skunk 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +19 -0
- data/.github/workflows/skunk.yml +24 -0
- data/CHANGELOG.md +28 -6
- data/Gemfile.lock +6 -6
- data/README.md +16 -7
- data/bin/skunk +1 -0
- data/lib/skunk/cli/commands/compare.rb +5 -3
- data/lib/skunk/cli/commands/output.rb +12 -0
- data/lib/skunk/cli/commands/status_reporter.rb +5 -1
- data/lib/skunk/cli/commands/version.rb +16 -0
- data/lib/skunk/cli/options/argv.rb +0 -7
- data/lib/skunk/version.rb +1 -1
- data/skunk.gemspec +1 -1
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c775bb1b34ac224cae3a0485f7279207f2454d2b03cec80f8033d596722b244
|
4
|
+
data.tar.gz: f24e05b044b854d5389ae7ca3f4b1399f2cea4ea154940dafc6ebae7ed3e8c35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ee6532b02608d746f58317d525da5c0350522326f6431ef2a078d20d721ac5656aea422229915abb70a64f24d4a9b7ed687ce6a69b8bdba75d571b88257b4a1
|
7
|
+
data.tar.gz: 5c6a3555e1b9e9ac3bba2497b71229350ef493dcbe59f203a01b1175009bfc47fa0821fd061543e8ef72bfaf3e0b4b671271a4c35b3a46f8eba0e6cd311ada0c
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# .github/workflows/ci.yml
|
2
|
+
|
3
|
+
name: CI
|
4
|
+
on: [push, pull_request]
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v1
|
11
|
+
- name: Setup Ruby
|
12
|
+
uses: actions/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 2.6.x
|
15
|
+
- name: Build and run tests
|
16
|
+
run: |
|
17
|
+
gem install bundler
|
18
|
+
bundle install --jobs 4 --retry 3
|
19
|
+
bundle exec rake
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Skunk
|
2
|
+
on: [push, pull_request]
|
3
|
+
|
4
|
+
jobs:
|
5
|
+
skunk:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v1
|
10
|
+
- name: Setup Ruby
|
11
|
+
uses: actions/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 2.6.x
|
14
|
+
- name: Run Skunk on Project
|
15
|
+
run: |
|
16
|
+
gem install skunk
|
17
|
+
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
18
|
+
if [[ "$CURRENT_BRANCH" -ne "master" ]]; then
|
19
|
+
echo "Executing within branch: $CURRENT_BRANCH"
|
20
|
+
skunk lib/
|
21
|
+
else
|
22
|
+
echo "Executing within master branch"
|
23
|
+
skunk lib/ -b master
|
24
|
+
fi
|
data/CHANGELOG.md
CHANGED
@@ -4,13 +4,35 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## [Unreleased]
|
7
|
+
## [Unreleased] [(commits)](https://github.com/fastruby/skunk/compare/v0.4.0...HEAD)
|
8
8
|
|
9
|
-
## [
|
9
|
+
## [Unreleased] [(commits)](https://github.com/fastruby/skunk/compare/v0.3.2...v0.4.0)
|
10
|
+
* [FEATURE] Add `--version` support to the command line. (by [@bronzdoc][])
|
11
|
+
* [FEATURE] Stop accepting `-p <path>` in the command line. It's redundant and it's not working anyway. (by [@etagwerker][])
|
12
|
+
* [BUGFIX] Change "StinkScore" formula to skip `churn_times_cost` (by [@etagwerker][])
|
13
|
+
* [BUGFIX] Fixes #12 (by [@sebastian-palma][])
|
14
|
+
|
15
|
+
## [0.3.2] - 2019-11-23 [(commits)](https://github.com/fastruby/skunk/compare/v0.3.1...v0.3.2)
|
16
|
+
### Changed
|
17
|
+
* [BUGFIX] Change "StinkScore" formula to skip `churn_times_cost` (by [@etagwerker][])
|
18
|
+
|
19
|
+
## [0.3.1] - 2019-11-19 [(commits)](https://github.com/fastruby/skunk/compare/v0.3.0...v0.3.1)
|
20
|
+
### Changed
|
21
|
+
* [BUGFIX] Change "StinkScore" formula to skip `churn_times_cost` (by [@etagwerker][])
|
22
|
+
|
23
|
+
## [0.3.0] - 2019-11-19 [(commits)](https://github.com/fastruby/skunk/compare/v0.2.0...v0.3.0)
|
24
|
+
### Changed
|
25
|
+
* [FEATURE] Added Travis CI badge to README (by [@themayurkumbhar][])
|
26
|
+
* [FEATURE] Now you can compare "StinkScore" between branches (by [@etagwerker][])
|
27
|
+
* [BUGFIX] Add contributor covenant doc (by [@etagwerker][])
|
28
|
+
* [BUGFIX] Make sure tests work even you don't have a `coverage/.resultset.json` file (by [@etagwerker][])
|
29
|
+
* [BUGFIX] Make tests easier to maintain (by [@etagwerker][])
|
30
|
+
|
31
|
+
## [0.2.0] - 2019-10-16 [(commits)](https://github.com/fastruby/skunk/compare/v0.1.0...v0.2.0)
|
10
32
|
### Changed
|
11
|
-
- Now `skunk` will not report status for files that start with `test/` or `spec/`
|
33
|
+
- [FEATURE] Now `skunk` will not report status for files that start with `test/` or `spec/` (by [@etagwerker][])
|
12
34
|
|
13
|
-
## [0.1.0] - 2019-10-
|
35
|
+
## [0.1.0] - 2019-10-16
|
14
36
|
### Added
|
15
|
-
- Now `skunk` uses `rubycritic-simplecov` to generate a console report with a list
|
16
|
-
of files and their "StinkScore"
|
37
|
+
- [FEATURE] Now `skunk` uses `rubycritic-simplecov` to generate a console report with a list
|
38
|
+
of files and their "StinkScore" (by [@etagwerker][])
|
data/Gemfile.lock
CHANGED
@@ -2,7 +2,7 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
skunk (0.3.2)
|
5
|
-
rubycritic (~> 4.
|
5
|
+
rubycritic (~> 4.0)
|
6
6
|
terminal-table (~> 1.8.0)
|
7
7
|
|
8
8
|
GEM
|
@@ -31,7 +31,7 @@ GEM
|
|
31
31
|
path_expander (~> 1.0)
|
32
32
|
ruby_parser (~> 3.0)
|
33
33
|
sexp_processor (~> 4.0)
|
34
|
-
flog (4.6.
|
34
|
+
flog (4.6.4)
|
35
35
|
path_expander (~> 1.0)
|
36
36
|
ruby_parser (~> 3.1, > 3.1.0)
|
37
37
|
sexp_processor (~> 4.8)
|
@@ -49,7 +49,7 @@ GEM
|
|
49
49
|
ast (~> 2.4.0)
|
50
50
|
path_expander (1.1.0)
|
51
51
|
psych (3.1.0)
|
52
|
-
public_suffix (4.0.
|
52
|
+
public_suffix (4.0.3)
|
53
53
|
rainbow (3.0.0)
|
54
54
|
rake (10.5.0)
|
55
55
|
reek (5.4.1)
|
@@ -68,11 +68,11 @@ GEM
|
|
68
68
|
ruby-progressbar (1.10.1)
|
69
69
|
ruby_parser (3.14.1)
|
70
70
|
sexp_processor (~> 4.9)
|
71
|
-
rubycritic (4.
|
71
|
+
rubycritic (4.3.2)
|
72
72
|
flay (~> 2.8)
|
73
73
|
flog (~> 4.4)
|
74
74
|
launchy (= 2.4.3)
|
75
|
-
parser (
|
75
|
+
parser (>= 2.6.0)
|
76
76
|
rainbow (~> 3.0)
|
77
77
|
reek (~> 5.0, < 6.0)
|
78
78
|
ruby_parser (~> 3.8)
|
@@ -92,7 +92,7 @@ GEM
|
|
92
92
|
terminal-table (1.8.0)
|
93
93
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
94
94
|
thread_safe (0.3.6)
|
95
|
-
tty-which (0.4.
|
95
|
+
tty-which (0.4.2)
|
96
96
|
unicode-display_width (1.6.0)
|
97
97
|
virtus (1.0.5)
|
98
98
|
axiom-types (~> 0.1)
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Skunk
|
2
2
|
|
3
|
-
[![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)
|
3
|
+
[![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)
|
4
4
|
|
5
5
|
A RubyCritic extension to calculate StinkScore for a file or project.
|
6
6
|
|
7
7
|
## What is the StinkScore?
|
8
8
|
|
9
|
-
The StinkScore is a value that assesses the
|
10
|
-
account:
|
9
|
+
The StinkScore is a value that assesses the technical debt of a module. It takes
|
10
|
+
into account:
|
11
11
|
|
12
12
|
- Code Complexity
|
13
13
|
- Code Smells
|
@@ -19,7 +19,7 @@ refactoring adventure. It will help you answer these questions:
|
|
19
19
|
- What can I do to pay off technical debt?
|
20
20
|
- What are the most complicated files with the least code coverage?
|
21
21
|
- What are good candidates for your next test-writing efforts?
|
22
|
-
- What are good candidates for your
|
22
|
+
- What are good candidates for your next refactoring efforts?
|
23
23
|
|
24
24
|
The formula is not perfect and it is certainly controversial, so any feedback is
|
25
25
|
welcome as a new issue!
|
@@ -42,6 +42,18 @@ Or install it yourself as:
|
|
42
42
|
|
43
43
|
## Usage
|
44
44
|
|
45
|
+
### Help details
|
46
|
+
|
47
|
+
There are not that many options but here they are:
|
48
|
+
|
49
|
+
```
|
50
|
+
skunk -h
|
51
|
+
Usage: skunk [options] [paths]
|
52
|
+
-b, --branch BRANCH Set branch to compare
|
53
|
+
-v, --version Show gem's version
|
54
|
+
-h, --help Show this message
|
55
|
+
```
|
56
|
+
|
45
57
|
### Getting a sorted list of stinkiest files
|
46
58
|
|
47
59
|
To get the best results, make sure that you have `coverage/.resultset.json` in
|
@@ -58,9 +70,6 @@ Then get a list of stinky files:
|
|
58
70
|
|
59
71
|
```
|
60
72
|
$ skunk
|
61
|
-
warning: parser/current is loading parser/ruby26, which recognizes
|
62
|
-
warning: 2.6.5-compliant syntax, but you are running 2.6.2.
|
63
|
-
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
|
64
73
|
running flay smells
|
65
74
|
|
66
75
|
running flog smells
|
data/bin/skunk
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
../exe/skunk
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "rubycritic/commands/compare"
|
4
4
|
require "skunk/rubycritic/analysed_modules_collection"
|
5
|
+
require "skunk/cli/commands/output"
|
5
6
|
|
6
7
|
# nodoc #
|
7
8
|
module Skunk
|
@@ -29,9 +30,10 @@ module Skunk
|
|
29
30
|
# create a txt file with the branch score details
|
30
31
|
def build_details
|
31
32
|
details = "Base branch (#{::RubyCritic::Config.base_branch}) "\
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
"average stink score: #{::RubyCritic::Config.base_branch_score} \n"\
|
34
|
+
"Feature branch (#{::RubyCritic::Config.feature_branch}) "\
|
35
|
+
"average stink score: #{::RubyCritic::Config.feature_branch_score} \n"
|
36
|
+
Skunk::Command::Output.create_directory(::RubyCritic::Config.compare_root_directory)
|
35
37
|
File.open(build_details_path, "w") { |file| file.write(details) }
|
36
38
|
puts details
|
37
39
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Skunk
|
4
|
+
module Command
|
5
|
+
# Implements the needed methods for a successful compare output
|
6
|
+
class Output
|
7
|
+
def self.create_directory(directory)
|
8
|
+
FileUtils.mkdir_p(directory) unless File.exist?(directory)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -11,6 +11,8 @@ module Skunk
|
|
11
11
|
attr_accessor :analysed_modules
|
12
12
|
|
13
13
|
HEADINGS = %w[file stink_score churn_times_cost churn cost coverage].freeze
|
14
|
+
HEADINGS_WITHOUT_FILE = HEADINGS - %w[file]
|
15
|
+
HEADINGS_WITHOUT_FILE_WIDTH = HEADINGS_WITHOUT_FILE.size * 15 # padding
|
14
16
|
|
15
17
|
TEMPLATE = ERB.new(<<-TEMPL
|
16
18
|
<%= _ttable %>\n
|
@@ -66,9 +68,11 @@ TEMPL
|
|
66
68
|
end
|
67
69
|
|
68
70
|
def table_options
|
71
|
+
max = sorted_modules.max_by { |a_mod| a_mod.pathname.to_s.length }
|
72
|
+
width = max.pathname.to_s.length + HEADINGS_WITHOUT_FILE_WIDTH
|
69
73
|
{
|
70
74
|
style: {
|
71
|
-
width:
|
75
|
+
width: width
|
72
76
|
}
|
73
77
|
}
|
74
78
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubycritic/commands/version"
|
4
|
+
|
5
|
+
# nodoc #
|
6
|
+
module Skunk
|
7
|
+
module Command
|
8
|
+
# Shows skunk version
|
9
|
+
class Version < RubyCritic::Command::Version
|
10
|
+
def execute
|
11
|
+
print Skunk::VERSION
|
12
|
+
status_reporter
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -13,13 +13,6 @@ module Skunk
|
|
13
13
|
parser.new do |opts|
|
14
14
|
opts.banner = "Usage: skunk [options] [paths]\n"
|
15
15
|
|
16
|
-
opts.on(
|
17
|
-
"-p", "--path [PATH]",
|
18
|
-
"Set path where report will be saved (tmp/skunk by default)"
|
19
|
-
) do |path|
|
20
|
-
@root = path
|
21
|
-
end
|
22
|
-
|
23
16
|
opts.on("-b", "--branch BRANCH", "Set branch to compare") do |branch|
|
24
17
|
self.base_branch = String(branch)
|
25
18
|
set_current_branch
|
data/lib/skunk/version.rb
CHANGED
data/skunk.gemspec
CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
37
|
spec.require_paths = ["lib"]
|
38
38
|
|
39
|
-
spec.add_dependency "rubycritic", "~> 4.
|
39
|
+
spec.add_dependency "rubycritic", "~> 4.0"
|
40
40
|
spec.add_dependency "terminal-table", "~> 1.8.0"
|
41
41
|
|
42
42
|
spec.add_development_dependency "bundler", "~> 2.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skunk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernesto Tagwerker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubycritic
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: terminal-table
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,6 +172,8 @@ executables:
|
|
172
172
|
extensions: []
|
173
173
|
extra_rdoc_files: []
|
174
174
|
files:
|
175
|
+
- ".github/workflows/main.yml"
|
176
|
+
- ".github/workflows/skunk.yml"
|
175
177
|
- ".gitignore"
|
176
178
|
- ".reek.yml"
|
177
179
|
- ".rubocop.yml"
|
@@ -186,6 +188,7 @@ files:
|
|
186
188
|
- Rakefile
|
187
189
|
- bin/console
|
188
190
|
- bin/setup
|
191
|
+
- bin/skunk
|
189
192
|
- exe/skunk
|
190
193
|
- lib/skunk.rb
|
191
194
|
- lib/skunk/cli/application.rb
|
@@ -194,7 +197,9 @@ files:
|
|
194
197
|
- lib/skunk/cli/commands/compare.rb
|
195
198
|
- lib/skunk/cli/commands/default.rb
|
196
199
|
- lib/skunk/cli/commands/help.rb
|
200
|
+
- lib/skunk/cli/commands/output.rb
|
197
201
|
- lib/skunk/cli/commands/status_reporter.rb
|
202
|
+
- lib/skunk/cli/commands/version.rb
|
198
203
|
- lib/skunk/cli/options.rb
|
199
204
|
- lib/skunk/cli/options/argv.rb
|
200
205
|
- lib/skunk/rubycritic/analysed_module.rb
|
@@ -225,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
230
|
- !ruby/object:Gem::Version
|
226
231
|
version: '0'
|
227
232
|
requirements: []
|
228
|
-
rubygems_version: 3.0.
|
233
|
+
rubygems_version: 3.0.3
|
229
234
|
signing_key:
|
230
235
|
specification_version: 4
|
231
236
|
summary: A library to assess code quality vs. code coverage
|