rubycritic 0.0.5 → 0.0.16
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/.travis.yml +10 -0
- data/README.md +72 -11
- data/bin/rubycritic +2 -0
- data/lib/rubycritic/adapters/complexity/flog.rb +22 -0
- data/lib/rubycritic/adapters/smell/flay.rb +68 -0
- data/lib/rubycritic/adapters/smell/flog.rb +62 -0
- data/lib/rubycritic/adapters/smell/reek.rb +44 -0
- data/lib/rubycritic/analysers/churn.rb +19 -0
- data/lib/rubycritic/analysers/config.reek +8 -0
- data/lib/rubycritic/analysers/flay.rb +15 -0
- data/lib/rubycritic/analysers/flog.rb +1 -2
- data/lib/rubycritic/analysers/stats.rb +31 -0
- data/lib/rubycritic/analysers_runner.rb +15 -14
- data/lib/rubycritic/cli.rb +35 -14
- data/lib/rubycritic/configuration.rb +24 -0
- data/lib/rubycritic/core/analysed_file.rb +50 -0
- data/lib/rubycritic/{location.rb → core/location.rb} +6 -2
- data/lib/rubycritic/core/rating.rb +22 -0
- data/lib/rubycritic/{smell.rb → core/smell.rb} +5 -12
- data/lib/rubycritic/files_initializer.rb +15 -0
- data/lib/rubycritic/orchestrator.rb +23 -0
- data/lib/rubycritic/report_generators/assets/javascripts/application.js +87 -8
- data/lib/rubycritic/report_generators/assets/javascripts/highcharts.src-4.0.1.js +17672 -0
- data/lib/rubycritic/report_generators/assets/javascripts/jquery.floatThead-v1.2.7.js +754 -0
- data/lib/rubycritic/report_generators/assets/javascripts/jquery.scrollTo-1.4.11.js +186 -0
- data/lib/rubycritic/report_generators/assets/javascripts/jquery.tablesorter-2.0.js +1031 -0
- data/lib/rubycritic/report_generators/assets/javascripts/jquery.timeago-v1.4.1.js +214 -0
- data/lib/rubycritic/report_generators/assets/stylesheets/application.css +204 -1
- data/lib/rubycritic/report_generators/assets/stylesheets/prettify.custom_theme.css +1 -4
- data/lib/rubycritic/report_generators/base.rb +49 -0
- data/lib/rubycritic/report_generators/code_file.rb +38 -0
- data/lib/rubycritic/report_generators/code_index.rb +24 -0
- data/lib/rubycritic/report_generators/current_code_file.rb +17 -0
- data/lib/rubycritic/report_generators/line.rb +31 -0
- data/lib/rubycritic/report_generators/overview.rb +25 -0
- data/lib/rubycritic/report_generators/smells_index.rb +24 -0
- data/lib/rubycritic/report_generators/templates/code_file.html.erb +36 -0
- data/lib/rubycritic/report_generators/templates/code_index.html.erb +26 -0
- data/lib/rubycritic/report_generators/templates/layouts/application.html.erb +27 -16
- data/lib/rubycritic/report_generators/templates/overview.html.erb +5 -0
- data/lib/rubycritic/report_generators/templates/smells_index.html.erb +20 -0
- data/lib/rubycritic/report_generators/view_helpers.rb +28 -9
- data/lib/rubycritic/reporters/base.rb +24 -0
- data/lib/rubycritic/reporters/main.rb +52 -0
- data/lib/rubycritic/reporters/mini.rb +30 -0
- data/lib/rubycritic/revision_comparator.rb +21 -28
- data/lib/rubycritic/serializer.rb +32 -0
- data/lib/rubycritic/smells_status_setter.rb +7 -16
- data/lib/rubycritic/source_control_systems/base.rb +60 -0
- data/lib/rubycritic/source_control_systems/double.rb +19 -0
- data/lib/rubycritic/source_control_systems/git.rb +47 -37
- data/lib/rubycritic/source_locator.rb +8 -12
- data/lib/rubycritic/turbulence.rb +17 -0
- data/lib/rubycritic/version.rb +1 -1
- data/lib/rubycritic.rb +2 -27
- data/rubycritic.gemspec +3 -0
- data/test/lib/rubycritic/adapters/complexity/flog_test.rb +18 -0
- data/test/lib/rubycritic/adapters/smell/flay_test.rb +34 -0
- data/test/lib/rubycritic/adapters/smell/flog_test.rb +26 -0
- data/test/lib/rubycritic/adapters/smell/reek_test.rb +35 -0
- data/test/lib/rubycritic/analysers/churn_test.rb +38 -0
- data/test/lib/rubycritic/configuration_test.rb +17 -0
- data/test/lib/rubycritic/core/analysed_file_test.rb +71 -0
- data/test/lib/rubycritic/{location_test.rb → core/location_test.rb} +8 -4
- data/test/lib/rubycritic/core/smell_test.rb +73 -0
- data/test/lib/rubycritic/{smells_array_test.rb → core/smells_array_test.rb} +1 -1
- data/test/lib/rubycritic/smells_status_setter_test.rb +5 -5
- data/test/lib/rubycritic/source_control_systems/source_control_system_test.rb +5 -11
- data/test/lib/rubycritic/source_locator_test.rb +26 -17
- data/test/lib/rubycritic/turbulence_test.rb +17 -0
- data/test/lib/rubycritic/version_test.rb +1 -0
- data/test/samples/flay/smelly.rb +17 -0
- data/test/samples/flog/complex.rb +11 -0
- data/test/samples/flog/smelly.rb +7 -2
- data/test/samples/reek/not_smelly.rb +31 -3
- data/test/test_helper.rb +1 -0
- metadata +97 -32
- data/SPEC.md +0 -58
- data/lib/rubycritic/report_generators/base_generator.rb +0 -42
- data/lib/rubycritic/report_generators/file_generator.rb +0 -42
- data/lib/rubycritic/report_generators/index_generator.rb +0 -28
- data/lib/rubycritic/report_generators/line_generator.rb +0 -27
- data/lib/rubycritic/report_generators/reporter.rb +0 -45
- data/lib/rubycritic/report_generators/templates/file.html.erb +0 -3
- data/lib/rubycritic/report_generators/templates/index.html.erb +0 -14
- data/lib/rubycritic/smell_adapters/flog.rb +0 -41
- data/lib/rubycritic/smell_adapters/reek.rb +0 -35
- data/lib/rubycritic/smells_aggregator.rb +0 -29
- data/lib/rubycritic/smelly_pathnames_serializer.rb +0 -34
- data/lib/rubycritic/source_control_systems/source_control_system.rb +0 -42
- data/test/lib/rubycritic/metric_adapters/flog_adapter_test.rb +0 -25
- data/test/lib/rubycritic/metric_adapters/reek_adapter_test.rb +0 -34
- data/test/lib/rubycritic/smell_test.rb +0 -71
- data/test/lib/rubycritic/smells_aggregator_test.rb +0 -47
- /data/lib/rubycritic/report_generators/assets/javascripts/{prettify.js → prettify-4-Mar-2013.js} +0 -0
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: 0.0.
|
|
4
|
+
version: 0.0.16
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Guilherme Simoes
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: virtus
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: flay
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 2.4.0
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 2.4.0
|
|
27
41
|
- !ruby/object:Gem::Dependency
|
|
28
42
|
name: flog
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,6 +66,20 @@ dependencies:
|
|
|
52
66
|
- - '='
|
|
53
67
|
- !ruby/object:Gem::Version
|
|
54
68
|
version: 1.3.6
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: code_analyzer
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - '='
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 0.4.5
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - '='
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 0.4.5
|
|
55
83
|
- !ruby/object:Gem::Dependency
|
|
56
84
|
name: bundler
|
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -118,58 +146,88 @@ extensions: []
|
|
|
118
146
|
extra_rdoc_files: []
|
|
119
147
|
files:
|
|
120
148
|
- ".gitignore"
|
|
149
|
+
- ".travis.yml"
|
|
121
150
|
- CONTRIBUTING.md
|
|
122
151
|
- Gemfile
|
|
123
152
|
- LICENSE.txt
|
|
124
153
|
- README.md
|
|
125
154
|
- Rakefile
|
|
126
|
-
- SPEC.md
|
|
127
155
|
- bin/rubycritic
|
|
128
156
|
- lib/rubycritic.rb
|
|
157
|
+
- lib/rubycritic/adapters/complexity/flog.rb
|
|
158
|
+
- lib/rubycritic/adapters/smell/flay.rb
|
|
159
|
+
- lib/rubycritic/adapters/smell/flog.rb
|
|
160
|
+
- lib/rubycritic/adapters/smell/reek.rb
|
|
161
|
+
- lib/rubycritic/analysers/churn.rb
|
|
129
162
|
- lib/rubycritic/analysers/config.reek
|
|
163
|
+
- lib/rubycritic/analysers/flay.rb
|
|
130
164
|
- lib/rubycritic/analysers/flog.rb
|
|
131
165
|
- lib/rubycritic/analysers/reek.rb
|
|
166
|
+
- lib/rubycritic/analysers/stats.rb
|
|
132
167
|
- lib/rubycritic/analysers_runner.rb
|
|
133
168
|
- lib/rubycritic/cli.rb
|
|
134
|
-
- lib/rubycritic/
|
|
169
|
+
- lib/rubycritic/configuration.rb
|
|
170
|
+
- lib/rubycritic/core/analysed_file.rb
|
|
171
|
+
- lib/rubycritic/core/location.rb
|
|
172
|
+
- lib/rubycritic/core/rating.rb
|
|
173
|
+
- lib/rubycritic/core/smell.rb
|
|
174
|
+
- lib/rubycritic/files_initializer.rb
|
|
175
|
+
- lib/rubycritic/orchestrator.rb
|
|
135
176
|
- lib/rubycritic/report_generators/assets/javascripts/application.js
|
|
177
|
+
- lib/rubycritic/report_generators/assets/javascripts/highcharts.src-4.0.1.js
|
|
136
178
|
- lib/rubycritic/report_generators/assets/javascripts/jquery-2.1.0.js
|
|
137
|
-
- lib/rubycritic/report_generators/assets/javascripts/
|
|
179
|
+
- lib/rubycritic/report_generators/assets/javascripts/jquery.floatThead-v1.2.7.js
|
|
180
|
+
- lib/rubycritic/report_generators/assets/javascripts/jquery.scrollTo-1.4.11.js
|
|
181
|
+
- lib/rubycritic/report_generators/assets/javascripts/jquery.tablesorter-2.0.js
|
|
182
|
+
- lib/rubycritic/report_generators/assets/javascripts/jquery.timeago-v1.4.1.js
|
|
183
|
+
- lib/rubycritic/report_generators/assets/javascripts/prettify-4-Mar-2013.js
|
|
138
184
|
- lib/rubycritic/report_generators/assets/stylesheets/application.css
|
|
139
185
|
- lib/rubycritic/report_generators/assets/stylesheets/prettify.custom_theme.css
|
|
140
|
-
- lib/rubycritic/report_generators/
|
|
141
|
-
- lib/rubycritic/report_generators/
|
|
142
|
-
- lib/rubycritic/report_generators/
|
|
143
|
-
- lib/rubycritic/report_generators/
|
|
144
|
-
- lib/rubycritic/report_generators/
|
|
145
|
-
- lib/rubycritic/report_generators/
|
|
146
|
-
- lib/rubycritic/report_generators/
|
|
186
|
+
- lib/rubycritic/report_generators/base.rb
|
|
187
|
+
- lib/rubycritic/report_generators/code_file.rb
|
|
188
|
+
- lib/rubycritic/report_generators/code_index.rb
|
|
189
|
+
- lib/rubycritic/report_generators/current_code_file.rb
|
|
190
|
+
- lib/rubycritic/report_generators/line.rb
|
|
191
|
+
- lib/rubycritic/report_generators/overview.rb
|
|
192
|
+
- lib/rubycritic/report_generators/smells_index.rb
|
|
193
|
+
- lib/rubycritic/report_generators/templates/code_file.html.erb
|
|
194
|
+
- lib/rubycritic/report_generators/templates/code_index.html.erb
|
|
147
195
|
- lib/rubycritic/report_generators/templates/layouts/application.html.erb
|
|
148
196
|
- lib/rubycritic/report_generators/templates/line.html.erb
|
|
197
|
+
- lib/rubycritic/report_generators/templates/overview.html.erb
|
|
198
|
+
- lib/rubycritic/report_generators/templates/smells_index.html.erb
|
|
149
199
|
- lib/rubycritic/report_generators/templates/smelly_line.html.erb
|
|
150
200
|
- lib/rubycritic/report_generators/view_helpers.rb
|
|
201
|
+
- lib/rubycritic/reporters/base.rb
|
|
202
|
+
- lib/rubycritic/reporters/main.rb
|
|
203
|
+
- lib/rubycritic/reporters/mini.rb
|
|
151
204
|
- lib/rubycritic/revision_comparator.rb
|
|
152
|
-
- lib/rubycritic/
|
|
153
|
-
- lib/rubycritic/smell_adapters/flog.rb
|
|
154
|
-
- lib/rubycritic/smell_adapters/reek.rb
|
|
155
|
-
- lib/rubycritic/smells_aggregator.rb
|
|
205
|
+
- lib/rubycritic/serializer.rb
|
|
156
206
|
- lib/rubycritic/smells_status_setter.rb
|
|
157
|
-
- lib/rubycritic/
|
|
207
|
+
- lib/rubycritic/source_control_systems/base.rb
|
|
208
|
+
- lib/rubycritic/source_control_systems/double.rb
|
|
158
209
|
- lib/rubycritic/source_control_systems/git.rb
|
|
159
|
-
- lib/rubycritic/source_control_systems/source_control_system.rb
|
|
160
210
|
- lib/rubycritic/source_locator.rb
|
|
211
|
+
- lib/rubycritic/turbulence.rb
|
|
161
212
|
- lib/rubycritic/version.rb
|
|
162
213
|
- rubycritic.gemspec
|
|
163
|
-
- test/lib/rubycritic/
|
|
164
|
-
- test/lib/rubycritic/
|
|
165
|
-
- test/lib/rubycritic/
|
|
166
|
-
- test/lib/rubycritic/
|
|
167
|
-
- test/lib/rubycritic/
|
|
168
|
-
- test/lib/rubycritic/
|
|
214
|
+
- test/lib/rubycritic/adapters/complexity/flog_test.rb
|
|
215
|
+
- test/lib/rubycritic/adapters/smell/flay_test.rb
|
|
216
|
+
- test/lib/rubycritic/adapters/smell/flog_test.rb
|
|
217
|
+
- test/lib/rubycritic/adapters/smell/reek_test.rb
|
|
218
|
+
- test/lib/rubycritic/analysers/churn_test.rb
|
|
219
|
+
- test/lib/rubycritic/configuration_test.rb
|
|
220
|
+
- test/lib/rubycritic/core/analysed_file_test.rb
|
|
221
|
+
- test/lib/rubycritic/core/location_test.rb
|
|
222
|
+
- test/lib/rubycritic/core/smell_test.rb
|
|
223
|
+
- test/lib/rubycritic/core/smells_array_test.rb
|
|
169
224
|
- test/lib/rubycritic/smells_status_setter_test.rb
|
|
170
225
|
- test/lib/rubycritic/source_control_systems/source_control_system_test.rb
|
|
171
226
|
- test/lib/rubycritic/source_locator_test.rb
|
|
227
|
+
- test/lib/rubycritic/turbulence_test.rb
|
|
172
228
|
- test/lib/rubycritic/version_test.rb
|
|
229
|
+
- test/samples/flay/smelly.rb
|
|
230
|
+
- test/samples/flog/complex.rb
|
|
173
231
|
- test/samples/flog/smelly.rb
|
|
174
232
|
- test/samples/location/dir1/file1.rb
|
|
175
233
|
- test/samples/location/file0.rb
|
|
@@ -190,7 +248,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
190
248
|
requirements:
|
|
191
249
|
- - ">="
|
|
192
250
|
- !ruby/object:Gem::Version
|
|
193
|
-
version:
|
|
251
|
+
version: 1.9.3
|
|
194
252
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
253
|
requirements:
|
|
196
254
|
- - ">="
|
|
@@ -198,21 +256,28 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
198
256
|
version: '0'
|
|
199
257
|
requirements: []
|
|
200
258
|
rubyforge_project:
|
|
201
|
-
rubygems_version: 2.
|
|
259
|
+
rubygems_version: 2.2.2
|
|
202
260
|
signing_key:
|
|
203
261
|
specification_version: 4
|
|
204
262
|
summary: Ruby code smell detector
|
|
205
263
|
test_files:
|
|
206
|
-
- test/lib/rubycritic/
|
|
207
|
-
- test/lib/rubycritic/
|
|
208
|
-
- test/lib/rubycritic/
|
|
209
|
-
- test/lib/rubycritic/
|
|
210
|
-
- test/lib/rubycritic/
|
|
211
|
-
- test/lib/rubycritic/
|
|
264
|
+
- test/lib/rubycritic/adapters/complexity/flog_test.rb
|
|
265
|
+
- test/lib/rubycritic/adapters/smell/flay_test.rb
|
|
266
|
+
- test/lib/rubycritic/adapters/smell/flog_test.rb
|
|
267
|
+
- test/lib/rubycritic/adapters/smell/reek_test.rb
|
|
268
|
+
- test/lib/rubycritic/analysers/churn_test.rb
|
|
269
|
+
- test/lib/rubycritic/configuration_test.rb
|
|
270
|
+
- test/lib/rubycritic/core/analysed_file_test.rb
|
|
271
|
+
- test/lib/rubycritic/core/location_test.rb
|
|
272
|
+
- test/lib/rubycritic/core/smell_test.rb
|
|
273
|
+
- test/lib/rubycritic/core/smells_array_test.rb
|
|
212
274
|
- test/lib/rubycritic/smells_status_setter_test.rb
|
|
213
275
|
- test/lib/rubycritic/source_control_systems/source_control_system_test.rb
|
|
214
276
|
- test/lib/rubycritic/source_locator_test.rb
|
|
277
|
+
- test/lib/rubycritic/turbulence_test.rb
|
|
215
278
|
- test/lib/rubycritic/version_test.rb
|
|
279
|
+
- test/samples/flay/smelly.rb
|
|
280
|
+
- test/samples/flog/complex.rb
|
|
216
281
|
- test/samples/flog/smelly.rb
|
|
217
282
|
- test/samples/location/dir1/file1.rb
|
|
218
283
|
- test/samples/location/file0.rb
|
data/SPEC.md
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
Ruby Critic
|
|
2
|
-
===========
|
|
3
|
-
|
|
4
|
-
Ruby Critic is a tool that detects and reports smells in Ruby code.
|
|
5
|
-
|
|
6
|
-
Inspired by [RuboCop][1], [Rails Best Practices][2] and [Code Climate][3], Ruby Critic aims to better help you refactor your code. By making use of Ruby's rich ecosystem of code metrics tools, Ruby Critic generates high-quality visualizations and insightful code quality reports.
|
|
7
|
-
|
|
8
|
-
[1]: https://github.com/bbatsov/rubocop/
|
|
9
|
-
[2]: https://github.com/railsbp/rails_best_practices
|
|
10
|
-
[3]: https://codeclimate.com/
|
|
11
|
-
|
|
12
|
-
Installation
|
|
13
|
-
------------
|
|
14
|
-
|
|
15
|
-
Add this line to your application's Gemfile:
|
|
16
|
-
|
|
17
|
-
```ruby
|
|
18
|
-
gem "rubycritic"
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
And then execute:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
$ bundle
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Or just install it yourself:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
$ gem install rubycritic
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Usage
|
|
34
|
-
-----
|
|
35
|
-
|
|
36
|
-
Running `rubycritic` with no arguments will check all Ruby source files in the
|
|
37
|
-
current directory:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
$ rubycritic
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Alternatively you can pass `rubycritic` a list of files and directories to check:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
$ rubycritic app lib/foo.rb
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Options
|
|
50
|
-
-------
|
|
51
|
-
|
|
52
|
-
To specify an output file for the results:
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
$ rubycritic -o output_file
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
The output format is determined by the file extension or by using the `-f` option. Current options are: `text`, `html`, `yaml` and `json`.
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
require "rubycritic/report_generators/view_helpers"
|
|
2
|
-
|
|
3
|
-
module Rubycritic
|
|
4
|
-
|
|
5
|
-
class BaseGenerator
|
|
6
|
-
REPORT_DIR = File.expand_path("tmp/rubycritic", Dir.getwd)
|
|
7
|
-
TEMPLATES_DIR = File.expand_path("../templates", __FILE__)
|
|
8
|
-
|
|
9
|
-
include ViewHelpers
|
|
10
|
-
|
|
11
|
-
def file_href
|
|
12
|
-
"file://#{file_pathname}"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def file_pathname
|
|
16
|
-
File.join(file_directory, file_name)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def file_directory
|
|
20
|
-
raise NotImplementedError.new("You must implement the file_directory method.")
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def file_name
|
|
24
|
-
raise NotImplementedError.new("You must implement the file_name method.")
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def render
|
|
28
|
-
raise NotImplementedError.new("You must implement the render method.")
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def get_binding
|
|
32
|
-
binding
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
def root_directory
|
|
38
|
-
REPORT_DIR
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
require "erb"
|
|
2
|
-
require "rubycritic/report_generators/base_generator"
|
|
3
|
-
require "rubycritic/report_generators/line_generator"
|
|
4
|
-
|
|
5
|
-
module Rubycritic
|
|
6
|
-
|
|
7
|
-
class FileGenerator < BaseGenerator
|
|
8
|
-
LINE_NUMBER_OFFSET = 1
|
|
9
|
-
FILE_TEMPLATE = ERB.new(File.read(File.join(TEMPLATES_DIR, "file.html.erb")))
|
|
10
|
-
LAYOUT_TEMPLATE = ERB.new(File.read(File.join(TEMPLATES_DIR, "layouts", "application.html.erb")))
|
|
11
|
-
|
|
12
|
-
def initialize(pathname, smells)
|
|
13
|
-
@pathname = pathname
|
|
14
|
-
@smells = smells
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def file_directory
|
|
18
|
-
File.join(REPORT_DIR, File.dirname(@pathname))
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def file_name
|
|
22
|
-
"#{analysed_file_name}.html"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def analysed_file_name
|
|
26
|
-
@pathname.basename.sub_ext("")
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def render
|
|
30
|
-
file_code = ""
|
|
31
|
-
File.readlines(@pathname).each.with_index(LINE_NUMBER_OFFSET) do |line_text, line_number|
|
|
32
|
-
location = Location.new(@pathname, line_number)
|
|
33
|
-
line_smells = @smells.select { |smell| smell.located_in?(location) }
|
|
34
|
-
file_code << LineGenerator.new(line_text, line_smells).render
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
file_body = FILE_TEMPLATE.result(get_binding { file_code })
|
|
38
|
-
LAYOUT_TEMPLATE.result(get_binding { file_body })
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
require "erb"
|
|
2
|
-
require "rubycritic/report_generators/base_generator"
|
|
3
|
-
|
|
4
|
-
module Rubycritic
|
|
5
|
-
|
|
6
|
-
class IndexGenerator < BaseGenerator
|
|
7
|
-
INDEX_TEMPLATE = ERB.new(File.read(File.join(TEMPLATES_DIR, "index.html.erb")))
|
|
8
|
-
LAYOUT_TEMPLATE = ERB.new(File.read(File.join(TEMPLATES_DIR, "layouts", "application.html.erb")))
|
|
9
|
-
|
|
10
|
-
def initialize(file_generators)
|
|
11
|
-
@file_generators = file_generators.sort { |a, b| a.analysed_file_name <=> b.analysed_file_name }
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def file_directory
|
|
15
|
-
REPORT_DIR
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def file_name
|
|
19
|
-
"index.html"
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def render
|
|
23
|
-
index_body = INDEX_TEMPLATE.result(get_binding)
|
|
24
|
-
LAYOUT_TEMPLATE.result(get_binding { index_body })
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require "erb"
|
|
2
|
-
require "rubycritic/report_generators/base_generator"
|
|
3
|
-
require "cgi"
|
|
4
|
-
|
|
5
|
-
module Rubycritic
|
|
6
|
-
|
|
7
|
-
class LineGenerator < BaseGenerator
|
|
8
|
-
NORMAL_TEMPLATE = ERB.new(File.read(File.join(TEMPLATES_DIR, "line.html.erb")))
|
|
9
|
-
SMELLY_TEMPLATE = ERB.new(File.read(File.join(TEMPLATES_DIR, "smelly_line.html.erb")))
|
|
10
|
-
|
|
11
|
-
def initialize(text, smells)
|
|
12
|
-
@text = CGI::escapeHTML(text.chomp)
|
|
13
|
-
@smells = smells
|
|
14
|
-
@template =
|
|
15
|
-
if @smells.empty?
|
|
16
|
-
NORMAL_TEMPLATE
|
|
17
|
-
else
|
|
18
|
-
SMELLY_TEMPLATE
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def render
|
|
23
|
-
@template.result(binding).delete("\n") + "\n"
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
require "rubycritic/report_generators/base_generator"
|
|
2
|
-
require "rubycritic/report_generators/file_generator"
|
|
3
|
-
require "rubycritic/report_generators/index_generator"
|
|
4
|
-
require "fileutils"
|
|
5
|
-
|
|
6
|
-
module Rubycritic
|
|
7
|
-
|
|
8
|
-
class Reporter
|
|
9
|
-
ASSETS_DIR = File.expand_path("../assets", __FILE__)
|
|
10
|
-
|
|
11
|
-
def initialize(source_pathnames, smelly_pathnames)
|
|
12
|
-
@source_pathnames = source_pathnames
|
|
13
|
-
@smelly_pathnames = smelly_pathnames
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def generate_report
|
|
17
|
-
generators.each do |generator|
|
|
18
|
-
FileUtils.mkdir_p(generator.file_directory)
|
|
19
|
-
File.open(generator.file_pathname, "w+") do |file|
|
|
20
|
-
file.write(generator.render)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
FileUtils.cp_r(ASSETS_DIR, BaseGenerator::REPORT_DIR)
|
|
24
|
-
index_generator.file_href
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
private
|
|
28
|
-
|
|
29
|
-
def generators
|
|
30
|
-
file_generators + [index_generator]
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def index_generator
|
|
34
|
-
@index_generator ||= IndexGenerator.new(file_generators)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def file_generators
|
|
38
|
-
@file_generators ||= @source_pathnames.map do |pathname|
|
|
39
|
-
file_smells = @smelly_pathnames[pathname]
|
|
40
|
-
FileGenerator.new(pathname, file_smells)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<table>
|
|
2
|
-
<thead>
|
|
3
|
-
<tr>
|
|
4
|
-
<th>Name</th>
|
|
5
|
-
</tr>
|
|
6
|
-
</thead>
|
|
7
|
-
<tbody>
|
|
8
|
-
<% @file_generators.each do |file_generator| %>
|
|
9
|
-
<tr>
|
|
10
|
-
<td><a href="<%= file_generator.file_pathname %>"><%= file_generator.analysed_file_name %></a></td>
|
|
11
|
-
</tr>
|
|
12
|
-
<% end %>
|
|
13
|
-
</tbody>
|
|
14
|
-
</table>
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require "rubycritic/smell"
|
|
2
|
-
|
|
3
|
-
module Rubycritic
|
|
4
|
-
module SmellAdapter
|
|
5
|
-
|
|
6
|
-
class Flog
|
|
7
|
-
def initialize(flog)
|
|
8
|
-
@flog = flog
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def smells
|
|
12
|
-
smells = []
|
|
13
|
-
@flog.each_by_score do |class_method, score|
|
|
14
|
-
smells << create_smell(class_method, score)
|
|
15
|
-
end
|
|
16
|
-
smells
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
def create_smell(context, score)
|
|
22
|
-
location = method_location(context)
|
|
23
|
-
message = "has a complexity of #{score.round}"
|
|
24
|
-
Smell.new(
|
|
25
|
-
:locations => [location],
|
|
26
|
-
:context => context,
|
|
27
|
-
:message => message,
|
|
28
|
-
:score => score,
|
|
29
|
-
:type => "Complexity"
|
|
30
|
-
)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def method_location(context)
|
|
34
|
-
line = @flog.method_locations[context]
|
|
35
|
-
file_path, file_line = line.split(":")
|
|
36
|
-
Location.new(file_path, file_line)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require "rubycritic/smell"
|
|
2
|
-
|
|
3
|
-
module Rubycritic
|
|
4
|
-
module SmellAdapter
|
|
5
|
-
|
|
6
|
-
class Reek
|
|
7
|
-
def initialize(reek)
|
|
8
|
-
@reek = reek
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def smells
|
|
12
|
-
@reek.smells.map do |smell|
|
|
13
|
-
create_smell(smell)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
def create_smell(smell)
|
|
20
|
-
locations = smell_locations(smell.source, smell.lines)
|
|
21
|
-
message = smell.message
|
|
22
|
-
context = smell.context
|
|
23
|
-
type = smell.subclass
|
|
24
|
-
Smell.new(:locations => locations, :context => context, :message => message, :type => type)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def smell_locations(file_path, file_lines)
|
|
28
|
-
file_lines.uniq.sort.map do |file_line|
|
|
29
|
-
Location.new(file_path, file_line)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
module Rubycritic
|
|
2
|
-
|
|
3
|
-
class SmellsAggregator
|
|
4
|
-
def initialize(smell_adapters)
|
|
5
|
-
@smell_adapters = smell_adapters
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def smells
|
|
9
|
-
@smells ||= @smell_adapters.map(&:smells).flatten.sort
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def smelly_pathnames
|
|
13
|
-
@smelly_pathnames ||= pathnames_to_files_with_smells
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
def pathnames_to_files_with_smells
|
|
19
|
-
pathnames = Hash.new { |hash, key| hash[key] = [] }
|
|
20
|
-
smells.each do |smell|
|
|
21
|
-
smell.pathnames.each do |path|
|
|
22
|
-
pathnames[path] << smell
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
pathnames
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require "fileutils"
|
|
2
|
-
|
|
3
|
-
module Rubycritic
|
|
4
|
-
|
|
5
|
-
class SmellyPathnamesSerializer
|
|
6
|
-
def initialize(file_name)
|
|
7
|
-
@file_name = file_name
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def load
|
|
11
|
-
Marshal.load(File.read(@file_name))
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def dump(smelly_pathnames)
|
|
15
|
-
create_file_directory
|
|
16
|
-
# HACK It's not possible to Marshal procs or lambdas.
|
|
17
|
-
smelly_pathnames.default = []
|
|
18
|
-
File.open(@file_name, "w+") do |file|
|
|
19
|
-
Marshal.dump(smelly_pathnames, file)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
def create_file_directory
|
|
26
|
-
FileUtils.mkdir_p(file_directory)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def file_directory
|
|
30
|
-
File.dirname(@file_name)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
module Rubycritic
|
|
2
|
-
|
|
3
|
-
class SourceControlSystem
|
|
4
|
-
@@systems = []
|
|
5
|
-
|
|
6
|
-
def self.register_system
|
|
7
|
-
@@systems << self
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def self.create
|
|
11
|
-
supported_system = systems.detect(&:supported?)
|
|
12
|
-
if supported_system
|
|
13
|
-
supported_system.new
|
|
14
|
-
else
|
|
15
|
-
raise "Rubycritic requires a #{system_names} repository."
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def self.systems
|
|
20
|
-
@@systems
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def self.system_names
|
|
24
|
-
systems.join(", ")
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def has_revision?
|
|
28
|
-
raise NotImplementedError.new("You must implement the has_revision? method.")
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def head_reference
|
|
32
|
-
raise NotImplementedError.new("You must implement the head_reference method.")
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def travel_to_head
|
|
36
|
-
raise NotImplementedError.new("You must implement the travel_to_head method.")
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
require "rubycritic/source_control_systems/git"
|