-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[cpd] Found match is not maximal #4835
Comments
This is actually not a false negative. Even though the code is extremely similar, the literal strings If C/C++ supported |
Oh, I see it now. I got confused by my own visualization. Anyway, could you give me some pointers, where in code the ignore literals is/should be handled. I could really use this so I will try to implement it myself. |
@jdupak sure! Any contributions are more than welcomed! First of, you would need to declare support for it on pmd/pmd-cpp/src/main/java/net/sourceforge/pmd/lang/cpp/CppLanguageModule.java Lines 46 to 51 in c9926fb
By adding a line Then you would have to edit Doing so basically requires first looking at Java implements exactly that here:
For ease of comprehension, these are the relevant bits of the Java implementation (as it also does other transformations): @Override
protected void processToken(TokenFactory tokenEntries, JavaccToken javaToken) {
String image = javaToken.getImage();
if (ignoreLiterals && (javaToken.kind == JavaTokenKinds.STRING_LITERAL
|| javaToken.kind == JavaTokenKinds.CHARACTER_LITERAL
|| javaToken.kind == JavaTokenKinds.INTEGER_LITERAL
|| javaToken.kind == JavaTokenKinds.FLOATING_POINT_LITERAL)) {
image = JavaTokenKinds.describe(javaToken.kind);
}
tokenEntries.recordToken(image, javaToken.getReportLocation());
} I believe this should be straight-forward given this context and detail, but let me know if you have any questions. |
Affects PMD Version: 6.55.0
The for loop and if are also identical.
The text was updated successfully, but these errors were encountered: