Skip to content

Commit

Permalink
Merge pull request #102 from fastruby/fixes/documentation-and-refacto…
Browse files Browse the repository at this point in the history
…rs-code
  • Loading branch information
etagwerker authored Nov 15, 2022
2 parents a4ed251 + f9e9f15 commit 6a601a5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## main [(unreleased)](https://github.com/fastruby/skunk/compare/v0.5.2...HEAD)

* <INSERT YOUR FEATURE OR BUGFIX HERE>
* [BUGFIX: Fix documentation and refactor `skunk_score` method](https://github.com/fastruby/skunk/pull/102)
* [FEATURE: Improve main workflow](https://github.com/fastruby/skunk/pull/99)
* [BUGFIX: Fix analized module test](https://github.com/fastruby/skunk/pull/98)

Expand Down
22 changes: 15 additions & 7 deletions lib/skunk/rubycritic/analysed_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,38 @@ class AnalysedModule
# Returns a numeric value that represents the skunk_score of a module:
#
# If module is perfectly covered, skunk score is the same as the
# `churn_times_cost`
# `cost`
#
# If module has no coverage, skunk score is a penalized value of
# `churn_times_cost`
# `cost`
#
# For now the skunk_score is calculated by multiplying `churn_times_cost`
# For now the skunk_score is calculated by multiplying `cost`
# times the lack of coverage.
#
# For example:
#
# When `churn_times_cost` is 100 and module is perfectly covered:
# When `cost` is 100 and module is perfectly covered:
# skunk_score => 100
#
# When `churn_times_cost` is 100 and module is not covered at all:
# When `cost` is 100 and module is not covered at all:
# skunk_score => 100 * 100 = 10_000
#
# When `churn_times_cost` is 100 and module is covered at 75%:
# When `cost` is 100 and module is covered at 75%:
# skunk_score => 100 * 25 (percentage uncovered) = 2_500
#
# @return [Float]
def skunk_score
return cost.round(2) if coverage == PERFECT_COVERAGE

(cost * (PERFECT_COVERAGE - coverage.to_i)).round(2)
(cost * penalty_factor).round(2)
end

# Returns a numeric value that represents the penalty factor based
# on the lack of code coverage (not enough test cases for this module)
#
# @return [Integer]
def penalty_factor
PERFECT_COVERAGE - coverage.to_i
end

# Returns the value of churn times cost.
Expand Down
2 changes: 1 addition & 1 deletion skunk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ Gem::Specification.new do |spec|
spec.add_dependency "rubycritic", ">= 4.5.2", "< 5.0"
spec.add_dependency "terminal-table", "~> 1.8.0"

spec.add_development_dependency "byebug", "~> 11"
spec.add_development_dependency "codecov", "~> 0.1.16"
spec.add_development_dependency "debug"
spec.add_development_dependency "minitest", "~> 5.8.4"
spec.add_development_dependency "minitest-around", "~> 0.5.0"
spec.add_development_dependency "minitest-stub_any_instance", "~> 1.0.2"
Expand Down

0 comments on commit 6a601a5

Please sign in to comment.