rubycritic 2.7.1 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.todo.reek +137 -0
- data/.travis.yml +18 -9
- data/CHANGELOG.md +9 -0
- data/README.md +45 -8
- data/Rakefile +9 -1
- data/features/rake_task.feature +65 -0
- data/features/step_definitions/rake_task_steps.rb +3 -0
- data/features/support/env.rb +10 -0
- data/lib/rubycritic/core/smell.rb +10 -0
- data/lib/rubycritic/generators/html/templates/smelly_line.html.erb +3 -1
- data/lib/rubycritic/rake_task.rb +70 -0
- data/lib/rubycritic/version.rb +1 -1
- data/rubycritic.gemspec +5 -3
- data/test/lib/rubycritic/core/smell_test.rb +14 -0
- metadata +41 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 98d2664f3cdb47e1c19d036b56085e1f62d7f930
|
|
4
|
+
data.tar.gz: 08a7a743ec2f7891a694bb2e27fb96c905c6ec58
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 993ea1b9d055be63eabcba5a8706fcf1aa8b5f9bd04a6681f1ed79f92fc22503892c6fbeabed3be0e1d80383b91fc25dbccb1ddf51450cdbc82a58e51335bc5d
|
|
7
|
+
data.tar.gz: 721f4a64f158559101ea871cbfa88474993487861e95f623d01b5667a0cca1c4e39869ee26b6fa97ddfaffd97f848a86e2a61dececf4e564a55b8101998778bc
|
data/.todo.reek
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
IrresponsibleModule:
|
|
3
|
+
exclude:
|
|
4
|
+
- Rubycritic::Analyser::Attributes
|
|
5
|
+
- Rubycritic::Analyser::Churn
|
|
6
|
+
- Rubycritic::Analyser::Complexity
|
|
7
|
+
- Parser::AST::Node
|
|
8
|
+
- Rubycritic::AST::EmptyNode
|
|
9
|
+
- Rubycritic::Flay
|
|
10
|
+
- Rubycritic::Flog
|
|
11
|
+
- Rubycritic::MethodsCounter
|
|
12
|
+
- Rubycritic::ModulesLocator
|
|
13
|
+
- Rubycritic::Parser
|
|
14
|
+
- Rubycritic::Reek
|
|
15
|
+
- Rubycritic::Analyser::FlaySmells
|
|
16
|
+
- Rubycritic::Analyser::FlogSmells
|
|
17
|
+
- Rubycritic::Analyser::ReekSmells
|
|
18
|
+
- Rubycritic::AnalysersRunner
|
|
19
|
+
- Rubycritic::Browser
|
|
20
|
+
- Rubycritic::Cli::Application
|
|
21
|
+
- Rubycritic::Cli::Options
|
|
22
|
+
- Rubycritic::Colorize
|
|
23
|
+
- Rubycritic::CommandFactory
|
|
24
|
+
- Rubycritic::Command::Base
|
|
25
|
+
- Rubycritic::Command::Ci
|
|
26
|
+
- Rubycritic::Command::Default
|
|
27
|
+
- Rubycritic::Command::Help
|
|
28
|
+
- Rubycritic::Command::StatusReporter
|
|
29
|
+
- Rubycritic::Command::Version
|
|
30
|
+
- Rubycritic::Config
|
|
31
|
+
- Rubycritic::Configuration
|
|
32
|
+
- Rubycritic::AnalysedModule
|
|
33
|
+
- Rubycritic::AnalysedModulesCollection
|
|
34
|
+
- Rubycritic::Location
|
|
35
|
+
- Rubycritic::Rating
|
|
36
|
+
- Rubycritic::Smell
|
|
37
|
+
- Rubycritic::Generator::ConsoleReport
|
|
38
|
+
- Rubycritic::Generator::Html::Base
|
|
39
|
+
- Rubycritic::Generator::Html::CodeFile
|
|
40
|
+
- Rubycritic::Generator::Html::CodeIndex
|
|
41
|
+
- Rubycritic::Generator::Html::Line
|
|
42
|
+
- Rubycritic::Generator::Html::Overview
|
|
43
|
+
- Rubycritic::Generator::Html::SmellsIndex
|
|
44
|
+
- Rubycritic::Turbulence
|
|
45
|
+
- Rubycritic::ViewHelpers
|
|
46
|
+
- Rubycritic::Generator::HtmlReport
|
|
47
|
+
- Rubycritic::Generator::Json::Simple
|
|
48
|
+
- Rubycritic::Generator::JsonReport
|
|
49
|
+
- Rubycritic::Generator::Text::List
|
|
50
|
+
- Rubycritic::Reporter
|
|
51
|
+
- Rubycritic::RevisionComparator
|
|
52
|
+
- Rubycritic::Serializer
|
|
53
|
+
- Rubycritic::SmellsStatusSetter
|
|
54
|
+
- Rubycritic::SourceControlSystem::Base
|
|
55
|
+
- Rubycritic::SourceControlSystem::Double
|
|
56
|
+
- Rubycritic::SourceControlSystem::Git
|
|
57
|
+
- Rubycritic::SourceControlSystem::Mercurial
|
|
58
|
+
- Rubycritic::SourceLocator
|
|
59
|
+
- Rubycritic
|
|
60
|
+
Attribute:
|
|
61
|
+
exclude:
|
|
62
|
+
- Rubycritic::Analyser::Churn#source_control_system
|
|
63
|
+
- Rubycritic::Configuration#deduplicate_symlinks
|
|
64
|
+
- Rubycritic::Configuration#format
|
|
65
|
+
- Rubycritic::Configuration#mode
|
|
66
|
+
- Rubycritic::Configuration#no_browser
|
|
67
|
+
- Rubycritic::Configuration#open_with
|
|
68
|
+
- Rubycritic::Configuration#source_control_system
|
|
69
|
+
- Rubycritic::Configuration#suppress_ratings
|
|
70
|
+
- Rubycritic::RakeTask#name
|
|
71
|
+
- Rubycritic::RakeTask#options
|
|
72
|
+
- Rubycritic::RakeTask#paths
|
|
73
|
+
- Rubycritic::RakeTask#verbose
|
|
74
|
+
DuplicateMethodCall:
|
|
75
|
+
exclude:
|
|
76
|
+
- Rubycritic::Analyser::Churn#run
|
|
77
|
+
- Parser::AST::Node#module_name
|
|
78
|
+
TooManyStatements:
|
|
79
|
+
exclude:
|
|
80
|
+
- Rubycritic::Analyser::Complexity#run
|
|
81
|
+
- Parser::AST::Node#get_module_names
|
|
82
|
+
- Rubycritic::Analyser::FlaySmells#run
|
|
83
|
+
- Rubycritic::Cli::Application#execute
|
|
84
|
+
- Rubycritic::Cli::Options#parse
|
|
85
|
+
- Rubycritic::CommandFactory#self.command_class
|
|
86
|
+
- Rubycritic::Configuration#set
|
|
87
|
+
- Rubycritic::Generator::Html::CodeFile#render
|
|
88
|
+
- Rubycritic::Reporter#self.report_generator_class
|
|
89
|
+
- Rubycritic::SourceLocator#deduplicate_symlinks
|
|
90
|
+
FeatureEnvy:
|
|
91
|
+
exclude:
|
|
92
|
+
- Parser::AST::Node#module_name
|
|
93
|
+
- Parser::AST::Node#module_name
|
|
94
|
+
- Parser::AST::Node#recursive_children
|
|
95
|
+
- Rubycritic::Analyser::ReekSmells#add_smells_to
|
|
96
|
+
- Rubycritic::Analyser::ReekSmells#create_smell
|
|
97
|
+
- Rubycritic::ViewHelpers#smell_location_path
|
|
98
|
+
- Rubycritic::Generator::HtmlReport#create_directories_and_files
|
|
99
|
+
- Rubycritic::SourceLocator#deduplicate_symlinks
|
|
100
|
+
NestedIterators:
|
|
101
|
+
exclude:
|
|
102
|
+
- Parser::AST::Node#recursive_children
|
|
103
|
+
- Rubycritic::Analyser::FlaySmells#run
|
|
104
|
+
- Rubycritic::Cli::Options#parse
|
|
105
|
+
- Rubycritic::Generator::HtmlReport#create_directories_and_files
|
|
106
|
+
UtilityFunction:
|
|
107
|
+
exclude:
|
|
108
|
+
- Rubycritic::Analyser::FlaySmells#cost
|
|
109
|
+
- Rubycritic::Analyser::FlaySmells#paths_to_analysed_modules
|
|
110
|
+
- Rubycritic::Analyser::FlaySmells#smell_locations
|
|
111
|
+
- Rubycritic::Analyser::FlogSmells#type
|
|
112
|
+
- Rubycritic::Analyser::ReekSmells#smell_locations
|
|
113
|
+
- Rubycritic::Cli::Application#print
|
|
114
|
+
- Rubycritic::AnalysedModulesCollection#limited_cost_for
|
|
115
|
+
- Rubycritic::Generator::Html::SmellsIndex#analysed_module_names
|
|
116
|
+
- Rubycritic::Generator::HtmlReport#copy_assets_to_report_directory
|
|
117
|
+
- Rubycritic::SourceControlSystem::Git#date_of_last_commit
|
|
118
|
+
- Rubycritic::SourceControlSystem::Git#head_reference
|
|
119
|
+
- Rubycritic::SourceControlSystem::Git#revisions_count
|
|
120
|
+
- Rubycritic::SourceControlSystem::Git#stashes_count
|
|
121
|
+
- Rubycritic::SourceControlSystem::Mercurial#date_of_last_commit
|
|
122
|
+
- Rubycritic::SourceControlSystem::Mercurial#revisions_count
|
|
123
|
+
TooManyInstanceVariables:
|
|
124
|
+
exclude:
|
|
125
|
+
- Rubycritic::Cli::Options
|
|
126
|
+
ControlParameter:
|
|
127
|
+
exclude:
|
|
128
|
+
- Rubycritic::CommandFactory#self.command_class
|
|
129
|
+
UncommunicativeParameterName:
|
|
130
|
+
exclude:
|
|
131
|
+
- Rubycritic::AnalysedModule#to_json
|
|
132
|
+
- Rubycritic::Location#to_json
|
|
133
|
+
- Rubycritic::Rating#to_json
|
|
134
|
+
- Rubycritic::Smell#to_json
|
|
135
|
+
ClassVariable:
|
|
136
|
+
exclude:
|
|
137
|
+
- Rubycritic::SourceControlSystem::Base
|
data/.travis.yml
CHANGED
|
@@ -2,16 +2,25 @@ sudo: false
|
|
|
2
2
|
language: ruby
|
|
3
3
|
|
|
4
4
|
rvm:
|
|
5
|
-
- 2.0
|
|
6
|
-
- 2.1
|
|
7
|
-
- 2.2
|
|
8
|
-
-
|
|
9
|
-
-
|
|
5
|
+
- 2.0.0-p648
|
|
6
|
+
- 2.1.8
|
|
7
|
+
- 2.2.4
|
|
8
|
+
- 2.3.0
|
|
9
|
+
- ruby-head
|
|
10
|
+
- jruby-9.0.5.0
|
|
11
|
+
- rbx-3
|
|
12
|
+
|
|
13
|
+
env:
|
|
14
|
+
# this doesn't do anything for MRI or RBX, but it doesn't hurt them either
|
|
15
|
+
# for JRuby, it enables us to get more accurate coverage data
|
|
16
|
+
- JRUBY_OPTS="--debug"
|
|
17
|
+
|
|
10
18
|
matrix:
|
|
11
19
|
allow_failures:
|
|
12
|
-
- rvm:
|
|
13
|
-
- rvm: jruby
|
|
20
|
+
- rvm: ruby-head
|
|
21
|
+
- rvm: jruby-9.0.5.0
|
|
22
|
+
- rvm: rbx-3
|
|
14
23
|
fast_finish: true
|
|
15
24
|
|
|
16
|
-
before_install:
|
|
17
|
-
script:
|
|
25
|
+
before_install: gem update bundler
|
|
26
|
+
script: bundle exec rake
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
# 2.8.0 / 2016-02-29
|
|
2
|
+
|
|
3
|
+
* [FEATURE] Add link to Reek's code smells documentation (by danielmbarlow)
|
|
4
|
+
* [FEATURE] Make RubyCritic usable as Rake Task (by Timo Rößner)
|
|
5
|
+
* [CHANGE] Bump Rubocop to 0.37.2 (by Tomasz Pajor)
|
|
6
|
+
* [CHANGE] Bump Flay to 2.7.0 (by Tomasz Pajor)
|
|
7
|
+
* [CHANGE] Bump Reek to 3.11 (by Tomasz Pajor)
|
|
8
|
+
* [CHANGE] Add explicit runtime dependency on ruby_parser ('~> 3.8') (by Nuno Silva)
|
|
9
|
+
|
|
1
10
|
# 2.7.1 / 2016-02-09
|
|
2
11
|
|
|
3
12
|
* [CHANGE] Bump Reek to 3.10.1 (by Tomasz Pajor)
|
data/README.md
CHANGED
|
@@ -104,10 +104,11 @@ $ rubycritic --help
|
|
|
104
104
|
Analyzer Configuration
|
|
105
105
|
-------------------------
|
|
106
106
|
|
|
107
|
-
* `Reek
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
* [`Reek`](https://github.com/troessner/reek): `RubyCritic` utilizes `Reek`'s default [configuration loading mechanism](https://github.com/troessner/reek#configuration-file).
|
|
108
|
+
This means that if you have an existing `Reek` configuration file, you can just put this into your
|
|
109
|
+
project root and `RubyCritic` will respect this configuration.
|
|
110
|
+
* [`flay`](https://github.com/seattlerb/flay): We use `flay`'s default configuration.
|
|
111
|
+
* [`flog`](https://github.com/seattlerb/flog): We use `flog`'s default configuration with a couple of [smaller tweaks](https://github.com/whitesmith/rubycritic/blob/master/lib/rubycritic/analysers/helpers/flog.rb#L5).
|
|
111
112
|
|
|
112
113
|
Alternative Usage Methods
|
|
113
114
|
-------------------------
|
|
@@ -116,6 +117,45 @@ If you're fond of Guard you might like [guard-rubycritic][4]. It automatically a
|
|
|
116
117
|
|
|
117
118
|
For continuous integration, you can give [Jenkins CI][5] a spin. With it, you can [easily build your own (poor-man's) Code Climate][6]!
|
|
118
119
|
|
|
120
|
+
Rake Task
|
|
121
|
+
---------
|
|
122
|
+
|
|
123
|
+
You can use RubyCritic as Rake command in its most simple form like this:
|
|
124
|
+
|
|
125
|
+
```ruby
|
|
126
|
+
require "rubycritic/rake_task"
|
|
127
|
+
|
|
128
|
+
Rubycritic::RakeTask.new
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
A more sophisticated Rake task that would make use of all available configuration options could look like this:
|
|
132
|
+
|
|
133
|
+
```ruby
|
|
134
|
+
RubyCritic::RakeTask.new do |task|
|
|
135
|
+
# Name of RubyCritic task. Defaults to :rubycritic.
|
|
136
|
+
task.name = 'something_special'
|
|
137
|
+
|
|
138
|
+
# Glob pattern to match source files. Defaults to FileList['.'].
|
|
139
|
+
task.paths = FileList['vendor/**/*.rb']
|
|
140
|
+
|
|
141
|
+
# You can pass all the options here in that are shown by "rubycritic -h" except for
|
|
142
|
+
# "-p / --path" since that is set separately. Defaults to ''.
|
|
143
|
+
task.options = '--mode-ci --format json'
|
|
144
|
+
|
|
145
|
+
# Defaults to false
|
|
146
|
+
task.verbose = true
|
|
147
|
+
end
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
RubyCritic will try to open the generated report with a browser by default. If you don't want this
|
|
151
|
+
you can prevent this behaviour by setting the options correspondingly:
|
|
152
|
+
|
|
153
|
+
```ruby
|
|
154
|
+
RubyCritic::RakeTask.new do |task|
|
|
155
|
+
task.options = '--no-browser'
|
|
156
|
+
end
|
|
157
|
+
```
|
|
158
|
+
|
|
119
159
|
Compatibility
|
|
120
160
|
---------------
|
|
121
161
|
|
|
@@ -124,10 +164,7 @@ RubyCritic is supporting:
|
|
|
124
164
|
* 2.0
|
|
125
165
|
* 2.1
|
|
126
166
|
* 2.2
|
|
127
|
-
|
|
128
|
-
Note that we do not support Ruby 1.9 anymore.
|
|
129
|
-
|
|
130
|
-
If you're still on ruby 1.9 you'll have to use the last version of RubyCritic that supports it, which would be [1.4.0](https://github.com/whitesmith/rubycritic/tree/v1.4.0).
|
|
167
|
+
* 2.3
|
|
131
168
|
|
|
132
169
|
Improving RubyCritic
|
|
133
170
|
--------------------
|
data/Rakefile
CHANGED
|
@@ -2,6 +2,8 @@ require 'bundler/gem_tasks'
|
|
|
2
2
|
require 'rake/testtask'
|
|
3
3
|
require 'rubocop/rake_task'
|
|
4
4
|
require 'cucumber/rake/task'
|
|
5
|
+
require 'reek/rake/task'
|
|
6
|
+
require 'rubycritic/rake_task'
|
|
5
7
|
|
|
6
8
|
Rake::TestTask.new do |task|
|
|
7
9
|
task.libs.push 'lib'
|
|
@@ -15,4 +17,10 @@ end
|
|
|
15
17
|
|
|
16
18
|
RuboCop::RakeTask.new
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
Reek::Rake::Task.new
|
|
21
|
+
|
|
22
|
+
Rubycritic::RakeTask.new do |task|
|
|
23
|
+
task.paths = FileList['lib/**/*.rb']
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
task default: [:test, :features, :reek, :rubocop]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Feature: Rubycritic can be run via Rake task
|
|
2
|
+
In order to allow for a better CI usage
|
|
3
|
+
As a developer
|
|
4
|
+
I want to use RubyCritic as a Rake task
|
|
5
|
+
|
|
6
|
+
Scenario: ‘paths' attribute is respected
|
|
7
|
+
Given the smelly file 'smelly.rb'
|
|
8
|
+
When I run rake rubycritic with:
|
|
9
|
+
"""
|
|
10
|
+
Rubycritic::RakeTask.new do |t|
|
|
11
|
+
t.paths = FileList['smelly.*']
|
|
12
|
+
t.options = '--no-browser -f console'
|
|
13
|
+
end
|
|
14
|
+
"""
|
|
15
|
+
Then the output should contain:
|
|
16
|
+
"""
|
|
17
|
+
(HighComplexity) AllTheMethods#method_missing has a flog score of 27
|
|
18
|
+
"""
|
|
19
|
+
And the exit status indicates a success
|
|
20
|
+
|
|
21
|
+
Scenario: 'name' option changes the task name
|
|
22
|
+
Given the smelly file 'smelly.rb'
|
|
23
|
+
When I run rake silky with:
|
|
24
|
+
"""
|
|
25
|
+
Rubycritic::RakeTask.new('silky') do |t|
|
|
26
|
+
t.paths = FileList['smelly.*']
|
|
27
|
+
t.verbose = true
|
|
28
|
+
t.options = '--no-browser'
|
|
29
|
+
end
|
|
30
|
+
"""
|
|
31
|
+
Then the output should contain:
|
|
32
|
+
"""
|
|
33
|
+
Running `silky` rake command
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
Scenario: 'verbose' prints details about the execution
|
|
37
|
+
Given the smelly file 'smelly.rb'
|
|
38
|
+
When I run rake rubycritic with:
|
|
39
|
+
"""
|
|
40
|
+
Rubycritic::RakeTask.new do |t|
|
|
41
|
+
t.paths = FileList['smelly.*']
|
|
42
|
+
t.verbose = true
|
|
43
|
+
t.options = '--no-browser'
|
|
44
|
+
end
|
|
45
|
+
"""
|
|
46
|
+
Then the output should contain:
|
|
47
|
+
"""
|
|
48
|
+
!!! Running `rubycritic` rake command
|
|
49
|
+
!!! Inspecting smelly.rb with options --no-browser
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
Scenario: respect --minimum-score
|
|
53
|
+
Given the smelly file 'smelly.rb'
|
|
54
|
+
When I run rake rubycritic with:
|
|
55
|
+
"""
|
|
56
|
+
Rubycritic::RakeTask.new do |t|
|
|
57
|
+
t.paths = FileList['smelly.*']
|
|
58
|
+
t.verbose = true
|
|
59
|
+
t.options = '--no-browser -f console --minimum-score 95'
|
|
60
|
+
end
|
|
61
|
+
"""
|
|
62
|
+
Then the output should contain:
|
|
63
|
+
"""
|
|
64
|
+
Score (93.75) is below the minimum 95
|
|
65
|
+
"""
|
data/features/support/env.rb
CHANGED
|
@@ -18,6 +18,16 @@ class RubycriticWorld
|
|
|
18
18
|
def rubycritic(args)
|
|
19
19
|
run_simple("rubycritic #{args} --no-browser", false)
|
|
20
20
|
end
|
|
21
|
+
|
|
22
|
+
def rake(name, task_def)
|
|
23
|
+
header = <<-EOS.strip_heredoc
|
|
24
|
+
require 'rubycritic'
|
|
25
|
+
require 'rubycritic/rake_task'
|
|
26
|
+
|
|
27
|
+
EOS
|
|
28
|
+
write_file 'Rakefile', header + task_def
|
|
29
|
+
run_simple("rake #{name}", false)
|
|
30
|
+
end
|
|
21
31
|
end
|
|
22
32
|
|
|
23
33
|
World do
|
|
@@ -46,6 +46,10 @@ module Rubycritic
|
|
|
46
46
|
to_h.to_json(*a)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
+
def doc_url
|
|
50
|
+
"https://github.com/troessner/reek/blob/master/docs/#{dasherized_type}.md"
|
|
51
|
+
end
|
|
52
|
+
|
|
49
53
|
def hash
|
|
50
54
|
state.hash
|
|
51
55
|
end
|
|
@@ -55,5 +59,11 @@ module Rubycritic
|
|
|
55
59
|
def state
|
|
56
60
|
[@context, @message, @score, @type]
|
|
57
61
|
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
def dasherized_type
|
|
66
|
+
type.gsub(/(?<!^)([A-Z])/, '-\1')
|
|
67
|
+
end
|
|
58
68
|
end
|
|
59
69
|
end
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
<ul class="nocode smells js-smells">
|
|
4
4
|
<% @smells.each do |smell| %>
|
|
5
5
|
<li class="smell <%= smell.status %>">
|
|
6
|
-
<span class="description"
|
|
6
|
+
<span class="description">
|
|
7
|
+
(<a href="<%= smell.doc_url %>" target="_blank"><%= smell.type %></a>)
|
|
8
|
+
<%= "#{smell.context} #{smell.message}" %>
|
|
7
9
|
<% if smell.multiple_locations? %>
|
|
8
10
|
<% smell.locations.each_with_index do |location, index| %>
|
|
9
11
|
<a href="<%= smell_location_path(location) %>" class="js-smell-location"><%= index %></a>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rake/tasklib'
|
|
3
|
+
require 'English'
|
|
4
|
+
require 'rubycritic/cli/application'
|
|
5
|
+
|
|
6
|
+
module Rubycritic
|
|
7
|
+
#
|
|
8
|
+
# A rake task that runs RubyCritic on a set of source files.
|
|
9
|
+
#
|
|
10
|
+
# This will create a task that can be run with:
|
|
11
|
+
#
|
|
12
|
+
# rake rubycritic
|
|
13
|
+
#
|
|
14
|
+
# Example:
|
|
15
|
+
#
|
|
16
|
+
# require 'rubycritic/rake_task'
|
|
17
|
+
#
|
|
18
|
+
# RubyCritic::RakeTask.new do |task|
|
|
19
|
+
# task.paths = FileList['lib/**/*.rb', 'spec/**/*.rb']
|
|
20
|
+
# end
|
|
21
|
+
#
|
|
22
|
+
# :reek:TooManyStatements: { max_statements: 6 }
|
|
23
|
+
class RakeTask < ::Rake::TaskLib
|
|
24
|
+
# Name of RubyCritic task. Defaults to :rubycritic.
|
|
25
|
+
attr_writer :name
|
|
26
|
+
|
|
27
|
+
# Glob pattern to match source files. Defaults to FileList['.'].
|
|
28
|
+
attr_writer :paths
|
|
29
|
+
|
|
30
|
+
# Use verbose output. If this is set to true, the task will print
|
|
31
|
+
# the rubycritic command to stdout. Defaults to false.
|
|
32
|
+
attr_writer :verbose
|
|
33
|
+
|
|
34
|
+
# You can pass all the options here in that are shown by "rubycritic -h" except for
|
|
35
|
+
# "-p / --path" since that is set separately. Defaults to ''.
|
|
36
|
+
attr_writer :options
|
|
37
|
+
|
|
38
|
+
def initialize(name = :rubycritic)
|
|
39
|
+
@name = name
|
|
40
|
+
@paths = FileList['.']
|
|
41
|
+
@options = ''
|
|
42
|
+
@verbose = false
|
|
43
|
+
|
|
44
|
+
yield self if block_given?
|
|
45
|
+
define_task
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
attr_reader :name, :paths, :verbose, :options
|
|
51
|
+
|
|
52
|
+
def define_task
|
|
53
|
+
desc 'Run RubyCritic'
|
|
54
|
+
task(name) { run_task }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def run_task
|
|
58
|
+
if verbose
|
|
59
|
+
puts "\n\n!!! Running `#{name}` rake command\n"
|
|
60
|
+
puts "!!! Inspecting #{paths} #{options.empty? ? '' : "with options #{options}"}\n\n"
|
|
61
|
+
end
|
|
62
|
+
application = Rubycritic::Cli::Application.new(options_as_arguments + paths)
|
|
63
|
+
application.execute
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def options_as_arguments
|
|
67
|
+
options.split(/\s+/)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
data/lib/rubycritic/version.rb
CHANGED
data/rubycritic.gemspec
CHANGED
|
@@ -21,10 +21,11 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.require_path = 'lib'
|
|
22
22
|
|
|
23
23
|
spec.add_runtime_dependency 'virtus', '~> 1.0'
|
|
24
|
-
spec.add_runtime_dependency 'flay', '2.
|
|
24
|
+
spec.add_runtime_dependency 'flay', '2.7.0'
|
|
25
25
|
spec.add_runtime_dependency 'flog', '4.3.2'
|
|
26
|
-
spec.add_runtime_dependency 'reek', '3.
|
|
26
|
+
spec.add_runtime_dependency 'reek', '3.11'
|
|
27
27
|
spec.add_runtime_dependency 'parser', '~> 2.3'
|
|
28
|
+
spec.add_runtime_dependency 'ruby_parser', '~> 3.8'
|
|
28
29
|
spec.add_runtime_dependency 'colorize'
|
|
29
30
|
spec.add_runtime_dependency 'launchy', '2.4.3'
|
|
30
31
|
|
|
@@ -34,5 +35,6 @@ Gem::Specification.new do |spec|
|
|
|
34
35
|
spec.add_development_dependency 'rake'
|
|
35
36
|
spec.add_development_dependency 'minitest', '~> 5.3'
|
|
36
37
|
spec.add_development_dependency 'mocha', '~> 1.1'
|
|
37
|
-
spec.add_development_dependency 'rubocop', '0.37.
|
|
38
|
+
spec.add_development_dependency 'rubocop', '0.37.2'
|
|
39
|
+
spec.add_development_dependency 'pry-byebug'
|
|
38
40
|
end
|
|
@@ -69,4 +69,18 @@ describe Rubycritic::Smell do
|
|
|
69
69
|
smell1.must_equal smell2
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
|
+
|
|
73
|
+
describe '#doc_url' do
|
|
74
|
+
it 'handles one word type names' do
|
|
75
|
+
smell = Rubycritic::Smell.new(type: 'Complexity')
|
|
76
|
+
|
|
77
|
+
smell.doc_url.must_equal('https://github.com/troessner/reek/blob/master/docs/Complexity.md')
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'handles multiple word type names' do
|
|
81
|
+
smell = Rubycritic::Smell.new(type: 'TooManyStatements')
|
|
82
|
+
|
|
83
|
+
smell.doc_url.must_equal('https://github.com/troessner/reek/blob/master/docs/Too-Many-Statements.md')
|
|
84
|
+
end
|
|
85
|
+
end
|
|
72
86
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubycritic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Guilherme Simoes
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: virtus
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - '='
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 2.
|
|
33
|
+
version: 2.7.0
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - '='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 2.
|
|
40
|
+
version: 2.7.0
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: flog
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - '='
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 3.
|
|
61
|
+
version: '3.11'
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - '='
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 3.
|
|
68
|
+
version: '3.11'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: parser
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -80,6 +80,20 @@ dependencies:
|
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '2.3'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: ruby_parser
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '3.8'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '3.8'
|
|
83
97
|
- !ruby/object:Gem::Dependency
|
|
84
98
|
name: colorize
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -198,14 +212,28 @@ dependencies:
|
|
|
198
212
|
requirements:
|
|
199
213
|
- - '='
|
|
200
214
|
- !ruby/object:Gem::Version
|
|
201
|
-
version: 0.37.
|
|
215
|
+
version: 0.37.2
|
|
202
216
|
type: :development
|
|
203
217
|
prerelease: false
|
|
204
218
|
version_requirements: !ruby/object:Gem::Requirement
|
|
205
219
|
requirements:
|
|
206
220
|
- - '='
|
|
207
221
|
- !ruby/object:Gem::Version
|
|
208
|
-
version: 0.37.
|
|
222
|
+
version: 0.37.2
|
|
223
|
+
- !ruby/object:Gem::Dependency
|
|
224
|
+
name: pry-byebug
|
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
|
226
|
+
requirements:
|
|
227
|
+
- - ">="
|
|
228
|
+
- !ruby/object:Gem::Version
|
|
229
|
+
version: '0'
|
|
230
|
+
type: :development
|
|
231
|
+
prerelease: false
|
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
233
|
+
requirements:
|
|
234
|
+
- - ">="
|
|
235
|
+
- !ruby/object:Gem::Version
|
|
236
|
+
version: '0'
|
|
209
237
|
description: RubyCritic is a tool that wraps around various static analysis gems to
|
|
210
238
|
provide a quality report of your Ruby code.
|
|
211
239
|
email:
|
|
@@ -218,6 +246,7 @@ files:
|
|
|
218
246
|
- ".gitignore"
|
|
219
247
|
- ".rubocop.yml"
|
|
220
248
|
- ".rubocop_todo.yml"
|
|
249
|
+
- ".todo.reek"
|
|
221
250
|
- ".travis.yml"
|
|
222
251
|
- CHANGELOG.md
|
|
223
252
|
- CONTRIBUTING.md
|
|
@@ -228,6 +257,8 @@ files:
|
|
|
228
257
|
- bin/rubycritic
|
|
229
258
|
- features/command_line_interface/minimum_score.feature
|
|
230
259
|
- features/command_line_interface/options.feature
|
|
260
|
+
- features/rake_task.feature
|
|
261
|
+
- features/step_definitions/rake_task_steps.rb
|
|
231
262
|
- features/step_definitions/rubycritic_steps.rb
|
|
232
263
|
- features/step_definitions/sample_file_steps.rb
|
|
233
264
|
- features/support/env.rb
|
|
@@ -294,6 +325,7 @@ files:
|
|
|
294
325
|
- lib/rubycritic/generators/json_report.rb
|
|
295
326
|
- lib/rubycritic/generators/text/list.rb
|
|
296
327
|
- lib/rubycritic/generators/text/templates/list.erb
|
|
328
|
+
- lib/rubycritic/rake_task.rb
|
|
297
329
|
- lib/rubycritic/reporter.rb
|
|
298
330
|
- lib/rubycritic/revision_comparator.rb
|
|
299
331
|
- lib/rubycritic/serializer.rb
|
|
@@ -371,7 +403,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
371
403
|
version: '0'
|
|
372
404
|
requirements: []
|
|
373
405
|
rubyforge_project:
|
|
374
|
-
rubygems_version: 2.4.
|
|
406
|
+
rubygems_version: 2.4.8
|
|
375
407
|
signing_key:
|
|
376
408
|
specification_version: 4
|
|
377
409
|
summary: RubyCritic is a Ruby code quality reporter
|