We’re seeing false positives for Jetpack Compose function names that are annotated with Composable, in which the convention is to capitalize the first letter of the Kotlin function:
@Composable
fun SampleScreen() { ... }
The false positive is: Rename function "SampleScreen" to match the regular expression ^[a-z][a-zA-Z0-9]*$
This contradicts the style guide for Compose here:
which states:
“Jetpack Compose framework development and Library development MUST name any function that returns Unit and bears the @Composable annotation using PascalCase, and the name MUST be that of a noun, not a verb or verb phrase, nor a nouned preposition, adjective or adverb. Nouns MAY be prefixed by descriptive adjectives. This guideline applies whether the function emits UI elements or not. App development SHOULD follow this same convention.”
I looked at this ticket, and I think the convention you mention applies to any factory function, not just the @Composable functions. See code convention.
I could think of 2 reasons why you still reference an old regex:
You use a pretty old version of SQ (<9.9) which has a very old Kotlin analyzer and doesn’t contain this change
You copied a SonarWay quality profile a long time ago before the default parameter was changed, and you never updated it.
As for the resolution, I think I can close the ticket, as the default already works the way code convention requires and according to Compose spec; from your side, since the rule is configurable, just change the parameter to the regex you want. Probably "^[a-zA-Z][a-zA-Z0-9]*$" should work.