[java] Update rule UseDiamondOperator#3253
Merged
Merged
Conversation
Convert it to a java rule
This reverts commit 8e570af.
Remove references to the 'diamond operator'. This is not an operator, it's just a syntax to avoid mentioning type arguments. The JLS says 'diamond type arguments', now we do too.
do inference for entire subtree instead of just one level
Generated by 🚫 Danger |
Prints eg net.sourceforge.pmd.internal.util.ContextedAssertionError: Detail message Exception Context: [1:Rule applied on node=[CastExpression:92:53](long ) (2 * (4 / 2 ) )]
also format
jsotuyod
reviewed
May 10, 2021
jsotuyod
reviewed
May 10, 2021
jsotuyod
reviewed
May 10, 2021
jsotuyod
reviewed
May 10, 2021
This was referenced May 13, 2021
adangel
added a commit
that referenced
this pull request
May 13, 2021
[java] Update rule UseDiamondOperator #3253
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the PR
Update the rule, converting it to a Java rule. The rule now uses the type res framework to improve its accuracy and recall. See the javadoc of the class.
Previously the rule had a "java 7 compatibility" property. This is now removed because Java 7-specific inference logic is supported by the type resolution engine now. So the rule doesn't need to care which version of java we use.
This should fix many false negatives, including:
List<String> l = new ArrayList()produces an unchecked warning, but you could writenew ArrayList<>()and avoid it.The rule's description now does not mention the "diamond operator". It's not an operator, it's just shorthand syntax. The JLS says "diamond type arguments", and now we do too. We would ideally rename the rule.
Messages are now much better.
The diamond
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)