-
Notifications
You must be signed in to change notification settings - Fork 25
Tune remediation points to match Classic #61
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
RSpec.describe CC::Engine::Analyzers::Violation, in_tmpdir: true do | ||
include AnalyzerSpecHelpers | ||
|
||
describe "#calculate_points" do | ||
context "when issue mass exceeds threshold" do | ||
it "calculates mass overage points" do | ||
language = double(:language, base_points: 100, points_per_overage: 5, mass_threshold: 10) | ||
issue = double(:issue, mass: 15) | ||
hashes = [] | ||
|
||
expected_points = 100 + 5 * (issue.mass - 10) | ||
|
||
violation = CC::Engine::Analyzers::Violation.new(language, issue, hashes) | ||
points = violation.calculate_points | ||
|
||
expect(points).to eq(expected_points) | ||
end | ||
end | ||
|
||
context "when issue mass is less than threshold" do | ||
it "uses default" do | ||
language = double(:language, base_points: 100, points_per_overage: 5, mass_threshold: 18) | ||
issue = double(:issue, mass: 15) | ||
hashes = [] | ||
|
||
expected_points = CC::Engine::Analyzers::Violation::DEFAULT_POINTS | ||
|
||
violation = CC::Engine::Analyzers::Violation.new(language, issue, hashes) | ||
points = violation.calculate_points | ||
|
||
expect(points).to eq(CC::Engine::Analyzers::Violation::DEFAULT_POINTS) | ||
end | ||
end | ||
|
||
context "when issue mass equals threshold" do | ||
it "calculates remediation points" do | ||
language = double(:language, base_points: 100, points_per_overage: 5, mass_threshold: 18) | ||
issue = double(:issue, mass: language.mass_threshold) | ||
hashes = [] | ||
|
||
expected_points = 100 + 5 * (issue.mass - language.mass_threshold) | ||
|
||
violation = CC::Engine::Analyzers::Violation.new(language, issue, hashes) | ||
points = violation.calculate_points | ||
|
||
expect(points).to eq(expected_points) | ||
end | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to clarify that this is intentional and vetted: previously these were different between PHP & Python/Javascript, and this change makes them the same, but keeps Ruby different.
The previous values were, I believe, picked after a lot of manual testing to get something that felt "right". What the "right" default threshold choice is for a language is dependent on how the parser the engines uses for that language ends up expressing ASTs. I.e. small parser differences can change how verbose a mass threshold ends up seeming.
Based on the classic code, it looks like this value was taken directly from there (and it didn't apply to Python in classic). I'd personally be pretty surprised if the AST results of all the languages was the same between classic & this engine: at the very least I'm pretty sure the JS parser behavior is different.
For that reason, I'm not sure the classic thresholds will make sense here, because they are likely to produce different results here than they did in classic. Do you have a sample corpus you've been using to verify same results for each of these languages between classic/these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wfleming Thanks for the tip about the thought behind the thresholds and parsing. I can investigate that.
I reference the classic rubric you mentioned in my commit, along with the Python source.
I've been keeping track of test repos
here. (removed link)In general, it seemed that on classic, duplication and complexity issues had much greater grade impact than they did on Platform.
I tested the current duplication setup on
app
- but could do some further testing with this exact setup on additional repos.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's a question of effort vs accuracy, but if the intent is to get results similar to classic, we should probably have a small corpus of files for each language, get the overall mass of each file as calculated both by classic & by this engine, and compare those to see if the thresholds (and to a lesser extent
per_point
values) need to be scaled to get matching results.