File tree 3 files changed +21
-8
lines changed
3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 10
10
11
11
before do
12
12
# capture_output_streams do
13
- RubyCritic ::Config . source_control_system = RubyCritic :: SourceControlSystem :: Git . new
13
+ RubyCritic ::Config . source_control_system = MockGit . new
14
14
runner = RubyCritic ::AnalysersRunner . new ( paths )
15
15
analysed_modules = runner . run
16
16
@reporter = Skunk ::Command ::StatusReporter . new ( { } )
17
17
@reporter . analysed_modules = analysed_modules
18
+ analysed_modules . first . churn = 1
18
19
@reporter . score = analysed_modules . score
19
20
# end
20
21
end
27
28
end
28
29
end
29
30
end
31
+
32
+ class MockGit < RubyCritic ::SourceControlSystem ::Git
33
+ def revisions_count ( _ )
34
+ 1
35
+ end
36
+ end
Original file line number Diff line number Diff line change 28
28
let ( :coverage ) { 0 }
29
29
30
30
it "should be 99.32" do
31
- @analysed_module . stink_score . must_equal 85.92
31
+ @analysed_module . stub ( :churn , 1 ) do
32
+ _ ( @analysed_module . stink_score ) . must_equal 85.92
33
+ end
32
34
end
33
35
end
34
36
35
37
context "when there is near-perfect code coverage" do
36
38
let ( :coverage ) { 95 }
37
39
38
40
it "should be penalized slightly" do
39
- @analysed_module . stink_score . must_equal 4.3
41
+ @analysed_module . stub ( :churn , 1 ) do
42
+ _ ( @analysed_module . stink_score ) . must_equal 4.3
43
+ end
40
44
end
41
45
end
42
46
43
47
context "when there is perfect code coverage" do
44
48
let ( :coverage ) { 100 }
45
49
46
50
it "should not be penalized" do
47
- @analysed_module . stink_score . must_equal 0.86
51
+ @analysed_module . stub ( :churn , 1 ) do
52
+ _ ( @analysed_module . stink_score ) . must_equal 0.86
53
+ end
48
54
end
49
55
end
50
56
end
Original file line number Diff line number Diff line change 1
1
+-----------------------------------------+-------------------------------+-------------------------------+------------------------------+------------------------------+------------------------------+
2
2
| file | stink_score | churn_times_cost | churn | cost | coverage |
3
3
+-----------------------------------------+-------------------------------+-------------------------------+------------------------------+------------------------------+------------------------------+
4
- | lib/skunk/rubycritic/analysed_module.rb | 24.06 | 0.8592 | 1 | 0.8592 | 72.72727272727273 |
4
+ | lib/skunk/rubycritic/analysed_module.rb | 0.86 | 0.8592 | 1 | 0.8592 | 100.0 |
5
5
+-----------------------------------------+-------------------------------+-------------------------------+------------------------------+------------------------------+------------------------------+
6
6
7
- StinkScore Total: 24.06
7
+ StinkScore Total: 0.86
8
8
Modules Analysed: 1
9
- StinkScore Average: 0.2406e2
10
- Worst StinkScore: 24.06 (lib/skunk/rubycritic/analysed_module.rb)
9
+ StinkScore Average: 0.86e0
10
+ Worst StinkScore: 0.86 (lib/skunk/rubycritic/analysed_module.rb)
You can’t perform that action at this time.
0 commit comments