appKODE / detekt-rules-compose

A collection of Detekt rules for Jetpack Compose
MIT License
136 stars 8 forks source link

Fixing incorrect rule name in readme #27

Closed patbeagan1 closed 1 year ago

patbeagan1 commented 1 year ago

The copy/paste section of the readme has a typo in it (Compose -> Composable).

I had copied this is into the detekt yaml file in my project, and turned off ComposeFunctionName, only to find that the errors persisted. The new name of the rule seems to be ComposableFunctionName. Things worked as expected after updating my yaml file to be

ComposableFunctionName: 
  active: false

For context on why I wanted to turn it off - some of the preview composables in my project forward to other composables that return Unit, or use themes which return Unit. The error will go off for things like this

RedButton(text: String) = BaseButton(text, Color.Red)

and this

@Preview MyButtonOnLight() = PreviewThemeLight { RedButton("Hello") }
@Preview MyButtonOnDark() = PreviewThemeDark { RedButton("Hello") }
dimsuz commented 1 year ago

Thank you for the PR! ComposeFunctionName was an initial name of this rule, but then we've renamed it to be more correct and missed this spot in the README, good catch!

As for you case, I think it should be supported, but it will require rewriting this rule to use detekt's type resolution mode. And in general this is where this rule set is headed (to have rules working in that mode), so I think, eventually your case will be covered, I'll remember it (or we could have an issue for this too).