-
-
Notifications
You must be signed in to change notification settings - Fork 797
[Deprecation] Add config ignoreImport
#7878
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
base: main
Are you sure you want to change the base?
[Deprecation] Add config ignoreImport
#7878
Conversation
48578dc
to
3532aab
Compare
@@ -31,7 +31,7 @@ class ArgumentListWrapping(config: Config) : FormattingRule( | |||
@Configuration("maximum line length") | |||
private val maxLineLength by configWithAndroidVariants(120, 100) | |||
|
|||
@Configuration("paremeter threshold to ignore rule") | |||
@Configuration("parameter threshold to ignore rule") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you move this change to other PR it will be merged automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the PR #7881
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And reverted from here
The title of this PR is wrong, right? There is nothing related with |
} | ||
""".trimIndent() | ||
assertThat(ignoredImportSubject.lintWithContext(env, code, deprecatedFile)) | ||
.isEmpty() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like ignoreImport
because it creates false negatives. Here the code is using deprecated code but the rule says nothing even when there are more usages of LegacyFeatureFlags
outside the imports block.
I also don't like that we can't suppress an issue over an import
. It bothers me a lot and I end up using full qualified names in places where I don't want but I think that's better than false negatives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't like that we can't suppress an issue over an import.
same, and most of the users end up suppressing the whole file which prevents any future issue from surfacing
More general issue here is that people tend to suppress at unnecessarily higher level which could be lowered down. Import becomes especially problematic as you don't have option other than file suppression
I end up using full qualified names
this is very hard to enforce across the team, also in most of cases using fully qualified name will report the line length violation
there are more usages of LegacyFeatureFlags outside the imports block
I didn't get this? there are three usages, two are suppressed and since we are using ignoredImportSubject
deprecation in Import is not being reported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! My bad, I didn't see the @Suppress
🤦♂️. That have way more sense. I'll re-review this.
ignoreRuleParameterThreshold
ignoreImport
3532aab
to
f08ddb3
Compare
@@ -21,15 +25,30 @@ class Deprecation(config: Config) : Rule( | |||
"Deprecated elements should not be used." | |||
) { | |||
|
|||
@Configuration("Ignore deprecation in import statements") | |||
private val ignoreImport: Boolean by config(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be plurals as we have excludeImports
in another rule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing out, I have renamed it to excludeImportStatements
which is also being used in MaxLineLength
rule
9e23d63
to
18b2297
Compare
This allows deprecation in imports
18b2297
to
e0df908
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7878 +/- ##
=========================================
Coverage 85.60% 85.61%
- Complexity 4224 4229 +5
=========================================
Files 574 574
Lines 13365 13372 +7
Branches 2540 2541 +1
=========================================
+ Hits 11441 11448 +7
Misses 653 653
Partials 1271 1271 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@Test | ||
fun `does not report import location`() { | ||
val deprecatedFile = """ | ||
package com.example.detekt.featureflag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @BraisGabin now my TC is failing when I pass -Pcompile-test-snippets=true
. I think this started failing after test api changes. Do you know if anything needs to be changed here?
This PR is stale because it has been open 90 days with no activity. Please comment or this will be closed in 7 days. |
This allows deprecation in imports
Fixes: #7402