This repository was archived by the owner on Jul 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Tune Python Remediation Points #86
Merged
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,20 @@ module Python | |
class Main < CC::Engine::Analyzers::Base | ||
LANGUAGE = "python" | ||
DEFAULT_PATHS = ["**/*.py"] | ||
DEFAULT_MASS_THRESHOLD = 40 | ||
BASE_POINTS = 1000 | ||
DEFAULT_MASS_THRESHOLD = 32 | ||
BASE_POINTS = 1_500_000 | ||
POINTS_PER_OVERAGE = 50_000 | ||
|
||
def calculate_points(mass) | ||
BASE_POINTS + (overage(mass) * POINTS_PER_OVERAGE) | ||
end | ||
|
||
private | ||
|
||
def overage(mass) | ||
mass - mass_threshold | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, you can also set a custom threshold. The method is inherited. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. OK. |
||
end | ||
|
||
def process_file(path) | ||
Node.new(::CC::Engine::Analyzers::Python::Parser.new(File.binread(path), path).parse.syntax_tree, path).format | ||
end | ||
|
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
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.
What do you think about assigning a local
overage
variable directly in#mass
, rather than the method call. Names are good, but extra indirection can be bad, and the fact that you have to thread themass
variable down to this private method is a point against IMO.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.
You mean in
#calculate_points
?That's fine by me...
I think it should be a separate refactor though.
So far, the ruby one uses the same format.
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.
https://github.com/codeclimate/codeclimate-duplication/blob/master/lib/cc/engine/analyzers/ruby/main.rb#L31
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.
Sounds good.
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.
Something to fix later, not to hold up this PR...
Wait, why do these methods exist more than once? Can't they be shared on
Base
then?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.
Yes +1
I guess the overage method could already by shared innocuously.
The
calculate_points
method hasn't been moved yet because 2 of the 4 languages use the oldcalculate_points
formula (base * mass)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.
Is that intentional? Is the card you're working on fix "Duplication" or fix "Python"?
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.
ATM I'd say
Fix python-duplication
which is the child ofFix python
.We've been tackling grade tuning on a per-language basis, descending into the language's engines.
Not sure if that's the best approach.
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.
OK, sounds good.