Skip to content

Commit 8a3234f

Browse files
author
Ashley Baldwin-Hunter
committedJan 27, 2016
Merge pull request #86 from codeclimate/abh-python-points-algorithm
Tune Python Remediation Points
2 parents f721c03 + aff869e commit 8a3234f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed
 

Diff for: ‎lib/cc/engine/analyzers/python/main.rb

+11-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@ module Python
1212
class Main < CC::Engine::Analyzers::Base
1313
LANGUAGE = "python"
1414
DEFAULT_PATHS = ["**/*.py"]
15-
DEFAULT_MASS_THRESHOLD = 40
16-
BASE_POINTS = 1000
15+
DEFAULT_MASS_THRESHOLD = 32
16+
BASE_POINTS = 1_500_000
17+
POINTS_PER_OVERAGE = 50_000
18+
19+
def calculate_points(mass)
20+
BASE_POINTS + (overage(mass) * POINTS_PER_OVERAGE)
21+
end
1722

1823
private
1924

25+
def overage(mass)
26+
mass - mass_threshold
27+
end
28+
2029
def process_file(path)
2130
Node.new(::CC::Engine::Analyzers::Python::Parser.new(File.binread(path), path).parse.syntax_tree, path).format
2231
end

Diff for: ‎spec/cc/engine/analyzers/python/main_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"path" => "foo.py",
2929
"lines" => { "begin" => 1, "end" => 1 },
3030
})
31-
expect(json["remediation_points"]).to eq(6_000)
31+
expect(json["remediation_points"]).to eq(1_600_000)
3232
expect(json["other_locations"]).to eq([
3333
{"path" => "foo.py", "lines" => { "begin" => 2, "end" => 2} },
3434
{"path" => "foo.py", "lines" => { "begin" => 3, "end" => 3} }
@@ -56,7 +56,7 @@
5656
"path" => "foo.py",
5757
"lines" => { "begin" => 1, "end" => 1 },
5858
})
59-
expect(json["remediation_points"]).to eq(6_000)
59+
expect(json["remediation_points"]).to eq(1_600_000)
6060
expect(json["other_locations"]).to eq([
6161
{"path" => "foo.py", "lines" => { "begin" => 2, "end" => 2} },
6262
{"path" => "foo.py", "lines" => { "begin" => 3, "end" => 3} }

0 commit comments

Comments
 (0)