-
Notifications
You must be signed in to change notification settings - Fork 24
Tune Python Remediation Points #86
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
|
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.