Skip to content

Add suppression support to UnusedPropertyRule#5

Open
lithium147 wants to merge 1 commit intomainfrom
feature/unused-property-suppression
Open

Add suppression support to UnusedPropertyRule#5
lithium147 wants to merge 1 commit intomainfrom
feature/unused-property-suppression

Conversation

@lithium147
Copy link
Collaborator

@lithium147 lithium147 commented Mar 6, 2026

Add comment-based suppression for unused properties and tests, including JUnit TempDir-based parsing test and Maven inspection suppression.

Made-with: Cursor


Open with Devin

Add comment-based suppression for unused properties and tests, including JUnit TempDir-based parsing test and Maven inspection suppression.

Made-with: Cursor
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

public class UnusedPropertyRule extends AbstractEnforcerRule {
private static final Pattern PROPERTY_PATTERN = Pattern.compile("\\$\\{([^}]+)\\}");
private static final Pattern SUPPRESS_COMMENT = Pattern.compile("<!--\\s*suppress\\s+UnusedProperty\\s*-->", Pattern.CASE_INSENSITIVE);
private static final Pattern PROPERTY_ELEMENT = Pattern.compile("<([a-zA-Z0-9.-]+)>");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 PROPERTY_ELEMENT regex excludes underscores, silently skipping suppression for properties with underscores

The PROPERTY_ELEMENT pattern <([a-zA-Z0-9.-]+)> does not include underscores (_) in the character class. Maven property names commonly contain underscores (e.g., <my_lib.version>). If a user places <!-- suppress UnusedProperty --> before such a property, the suppression will silently fail because the element won't be matched by the regex, and the property will still be reported as unused despite the suppression comment.

Suggested change
private static final Pattern PROPERTY_ELEMENT = Pattern.compile("<([a-zA-Z0-9.-]+)>");
private static final Pattern PROPERTY_ELEMENT = Pattern.compile("<([a-zA-Z0-9._-]+)>");
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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 this pull request may close these issues.

1 participant