Skip to content

Commit 0eb5aec

Browse files
authored
Merge pull request #36 from fastruby/rename/skunk-score
Rename/skunk score
2 parents 055cee0 + 853f0c7 commit 0eb5aec

File tree

14 files changed

+67
-64
lines changed

14 files changed

+67
-64
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/pkg/
77
/spec/reports/
88
/tmp/
9+
/test/support/
910

1011
.byebug_history
1112

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased] [(commits)](https://github.com/fastruby/skunk/compare/v0.4.0...HEAD)
7+
## [Unreleased] [(commits)](https://github.com/fastruby/skunk/compare/v0.4.2...HEAD)
8+
9+
* [FEATURE] Rename the tech debt metric: StinkScore => SkunkScore. It's a little friendlier.
810

911
## [0.4.2] [(commits)](https://github.com/fastruby/skunk/compare/v0.4.1...v0.4.2)
1012
* [BUGFIX] Fixes table width issues by rounding values (by [@etagwerker][])

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md) [![Build Status](https://travis-ci.org/fastruby/skunk.svg?branch=master)](https://travis-ci.org/fastruby/skunk) [![Maintainability](https://api.codeclimate.com/v1/badges/3e33d701ced16eee2420/maintainability)](https://codeclimate.com/github/fastruby/skunk/maintainability) [![Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/gems/skunk) [![codecov](https://codecov.io/gh/fastruby/skunk/branch/master/graph/badge.svg)](https://codecov.io/gh/fastruby/skunk)
77

8-
A RubyCritic extension to calculate StinkScore for a file or project.
8+
A RubyCritic extension to calculate SkunkScore for a file or project.
99

10-
## What is the StinkScore?
10+
## What is the SkunkScore?
1111

12-
The StinkScore is a value that assesses the technical debt of a module. It takes
12+
The SkunkScore is a value that assesses the technical debt of a module. It takes
1313
into account:
1414

1515
- Code Complexity
1616
- Code Smells
1717
- Code Coverage
1818

19-
The main goal of the StinkScore is to serve as a compass in your next
19+
The main goal of the SkunkScore is to serve as a compass in your next
2020
refactoring adventure. It will help you answer these questions:
2121

2222
- What can I do to pay off technical debt?
@@ -89,7 +89,7 @@ running simple_cov
8989
.............
9090
New critique at file:////Users/etagwerker/Projects/fastruby/skunk/tmp/rubycritic/overview.html
9191
+-----------------------------------------------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+
92-
| file | stink_score | churn_times_cost | churn | cost | coverage |
92+
| file | skunk_score | churn_times_cost | churn | cost | coverage |
9393
+-----------------------------------------------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+
9494
| lib/skunk/cli/commands/default.rb | 166.44 | 1.6643999999999999 | 3 | 0.5548 | 0 |
9595
| lib/skunk/cli/application.rb | 139.2 | 1.392 | 3 | 0.46399999999999997 | 0 |
@@ -106,10 +106,10 @@ New critique at file:////Users/etagwerker/Projects/fastruby/skunk/tmp/rubycritic
106106
| lib/skunk/cli/commands/help.rb | 0.0 | 0.0 | 2 | 0.0 | 0 |
107107
+-----------------------------------------------------+----------------------------+----------------------------+----------------------------+----------------------------+----------------------------+
108108
109-
StinkScore Total: 612.31
109+
SkunkScore Total: 612.31
110110
Modules Analysed: 13
111-
StinkScore Average: 0.47100769230769230769230769231e2
112-
Worst StinkScore: 166.44 (lib/skunk/cli/commands/default.rb)
111+
SkunkScore Average: 0.47100769230769230769230769231e2
112+
Worst SkunkScore: 166.44 (lib/skunk/cli/commands/default.rb)
113113
```
114114

115115
The command will run `rubycritic` and it will try to load code coverage data
@@ -125,7 +125,7 @@ Simply run:
125125
skunk -b <target-branch-name>
126126
```
127127

128-
Then get a StinkScore average comparison:
128+
Then get a SkunkScore average comparison:
129129

130130
```
131131
$ skunk -b master
@@ -159,28 +159,28 @@ running churn
159159
.................
160160
running simple_cov
161161
.................
162-
Base branch (master) average stink score: 290.53999999999996
163-
Feature branch (feature/compare) average stink score: 340.3005882352941
162+
Base branch (master) average skunk score: 290.53999999999996
163+
Feature branch (feature/compare) average skunk score: 340.3005882352941
164164
Score: 340.3
165165
```
166166

167167
This should give you an idea if you're moving in the right direction or not.
168168

169169
## Known Issues
170170

171-
The StinkScore should be calculated per method. This would provide a more accurate
172-
representation of the average StinkScore in a module.
171+
The SkunkScore should be calculated per method. This would provide a more accurate
172+
representation of the average SkunkScore in a module.
173173

174-
I think that the StinkScore of a module should be the average of the StinkScores of
174+
I think that the SkunkScore of a module should be the average of the SkunkScores of
175175
all of its methods.
176176

177-
Right now the StinkScore is calculated using the totals for a module:
177+
Right now the SkunkScore is calculated using the totals for a module:
178178

179179
- Total Code Coverage Percentage per Module
180180
- Total Churn per Module
181181
- Total Cost per Module
182182

183-
For more details, feel free to review and improve this method: [RubyCritic::AnalysedModule#stink_score]
183+
For more details, feel free to review and improve this method: [RubyCritic::AnalysedModule#skunk_score]
184184

185185
## Development
186186

lib/skunk.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require "skunk/version"
44

5-
# Knows how to calculate the `StinkScore` for each file analyzed by `RubyCritic`
5+
# Knows how to calculate the `SkunkScore` for each file analyzed by `RubyCritic`
66
# and `SimpleCov`
77
module Skunk
88
end

lib/skunk/cli/commands/compare.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
# nodoc #
88
module Skunk
99
module Command
10-
# Knows how to compare two branches and their stink score average
10+
# Knows how to compare two branches and their skunk score average
1111
class Compare < RubyCritic::Command::Compare
1212
# switch branch and analyse files but don't generate a report
1313
def analyse_branch(branch)
1414
::RubyCritic::SourceControlSystem::Git.switch_branch(::RubyCritic::Config.send(branch))
1515
critic = critique(branch)
16-
::RubyCritic::Config.send(:"#{branch}_score=", critic.stink_score_average)
16+
::RubyCritic::Config.send(:"#{branch}_score=", critic.skunk_score_average)
1717
::RubyCritic::Config.root = branch_directory(branch)
1818
end
1919

@@ -30,9 +30,9 @@ def analyse_modified_files
3030
# create a txt file with the branch score details
3131
def build_details
3232
details = "Base branch (#{::RubyCritic::Config.base_branch}) "\
33-
"average stink score: #{::RubyCritic::Config.base_branch_score.to_f.round(2)} \n"\
33+
"average skunk score: #{::RubyCritic::Config.base_branch_score.to_f.round(2)} \n"\
3434
"Feature branch (#{::RubyCritic::Config.feature_branch}) "\
35-
"average stink score: #{::RubyCritic::Config.feature_branch_score.to_f.round(2)} \n"
35+
"average skunk score: #{::RubyCritic::Config.feature_branch_score.to_f.round(2)} \n"
3636
Skunk::Command::Output.create_directory(::RubyCritic::Config.compare_root_directory)
3737
File.open(build_details_path, "w") { |file| file.write(details) }
3838
puts details

lib/skunk/cli/commands/status_reporter.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ module Command
1010
class StatusReporter < RubyCritic::Command::StatusReporter
1111
attr_accessor :analysed_modules
1212

13-
HEADINGS = %w[file stink_score churn_times_cost churn cost coverage].freeze
13+
HEADINGS = %w[file skunk_score churn_times_cost churn cost coverage].freeze
1414
HEADINGS_WITHOUT_FILE = HEADINGS - %w[file]
1515
HEADINGS_WITHOUT_FILE_WIDTH = HEADINGS_WITHOUT_FILE.size * 17 # padding
1616

1717
TEMPLATE = ERB.new(<<-TEMPL
1818
<%= _ttable %>\n
19-
StinkScore Total: <%= total_stink_score %>
19+
SkunkScore Total: <%= total_skunk_score %>
2020
Modules Analysed: <%= analysed_modules_count %>
21-
StinkScore Average: <%= stink_score_average %>
22-
<% if worst %>Worst StinkScore: <%= worst.stink_score %> (<%= worst.pathname %>)<% end %>
21+
SkunkScore Average: <%= skunk_score_average %>
22+
<% if worst %>Worst SkunkScore: <%= worst.skunk_score %> (<%= worst.pathname %>)<% end %>
2323
2424
Generated with Skunk v<%= Skunk::VERSION %>
2525
TEMPL
2626
)
2727

2828
# Returns a status message with a table of all analysed_modules and
29-
# a stink score average
29+
# a skunk score average
3030
def update_status_message
3131
opts = table_options.merge(headings: HEADINGS, rows: table)
3232

@@ -52,21 +52,21 @@ def worst
5252
end
5353

5454
def sorted_modules
55-
@sorted_modules ||= non_test_modules.sort_by(&:stink_score).reverse!
55+
@sorted_modules ||= non_test_modules.sort_by(&:skunk_score).reverse!
5656
end
5757

58-
def total_stink_score
59-
@total_stink_score ||= non_test_modules.sum(&:stink_score)
58+
def total_skunk_score
59+
@total_skunk_score ||= non_test_modules.sum(&:skunk_score)
6060
end
6161

6262
def total_churn_times_cost
6363
non_test_modules.sum(&:churn_times_cost)
6464
end
6565

66-
def stink_score_average
66+
def skunk_score_average
6767
return 0 if analysed_modules_count.zero?
6868

69-
(total_stink_score.to_d / analysed_modules_count).to_f.round(2)
69+
(total_skunk_score.to_d / analysed_modules_count).to_f.round(2)
7070
end
7171

7272
def table_options
@@ -83,7 +83,7 @@ def table
8383
sorted_modules.map do |a_mod|
8484
[
8585
a_mod.pathname,
86-
a_mod.stink_score,
86+
a_mod.skunk_score,
8787
a_mod.churn_times_cost,
8888
a_mod.churn,
8989
a_mod.cost.round(2),

lib/skunk/rubycritic/analysed_module.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@
33
require "rubycritic/core/analysed_module"
44

55
module RubyCritic
6-
# Monkey-patches RubyCritic::AnalysedModule to add a stink_score method
6+
# Monkey-patches RubyCritic::AnalysedModule to add a skunk_score method
77
class AnalysedModule
88
PERFECT_COVERAGE = 100
99

10-
# Returns a numeric value that represents the stink_score of a module:
10+
# Returns a numeric value that represents the skunk_score of a module:
1111
#
12-
# If module is perfectly covered, stink score is the same as the
12+
# If module is perfectly covered, skunk score is the same as the
1313
# `churn_times_cost`
1414
#
15-
# If module has no coverage, stink score is a penalized value of
15+
# If module has no coverage, skunk score is a penalized value of
1616
# `churn_times_cost`
1717
#
18-
# For now the stink_score is calculated by multiplying `churn_times_cost`
18+
# For now the skunk_score is calculated by multiplying `churn_times_cost`
1919
# times the lack of coverage.
2020
#
2121
# For example:
2222
#
2323
# When `churn_times_cost` is 100 and module is perfectly covered:
24-
# stink_score => 100
24+
# skunk_score => 100
2525
#
2626
# When `churn_times_cost` is 100 and module is not covered at all:
27-
# stink_score => 100 * 100 = 10_000
27+
# skunk_score => 100 * 100 = 10_000
2828
#
2929
# When `churn_times_cost` is 100 and module is covered at 75%:
30-
# stink_score => 100 * 25 (percentage uncovered) = 2_500
30+
# skunk_score => 100 * 25 (percentage uncovered) = 2_500
3131
#
3232
# @return [Float]
33-
def stink_score
33+
def skunk_score
3434
return cost.round(2) if coverage == PERFECT_COVERAGE
3535

3636
(cost * (PERFECT_COVERAGE - coverage.to_i)).round(2)

lib/skunk/rubycritic/analysed_modules_collection.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
module RubyCritic
66
# nodoc #
77
class AnalysedModulesCollection
8-
def stink_score_average
8+
def skunk_score_average
99
num_modules = @modules.size
1010
if num_modules.positive?
11-
sum(&:stink_score) / num_modules.to_f
11+
sum(&:skunk_score) / num_modules.to_f
1212
else
1313
0.0
1414
end

samples/rubycritic/analysed_module.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@
33
require "rubycritic/core/analysed_module"
44

55
module RubyCritic
6-
# Monkey-patches RubyCritic::AnalysedModule to add a stink_score method
6+
# Monkey-patches RubyCritic::AnalysedModule to add a skunk_score method
77
class AnalysedModule
88
PERFECT_COVERAGE = 100
99

10-
# Returns a numeric value that represents the stink_score of a module:
10+
# Returns a numeric value that represents the skunk_score of a module:
1111
#
12-
# If module is perfectly covered, stink score is the same as the
12+
# If module is perfectly covered, skunk score is the same as the
1313
# `churn_times_cost`
1414
#
15-
# If module has no coverage, stink score is a penalized value of
15+
# If module has no coverage, skunk score is a penalized value of
1616
# `churn_times_cost`
1717
#
18-
# For now the stink_score is calculated by multiplying `churn_times_cost`
18+
# For now the skunk_score is calculated by multiplying `churn_times_cost`
1919
# times the lack of coverage.
2020
#
2121
# For example:
2222
#
2323
# When `churn_times_cost` is 100 and module is perfectly covered:
24-
# stink_score => 100
24+
# skunk_score => 100
2525
#
2626
# When `churn_times_cost` is 100 and module is not covered at all:
27-
# stink_score => 100 * 100 = 10_000
27+
# skunk_score => 100 * 100 = 10_000
2828
#
2929
# When `churn_times_cost` is 100 and module is covered at 75%:
30-
# stink_score => 100 * 25 (percentage uncovered) = 2_500
30+
# skunk_score => 100 * 25 (percentage uncovered) = 2_500
3131
#
3232
# @return [Float]
33-
def stink_score
33+
def skunk_score
3434
return cost.round(2) if coverage == PERFECT_COVERAGE
3535

3636
(cost * (PERFECT_COVERAGE - coverage.to_i)).round(2)

skunk.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
1111
spec.email = ["[email protected]"]
1212
spec.licenses = ["MIT"]
1313
spec.summary = "A library to assess code quality vs. code coverage"
14-
spec.description = "Knows how to calculate the StinkScore for a Ruby file"
14+
spec.description = "Knows how to calculate the SkunkScore for a set of Ruby modules"
1515
spec.homepage = "https://github.com/fastruby/skunk"
1616

1717
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'

0 commit comments

Comments
 (0)