-
-
Notifications
You must be signed in to change notification settings - Fork 794
Detect deprecations #1913
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
Detect deprecations #1913
Conversation
* Deprecated elements are expected to be removed in future. Alternatives should be found if possible. | ||
* | ||
* <noncompliant> | ||
* \@Deprecated("deprecation message") |
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.
@Deprecated("deprecation message")
causes generateDocumentation task to throw an error.
\@Deprecated("deprecation message")
doesn't render correctly, though it does remove the syntax highlighting in IDE so @Deprecated
isn't highlighted, so probably that syntax should be accepted by generateDocumentation task.
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.
You need to use a html escape character for @
.
I used it somewhere ... some rule with annotations I don't remember anymore :'D
Codecov Report
@@ Coverage Diff @@
## master #1913 +/- ##
============================================
+ Coverage 80.45% 80.47% +0.01%
- Complexity 1968 2000 +32
============================================
Files 326 329 +3
Lines 5510 5602 +92
Branches 1022 1042 +20
============================================
+ Hits 4433 4508 +75
- Misses 543 545 +2
- Partials 534 549 +15
Continue to review full report at Codecov.
|
Looks good and super cool that we can just wrap compiler warnings! This way you can suppress detekt issues with normal IDEA/kotlinc suppressions. |
Aliases work. In this case though the detekt and Kotlin suppression is effectively the same (Deprecation/DEPRECATION), so We should either match the suppression ID that Kotlin uses when wrapping rules, or make sure it's different, and do it consistently. |
Maybe its too early in the morning for me to think but isn't this also handled by the aliases feature?
So the user only needs to suppress the kotlin compiler warning and detekt will also be suppressed? |
Understood - so if the rule is the same or very similar to the kotlinc rule, add a default alias like above. Thanks, that answers my question. I'll find the correct KDoc string as mentioned above then merge. |
Tested it. IntelliJ autogenerates |
Using I tried HTML-escaping with Maybe this one can go in without code samples? It's self-explanatory and I don't want to fix this in the doc generation code because it's an edge case currently. Unless you can find the other example? I searched all KDoc in detekt-rules but cannot find any line that starts with |
Wow I thought our generator will crash when no examples are provided. Edit: Yes here https://github.com/arturbosch/detekt/pull/1823/files#diff-e19d966035356c2d7cdf24a1957fa12aR1246 |
* Detect deprecations * generate documentation * Remove code examples * Add default alias * Fix typos
* Detect deprecations * generate documentation * Remove code examples * Add default alias * Fix typos
* Detect deprecations * generate documentation * Remove code examples * Add default alias * Fix typos
Closes #267
This rule uses the diagnostic warning built into the Kotlin compiler. Earlier discussion suggested that detekt could reimplement compiler warnings, so users have control over which compiler warnings will fail the build.
Implementing rules in this way implements checks for compiler warnings with minimal effort.
One issue is that suppressions for detekt compiler warnings are separated by underscore (like "UNCHECKED_CAST") while detekt uses CamelCase.
For rules that overlay compiler checks that have names with underscores we could match the rule ID so a single suppression (
@Suppress("UNCHECKED_CAST")
) would apply to both detekt and the compiler, but then the style of the rule ID differs from the rest of the rules which have CamelCase IDs.We should pick one option and stick to it because there are many built in warnings that would be good to implement in detekt.