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
Option to ignore generated code #28
Comments
@talios Could you provide an example? I followed the simple example from immutables.org but could not trigger any modernizer warnings. |
When compiling for JDK7 I get out of our builds:
The @Override
public String toString() {
return MoreObjects.toStringHelper("TrustedIpDto")
.add("id", id)
.add("name", name)
.add("dateRange", dateRange)
.toString();
} Maybe it's more an of option to treat guava as "semi modern"? |
+1
Exclude file can't help with that, because that violation is usefull for my handwrited code. |
I do not see an easy, general fix for this -- #3 (comment) suggests hooking the source annotation during compilation for later use in the main modernizer goal. I opened an upstream issue against immutables to use |
StringBuffer is extensively used in Datanucleus enchanced classes. See class |
immutables/immutables#749 is another issue in Immutables.org re. this... but it's probably unrealistic to expect all 3rd party code generators to adapt, so the idea of using #3 (comment) seems cool... In the case of Immutables.org, and perhaps other code generators, I've noticed that it also adds the In the case of Immutables.org specifically, a simple exclusion / ignore by class name could work, given that they are (typically, it's customizale) all named |
I think this can be solved as part of #3, which we're working on in our fork. The simplest thing that comes to mind is config flags like |
@jhaber |
Interesting, is it possible to run modernizer before the bytecode is modified? You also mentioned exclusions by target characteristics, did you have something particular in mind? |
@jhaber and @vladimirfx just wanted to make sure that you saw that there now IS actually already a new option to ignore/exclude by package / class name FQN reg exp, see #67. @jhaber if you have #3 working for some specific @SuppressWarnings, it perhaps shouldn't be that hard to extend that to also kick in for any javax.annotation.Generated? That was probably the initial goal of this issue. |
👍 for using the same mechanism to ignore |
Immutables added their own As reference jacoco recognizes all annotations that are called Generated as long as the rentention is wider than SOURCE. I think modernizer should do the same. This should already cover a great set of projects. |
This sounds like a great idea; can someone investigate implementing this? I believe it should be straightforward if you follow the existing |
Fixed by #99. |
A lot of code generated via tools like immutables.org trigger warnings from the plugin, it would be nice to be able to disable the warmings for these files.
In general, these are all annotated with
javax.annotation.Generated
, unfortunately that's flagged as@Retention(SOURCE)
so can't be tracked at the.class
level.Thoughts? Maybe add an exclusions list in the plugin configuration?
The text was updated successfully, but these errors were encountered: