detekt - How to change function naming rule?

287 views Asked by At

I want to modify the rules of naming function because I am working on a project Android with Compose, and need a function starting with upper-case. Current condition:

@Compossable
fun SomeScreen() {} // violate naming function

The warning message:

Warning:(26, 5) detekt - FunctionNaming: Function names should match the pattern: [a-z][a-zA-Z0-9]*

I already create file detekt.yml and add it to configuration file, but still not working. here is my detekt configuration detekt.yml:

FunctionNaming:
    active: true
    functionPattern: '^[a-zA-Z][a-zA-Z0-9]*'

and this is configuration in my Android Studio

enter image description here

1

There are 1 answers

0
greyhairredbear On BEST ANSWER

In case that really is your entire configuration file, you are missing the ruleset element before the rule element itself:

naming:
  active: true
  FunctionNaming:
    active: true
    functionPattern: '^[a-zA-Z][a-zA-Z0-9]*'