Skip to content
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

diamond operator check gives false positive #1242

Closed
yegor256 opened this issue Mar 26, 2024 · 3 comments · Fixed by #1243
Closed

diamond operator check gives false positive #1242

yegor256 opened this issue Mar 26, 2024 · 3 comments · Fixed by #1243

Comments

@yegor256
Copy link
Owner

This is the code:

import java.util.Map;
import org.cactoos.map.MapEntry;
import org.cactoos.map.MapOf;

void foo() {
  Map<String, String> params = new MapOf<String, String>(
    new MapEntry<>("a", "foo"),
    new MapEntry<>("b", "foo")
  );
}

Qulice complains with PMD.UseDiamondOperator and DiamondOperatorCheck. However, I can't turn MapOf<String, String> into MapOf<>, because it won't compile. Can we do something about this?

@yegor256
Copy link
Owner Author

@pnatashap can you try to help?

Copy link

@yegor256 thanks for the report, but here some unclear moments:

  • The bug report title is not descriptive enough. It only mentions "diamond operator check gives false positive" but doesn't specify where or in what context. A more descriptive title would be "False positive on diamond operator check in MapOf class".
  • The report lacks essential details such as the software version, the operating system, and the development environment. Including these details can help to reproduce the bug and understand if it's a localized issue or a more general one.
  • The report is missing steps to reproduce the bug. Even though the code snippet is provided, it would be helpful to outline the steps leading to the issue.
  • The bug report doesn't mention the expected result and the actual result. The author should clarify what they expected to happen and what actually happened.
  • The report does not include any error messages or logs. These can provide valuable context and clues about what is causing the bug.
  • The report does not include any screenshots or screen recordings, which can be helpful to visualize the problem.
  • The report doesn't mention if this bug is consistent or if it happens intermittently. This information can help to understand the severity and the impact of the bug.
  • The author should avoid using phrases like "Can we do something about this?" and instead use a more formal language, such as "Suggesting to review the DiamondOperatorCheck for potential improvements".

Please fix the bug report in order it to get resolved faster.
Analyzed with gpt-4

@pnatashap
Copy link
Contributor

@yegor256 looks like this issue is solved in PMD 7 (they move rule to java code from XSL) https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UseDiamondOperatorRule.java
not sure that it is enough functionality in version 6 to just copy it, they have really change a lot. Will check migration guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants