Skip to content

[java] Fix problem with whitespace in properties#3064

Merged
adangel merged 4 commits into
pmd:masterfrom
oowekyala:issue2454-typehelper-trim-whitespace
Jan 21, 2021
Merged

[java] Fix problem with whitespace in properties#3064
adangel merged 4 commits into
pmd:masterfrom
oowekyala:issue2454-typehelper-trim-whitespace

Conversation

@oowekyala

Copy link
Copy Markdown
Member

Describe the PR

The problem with #2454 is that the input to TypeTestUtil is not sanitized to remove whitespace from the property value.

We can either

  • make TypeTestUtil lenient (as TypeHelper was)
  • make TypeTestUtil stricter, and validate user input higher up in the call tree

I prefer solution 2, so TypeTestUtil now checks that its input is a binary name without whitespace. Annotatable, which is a bit higher in the call tree, still cleans up the input strings, so it doesn't change behavior.

In PMD 7 I think we should be more restrictive vis à vis this user input, and sanitize it directly in the properties (eg with property constraints, refs #1432). Then we're sure that every class name we handle is a valid binary name.

The AssertionUtil here is extracted from the pmd 7 branch

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by travis)
  • Added (in-code) documentation (if needed)

Change contract in Annotatable interface

The goal is to allow us to drop support for canonical name
loading in PMD 7, for performance.
@oowekyala oowekyala added this to the 6.31.0 milestone Jan 16, 2021
@oowekyala oowekyala marked this pull request as ready for review January 16, 2021 21:10
@ghost

ghost commented Jan 16, 2021

Copy link
Copy Markdown
1 Message
📖 This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report

Generated by 🚫 Danger

@adangel adangel self-assigned this Jan 19, 2021

@adangel adangel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!
I agree, TypeTestUtil should be strict and validation should happen higher up.
And eventually (with PMD 7), we might even validate the properties already.

@adangel adangel merged commit 2f94ee6 into pmd:master Jan 21, 2021
adangel added a commit that referenced this pull request Jan 21, 2021
oowekyala:issue2454-typehelper-trim-whitespace

[java] Fix problem with whitespace in properties #3064
@oowekyala oowekyala deleted the issue2454-typehelper-trim-whitespace branch January 21, 2021 17:42
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.

[java] UnusedPrivateMethod violation for disabled class in 6.23.0

2 participants