Hey! I'm trying to implement custom detekt rules: ...
# detekt
f
Hey! I'm trying to implement custom detekt rules: - I added a new module for the rules - Added the new rule and tests (and it's working) - Added the META-INFO/services/... to point to the custom rule set provider. - Integrate the new ruleset with my project. My problem is that I just can't get the rule to be flagged (although the new ruleset appears in the output). Even if call
report
without any condition. Has anyone faced this?
m
Hey @fabio.carballo! Is your custom rule being called at all? As you mention that the tests for your custom rule are passing I don't think that some runtime error in the rule is causing this. But it might, depending on the input file.
f
I do believe it is not being run at all. I think that the problem should be in the configuration file. I'm going to look a bit more in that direction.
m
Did you add your module that contains the custom rules as a dependency in your main module?
detekt project(":customRulesModule")
f
yes yes
with this specific yml the rule outputs, with the one from my project it doesn't (https://github.com/vanniktech/kotlin-on-code-quality-tools/blob/master/demo/code_quality_tools/detekt.yml)
so, I'm tryiing to figure what is the faulty code, will let you know once I figure out
m
Oh interesting. So with the very small config.yml from that project it works and with your original config.yml it doesn't?
f
yup! exactly (if im not getting crazy meanwhile)
ok, found it: if
failFast: false
it won't flag it
if I set it to true it works
v
Yes. Just wanted to write that too. By default I think the rules are disabled.
failFast: true
enables all of 'em
f
cool, thanks for all the help! maybe something you could add to add add even more value for your article @vanniktech
👍 1
a
ah, all rules are deactivated by defailt so you have to enable them in the config ...
not that nice for custom rule sets..
maybe we should change this
v
Yeah we should