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

Fix severity condition #52

Merged
merged 2 commits into from
May 19, 2023

Conversation

Yurii-Zakharov
Copy link
Contributor

@Yurii-Zakharov Yurii-Zakharov commented May 19, 2023

Current condition check if violation.severity is equal or greater then inputs.severityThreshold from numbers perspective, but what we want is to check from severity perspective.

Severity perspective
1-5 where
1 - highest
5 - lowest
https://docs.pmd-code.org/pmd-doc-6.55.0/pmd_userdocs_configuring_rules.html#message-and-priority-overriding

In main branch

  • We set inputs.severityThreshold = 2 which means we want to throw error when severity is 2 or greater (1).
  • We run scan and violation.severity = 3 appears.
  • Next conditions is checked (inputs.severityThreshold <= violation.severity) -> True
  • Error is thrown. But it is not what we wanted. 2 is less then 3 from numbers meaning, but from severity perspective it is greater.

In fixSeverityCondition branch

  • We set inputs.severityThreshold = 2 which means we want to throw error when severity is 2 or greater (1).
  • We run scan and violation.severity = 3 appears.
  • Next conditions is checked (inputs.severityThreshold >= violation.severity) -> False
  • Continue without error. It is what we wanted. 2 is greater then 3 from from severity perspective.

The same way sfdx scanner plugin is working. While stating:

-s, --severity-threshold=_severity-threshold_
Throws an error when violations are found with equal or greater severity than the provided value. 

They consider this severity perspective.

https://forcedotcom.github.io/sfdx-scanner/en/v3.x/scanner-commands/run/

Copy link
Owner

@mitchspano mitchspano left a comment

Choose a reason for hiding this comment

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

Good catch - thank you for your contributions

@mitchspano mitchspano merged commit 47008f9 into mitchspano:main May 19, 2023
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.

2 participants