-
Notifications
You must be signed in to change notification settings - Fork 55
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
Optional <until> element ignores violations since a specific Java version #313
base: master
Are you sure you want to change the base?
Conversation
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.
Could you address the comment and Checkstyle violations?
@@ -390,7 +390,7 @@ public void testAnnotationViolation() throws Exception { | |||
String name = TestAnnotation.class.getName().replace('.', '/'); | |||
Map<String, Violation> testViolations = Maps.newHashMap(); | |||
testViolations.put(name, | |||
new Violation(name, 5, "")); | |||
new Violation(name, 5, OptionalInt.empty(), "")); |
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.
Could you add a until test that makes sure the intended violation messages are triggered depending on the requested version?
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 did not work in my testing.
This PR introduces a new feature: Ignoring violations past a specific version.
The new, optional XML attribute
<until>
holds a version since when a<violation>
is to be ignored. This is straight-forward and aligned with the existing syntax, as<version>
does exactly the same, but inverse: It ignores violations prior to a specific version.As a first proof-of-concept, the
modernizer.xml
now has separate proposals for the replacement ofnew File(...)
:Paths.get(...)
.Path.of(...)
.Closes #303
Alternatives:
<until>
element, but instead from a set of identically named violations, only apply the one with the highest version within the target version. This is complex to implement and less flexible, as it prevents the possibility to intentionally apply two identially named violations at the same time (I don't know why someone would want that, but I could imagine that there are use cases for this, possibly once we eventually add more functionality besides printing the comment).comment
. This is less flexible, as it excludes the possibility to exclude violations in general - it only changes the comment. If eventually we come up with additional functionality (like rewriting code), we might like to skip the violation in general.