-
-
Notifications
You must be signed in to change notification settings - Fork 779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove hardcoded default values from rules #2597
Comments
Those values are the same as in |
So, for what you are saying, this is wrong, right: We should have something like this: private val ignoredExceptionTypes = SplitPattern(valueOrDefault(IGNORED_EXCEPTION_TYPES,
"InterruptedException,NumberFormatException,ParseException,MalformedURLException")) I was confused here because I saw a lot of rules that have this problem. So I didn't know if the default value could be removed or we should fix the rules that doesn't have the proper default values. |
Ah, yes good find. Indeed these properties need the defaults from the configuration documentation. |
@arturbosch can you share this config documentation so I can take a look at the expected default values? |
I think that artur refers about this documentation: https://detekt.github.io/detekt/comments.html |
guys, I just opened my very first PR contributing to Open Source. if you please can take a look and see if it solves this issue 👍 |
Expected Behavior
All the lines of code that we have in our production code are "meaningful".
Observed Behavior
The second parameter in this functions is never used in production:
valueOrDefault(KEY, "value")
and it's really missleading when you are writing/editing a rule.Context
Working on #2498 I found some rules that doesn't have the default value hardcoded in it. And I created commits to fix that (4073097 and e7c0190)
But as I continue working in #2498 I see that there are even more rules that have this "issue".
I think that those values are there to make the tests easier. But we should not add any code in production to make the tests easier to write.
My proposal: change the use of
valueOrDefault(key, value)
tovalueString(key)
,valueBoolean(key)
...Good thing: This is not a breaking change.
The text was updated successfully, but these errors were encountered: