Skip to content

Commit

Permalink
Don't allow the usage of ` in function names
Browse files Browse the repository at this point in the history
  • Loading branch information
BraisGabin committed Jan 2, 2022
1 parent eb0f1cf commit eac3708
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion detekt-core/src/main/resources/default-detekt-config.yml
Expand Up @@ -446,7 +446,7 @@ naming:
FunctionNaming:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)'
functionPattern: '[a-z][a-zA-Z0-9]*'
excludeClassPattern: '$^'
ignoreOverridden: true
FunctionParameterNaming:
Expand Down
Expand Up @@ -32,7 +32,7 @@ class FunctionNaming(config: Config = Config.empty) : Rule(config) {
)

@Configuration("naming pattern")
private val functionPattern: Regex by config("([a-z][a-zA-Z0-9]*)|(`.*`)", String::toRegex)
private val functionPattern: Regex by config("[a-z][a-zA-Z0-9]*", String::toRegex)

@Configuration("ignores functions in classes which match this regex")
private val excludeClassPattern: Regex by config("$^", String::toRegex)
Expand Down
Expand Up @@ -97,11 +97,11 @@ class FunctionNamingSpec : Spek({
)
}

it("allow functions with backtick") {
it("doesn't allow functions with backtick") {
val code = """
fun `7his is a function name _`() = Unit
"""
assertThat(FunctionNaming().compileAndLint(code)).isEmpty()
assertThat(FunctionNaming().compileAndLint(code)).hasSourceLocations(SourceLocation(1, 5))
}
}
})

0 comments on commit eac3708

Please sign in to comment.