Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Property 'TwitterCompose' is misspelled or does not exist. #100

Closed
ege-ah opened this issue Oct 11, 2022 · 7 comments
Closed

Property 'TwitterCompose' is misspelled or does not exist. #100

ege-ah opened this issue Oct 11, 2022 · 7 comments

Comments

@ege-ah
Copy link

ege-ah commented Oct 11, 2022

When the detektPlugin applied and rules added to the config file, CI build fails with error

Run failed with 1 invalid config property. - Property 'TwitterCompose' is misspelled or does not exist.

To Reproduce
Steps to reproduce the behavior:

  1. Apply plugin
dependencies {
            detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion")
            detektPlugins("com.twitter.compose.rules:detekt:$twitterComposeVersion")
        }
  1. Add compose rules to bottom of the existing detekt-config.xml
TwitterCompose:
  CompositionLocalAllowlist:
    active: true
    # You can optionally define a list of CompositionLocals that are allowed here
    # allowedCompositionLocals: LocalSomething,LocalSomethingElse
  CompositionLocalNaming:
    active: true
  ContentEmitterReturningValues:
    active: true
    # You can optionally add your own composables here
    # contentEmitters: MyComposable,MyOtherComposable
  ModifierComposable:
    active: true
  ModifierMissing:
    active: true
  ModifierReused:
    active: true
  ModifierWithoutDefault:
    active: true
  MultipleEmitters:
    active: true
    # You can optionally add your own composables here
    # contentEmitters: MyComposable,MyOtherComposable
  MutableParams:
    active: true
  ComposableNaming:
    active: true
  ComposableParamOrder:
    active: true
  PreviewNaming:
    active: true
  PreviewPublic:
    active: false
  RememberMissing:
    active: true
  UnstableCollections:
    active: true
  ViewModelForwarding:
    active: true
  ViewModelInjection:
    active: true
  1. Run ./gradlew sonarqube

Expected behavior
Project compiles and CI build success

Instead it is failing on CI and locally, note that current detekt setup is working properly after deleting the TwitterCompose rule set.

Environment
Version 1.21

* What went wrong:
Execution failed for task ':sonarqube'.
> Run failed with 1 invalid config property.
  	- Property 'TwitterCompose' is misspelled or does not exist.
@mrmans0n
Copy link
Contributor

mrmans0n commented Oct 11, 2022

This means your rule is not properly brought on the module detekt wants to be running on. Make sure your gradle setup is correct and the rule is being applied in the right place.

Namely, this means that your step 1 is not correctly done (e.g. not done in the right place, at all necessary times).

For example, this happened to me when I was applying the detekt gradle plugin to modules but the detektPlugins was not applied to exactly the same modules the gradle plugin was being applied to.

@ege-ah
Copy link
Author

ege-ah commented Oct 11, 2022

How come detekt is working properly and CI doesnt fail without this plugin?

@mrmans0n
Copy link
Contributor

This is a custom plugin that has configuration to be added in detekt.yml. If the detekt gradle plugin is running through a module and finds this in detekt.yml, without seeing a plugin that can handle it, that's when you see this error. It's a mechanism Detekt has to detect misconfigurations in the build when using custom plugins.

It means that there is at least 1 place (maybe more, but at least 1) where detekt sees your config but doesn't have detektPlugins("com.twitter.compose.rules:detekt:$twitterComposeVersion") and it needs it.

From what you pasted here I cannot tell you exactly where it's wrong, but the error you are seeing is because of what I mentioned 😅

@ege-ah
Copy link
Author

ege-ah commented Oct 12, 2022

thanks for the response but still cannot understand why detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion")

works but not twittterCompose plugin, they are both in detekt.gradle which is applied in build.gradle (app)

@mrmans0n
Copy link
Contributor

mrmans0n commented Oct 13, 2022

As it's a rule they themselves maintain, the tooling provided out of the box contains generating the formatting defaults, so the proper config should already be there everywhere it's necessary (at least it used to anyway). They also include a default value in their resources/ (which I guess it's something we could do as well if it's open for everyone! will make a note to look into that if it helps)

I'm not super keen on providing a default for everything though because it kind of hides everything you can configure. The content emitters and the composition local allowlists are things I'd love people to set up in almost every situation, so adding a default fallback might lead to unintended situations like some modules not properly configured missing that part of the custom config and not failing to run with that error you saw 😬

So we'll have to think about it and see the pros/cons before moving forward with that 😅

@alvindizon
Copy link

I encountered this same error. Can this be used together with io.gitlab.arturbosch.detekt:detekt-formatting?

@mrmans0n
Copy link
Contributor

mrmans0n commented Nov 3, 2023

Use the fork at https://github.com/mrmans0n/compose-rules instead. It shouldn't be a problem there, plus all active development of this project moved there.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants