Skip to content

[apex] Stricter hardcoded ID detection - #1031

Merged
adangel merged 2 commits into
pmd:masterfrom
jsotuyod:issue-776
Apr 24, 2018
Merged

adangel merged 2 commits into
pmd:masterfrom
jsotuyod:issue-776

Conversation

@jsotuyod

Copy link
Copy Markdown
Member

 - IDs are only 15, or 18 digits long
 - 18 digits long IDs are actually 15 digit IDs + checksum, which is now
validated
 - Resolves pmd#776
@jsotuyod jsotuyod added the a:false-positive PMD flags a piece of code that is not problematic label Apr 10, 2018
@jsotuyod jsotuyod added this to the 6.3.0 milestone Apr 10, 2018
@adangel adangel self-assigned this Apr 24, 2018

@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.

Looks good. I'll add the test case of the original bug report, just to be sure.

@jsotuyod

Copy link
Copy Markdown
Member Author

@adangel the original bug report dealt with the string '359040082913024' which is 15-chars long and has a 0 in the 6th position. That case will still be flagged, as we can't validate anything else on those IDs that I'm aware of. The cases we do discard (that arouse in the discussion on that report) were:

  1. 16 and 17-chars long "ids"
  2. 18-chars long that don't actually pass the checksum check

That's why I added test-cases for those scenarios, but no for the original reported string

@adangel

adangel commented Apr 24, 2018

Copy link
Copy Markdown
Member

@jsotuyod Yes, I've seen it - the id from the original bug report can only be suppressed, since we can't figure out whether that's a salesforce id or not.

@adangel
adangel merged commit ffd88ef into pmd:master Apr 24, 2018
@jsotuyod
jsotuyod deleted the issue-776 branch April 24, 2018 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a:false-positive PMD flags a piece of code that is not problematic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants