rubycritic 4.6.1 → 4.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +59 -6
- data/CONTRIBUTING.md +3 -3
- data/README.md +38 -16
- data/lib/rubycritic/cli/options/argv.rb +4 -3
- data/lib/rubycritic/cli/options/file.rb +1 -1
- data/lib/rubycritic/configuration.rb +2 -1
- data/lib/rubycritic/core/smell.rb +1 -1
- data/lib/rubycritic/generators/html/templates/code_index.html.erb +3 -1
- data/lib/rubycritic/generators/html/templates/smells_index.html.erb +1 -1
- data/lib/rubycritic/generators/text/lint.rb +1 -1
- data/lib/rubycritic/generators/text/list.rb +1 -1
- data/lib/rubycritic/rake_task.rb +22 -12
- data/lib/rubycritic/source_control_systems/git.rb +3 -1
- data/lib/rubycritic/source_locator.rb +6 -1
- data/lib/rubycritic/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 025aff87e62b4fde94b8920973574ff4231503b8d1ed614705b223c61ab8cf17
|
4
|
+
data.tar.gz: b3e0521dd5d2859a7535c51a92f5b5bf2666f7cb02ad26a0171e503861ca308c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b8d0d03d8d9332e90899854e2f4e76e6b293dbc83e2bd76f0e6991fcce087294364bc2f6a1aceefa1cf101b20e6d94522464c61c1f18f06e3be2bc2c206e992
|
7
|
+
data.tar.gz: 8103598ab67398b6f5761ff3608e4a60879474f6b9b312700ccc6c48ecc59dc09ec5728d10a654daa11318bdaba316346be0b1360d8193337d68390c7ffa55a8
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,37 @@
|
|
1
|
-
# main [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.
|
2
|
-
|
3
|
-
# v4.
|
1
|
+
# main [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.8.0...main)
|
2
|
+
|
3
|
+
# v4.8.0 / 2023-05-12 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.7.0...v4.8.0)
|
4
|
+
|
5
|
+
* [CHORE] Fix syntax of contributor references in this file
|
6
|
+
* [CHANGE] Updated branch references from master to main (by [@96RadhikaJadhav][] and [@faisal][])
|
7
|
+
* [CHORE] Test gem with Ruby 3.2 (by [@etagwerker][])
|
8
|
+
* [CHORE] Test gem with Ruby 3.1 (by [@etagwerker][])
|
9
|
+
* [CHANGE] Drop support for JRuby 9.3.x (by [@faisal][])
|
10
|
+
* [CHANGE] Drop support for Ruby 2.6.x (by [@faisal][])
|
11
|
+
* [CHANGE] Drop support for Ruby 2.5.x (by [@cleicar][])
|
12
|
+
* [CHANGE] Drop support for Ruby 2.4.x (by [@rishijain][])
|
13
|
+
* [FEATURE] Add ruby_extensions configuration option (by [@stufro][])
|
14
|
+
* [CHANGE] Include files which have a ruby shebang (by [@stufro][])
|
15
|
+
* [CHANGE] Fix some typos (by [@ydah][])
|
16
|
+
* [CHANGE] Remove wrong Rubocop reference in contributing file (by [@itsmeurbi][])
|
17
|
+
* [BUGFIX] Restore missing smell status label (by [@itsmeurbi][])
|
18
|
+
* [BUGFIX] Fix changelog @user links and update README (by [@kcamcam][])
|
19
|
+
* [BUGFIX] Fix CI rubocop using ruby-head (by [@juanvqz][])
|
20
|
+
* [BUGFIX] Fix CI Update FakeFs to use ruby-head (by [@juanvqz][])
|
21
|
+
* [BUGFIX] Fix CI, test didn't include the ruby_extensions (by [@aisayo][] and [@juanvqz][])
|
22
|
+
* [FEATURE] Support a branch in 'detached HEAD' state (by [@h-r-k-matsumoto][])
|
23
|
+
* [BUGFIX] Fix CI, tests did not work with JRuby (by [@etagwerker][] and [@h-r-k-matsumoto][])
|
24
|
+
* [CHANGE] Add continuous integration status badge to README (by [@kcamcam][])
|
25
|
+
|
26
|
+
# v4.7.0 / 2022-05-06 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.6.1...v4.7.0)
|
27
|
+
|
28
|
+
* [CHANGE] Run test suite with Ruby 3.1 (by [@etagwerker][])
|
29
|
+
* [FEATURE] Allow the Rake task generator to accept a description (by [@anicholson][])
|
30
|
+
* [CHANGE] Replace travis-ci with Github Actions for contributors (by [@RyanSnodgrass][])
|
31
|
+
* [CHANGE] Drop support for JRuby 9.1.x (by [@RyanSnodgrass][])
|
32
|
+
* [BUGFIX] Exit with 0 or 1 from Rake Task. Fixes #214 (by [@RyanSnodgrass][])
|
33
|
+
|
34
|
+
# v4.6.1 / 2021-01-28 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.6.0...v4.6.1)
|
4
35
|
|
5
36
|
* [CHANGE] CI: Drop rbx-3 from matrix, does not install (by [@olleolleolle][])
|
6
37
|
* [CHANGE] Add support for Ruby 3.0 (by [@etagwerker][])
|
@@ -12,6 +43,7 @@
|
|
12
43
|
* [CHANGE] Make Github Linguist ignore vendored files (by [@sl4vr][])
|
13
44
|
* [BUGFIX] Fix directory structure of reports when comparing branches (by [@denny][])
|
14
45
|
* [BUGFIX] Restrict simplecov to versions before data format changed (by [@denny][])
|
46
|
+
* [BUGFIX] Handle missing comparison file in html template (by [@lauratpa][])
|
15
47
|
|
16
48
|
# v4.5.2 / 2020-08-20 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.5.1...v4.5.2)
|
17
49
|
|
@@ -20,7 +52,6 @@
|
|
20
52
|
# v4.5.1 / 2020-06-29 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.5.0...v4.5.1)
|
21
53
|
|
22
54
|
* [BUGFIX] Handle git --name-status Copied (C) operation (by [@rizalmuthi][])
|
23
|
-
|
24
55
|
* [FEATURE] Add --churn-after (only supports git) to limit churn analysis to recent history (by [@jackcasey][])
|
25
56
|
|
26
57
|
# v4.5.0 / 2020-05-14 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.4.1...v4.5.0)
|
@@ -89,8 +120,8 @@
|
|
89
120
|
|
90
121
|
# 4.0.0 / 2019-02-27 [(commits)](https://github.com/whitesmith/rubycritic/compare/v3.5.1...v4.0.0)
|
91
122
|
|
92
|
-
* [FEATURE] Allow generating reports in multiple formats in one run (by [@katafrakt])
|
93
|
-
* [FEATURE] Allow to accept a config file (by [@mfbmina])
|
123
|
+
* [FEATURE] Allow generating reports in multiple formats in one run (by [@katafrakt][])
|
124
|
+
* [FEATURE] Allow to accept a config file (by [@mfbmina][])
|
94
125
|
* [CHANGE] Update `reek` to 5.3 (by [@taitran19][] and [@onumis][])
|
95
126
|
* [CHANGE] Update `parser` to 2.6.0 (by [@onumis][])
|
96
127
|
* [CHANGE] Update `tty-which` to 0.4.0 (by [@onumis][])
|
@@ -366,3 +397,25 @@
|
|
366
397
|
[@jackcasey]: https://github.com/jackcasey
|
367
398
|
[@sl4vr]: https://github.com/sl4vr
|
368
399
|
[@denny]: https://github.com/denny
|
400
|
+
[@RyanSnodgrass]: https://github.com/RyanSnodgrass
|
401
|
+
[@ydah]: https://github.com/ydah
|
402
|
+
[@stufro]: https://github.com/stufro
|
403
|
+
[@rishijain]: https://github.com/rishijain
|
404
|
+
[@cleicar]: https://github.com/cleicar
|
405
|
+
[@anicholson]: https://github.com/anicholson
|
406
|
+
[@borisrorsvort]: https://github.com/borisrorsvort
|
407
|
+
[@lauratpa]: https://github.com/lauratpa
|
408
|
+
[@MZiserman]: https://github.com/MZiserman
|
409
|
+
[@rizalmuthi]: https://github.com/rizalmuthi
|
410
|
+
[@jsantos]: https://github.com/jsantos
|
411
|
+
[@teohm]: https://github.com/teohm
|
412
|
+
[@itsmeurbi]: https://github.com/itsmeurbi
|
413
|
+
[@kcamcam]: https://github.com/kcamcam
|
414
|
+
[@aisayo]: https://github.com/aisayo
|
415
|
+
[@h-r-k-matsumoto]: https://github.com/h-r-k-matsumoto
|
416
|
+
[@juanvqz]: https://github.com/juanvqz
|
417
|
+
[@eitoball]: https://github.com/eitoball
|
418
|
+
[@marcgrimme]: https://github.com/marcgrimme
|
419
|
+
[@katafrakt]: https://github.com/katafrakt
|
420
|
+
[@faisal]: https://github.com/faisal
|
421
|
+
[@96RadhikaJadhav]: https://github.com/
|
data/CONTRIBUTING.md
CHANGED
@@ -32,7 +32,7 @@ Each commit should do one thing and one thing only. For example, all whitespace
|
|
32
32
|
|
33
33
|
9. Push the branch to GitHub (`git push origin my-new-feature`).
|
34
34
|
|
35
|
-
10. [Create a Pull Request] and send it to be merged with the
|
35
|
+
10. [Create a Pull Request] and send it to be merged with the main branch.
|
36
36
|
|
37
37
|
11. After your code is reviewed, [hide the sausage making]. We follow the "one commit per pull request" [principle](http://ndlib.github.io/practices/one-commit-per-pull-request/) since this allows for a clean git history, easy handling of features and convenient rollbacks when things go wrong. Or in one sentence: You can have as many commits as you want in your pull request, but after the final review and before the merge you need to squash all of those in one single commit.
|
38
38
|
For a more in-depth look at interactive rebasing, be sure to check [how to rewrite history] as well.
|
@@ -85,9 +85,9 @@ Here are a few examples:
|
|
85
85
|
```
|
86
86
|
|
87
87
|
* Mark it up in [Markdown syntax](http://daringfireball.net/projects/markdown/syntax).
|
88
|
-
* Add your entry in the `
|
88
|
+
* Add your entry in the `main (unreleased)` section.
|
89
89
|
* The entry line should start with `* ` (an asterisk and a space).
|
90
90
|
* Start with the change type BUGFIX / CHANGE / FEATURE.
|
91
91
|
* Describe the brief of the change.
|
92
92
|
* At the end of the entry, add an implicit link to your GitHub user page as `([@username][])`.
|
93
|
-
* If this is your first contribution to
|
93
|
+
* If this is your first contribution to RubyCritic project, add a link definition for the implicit link to the bottom of the changelog as `[@username]: https://github.com/username`.
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# RubyCritic
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/rubycritic.svg)](http://badge.fury.io/rb/rubycritic)
|
4
|
+
[![Continuous Integration](https://github.com/whitesmith/rubycritic/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/whitesmith/rubycritic/actions/workflows/main.yml)
|
4
5
|
[![Build Status](https://travis-ci.org/whitesmith/rubycritic.svg?branch=master)](https://travis-ci.org/whitesmith/rubycritic)
|
5
6
|
[![Code Climate](https://codeclimate.com/github/whitesmith/rubycritic/badges/gpa.svg)](https://codeclimate.com/github/whitesmith/rubycritic)
|
6
7
|
|
@@ -16,6 +17,7 @@ RubyCritic is a gem that wraps around static analysis gems such as [Reek][1], [F
|
|
16
17
|
+ [Analyzer Configuration](#analyzer-configuration)
|
17
18
|
+ [Alternative Usage Methods](#alternative-usage-methods)
|
18
19
|
+ [Rake Task](#rake-task)
|
20
|
+
- [Formatters](#formatters)
|
19
21
|
- [Compatibility](#compatibility)
|
20
22
|
- [Improving RubyCritic](#improving-rubyCritic)
|
21
23
|
- [Contributors](#contributors)
|
@@ -26,15 +28,12 @@ RubyCritic is a gem that wraps around static analysis gems such as [Reek][1], [F
|
|
26
28
|
This gem provides features such as:
|
27
29
|
|
28
30
|
1. An overview of your project:
|
29
|
-
|
30
31
|
![RubyCritic overview screenshot](https://github.com/whitesmith/rubycritic/raw/main/images/overview.png)
|
31
32
|
|
32
33
|
2. An index of the project files with their respective number of smells:
|
33
|
-
|
34
34
|
![RubyCritic code index screenshot](https://github.com/whitesmith/rubycritic/raw/main/images/code.png)
|
35
35
|
|
36
36
|
3. An index of the smells detected:
|
37
|
-
|
38
37
|
![RubyCritic smells index screenshot](https://github.com/whitesmith/rubycritic/raw/main/images/smells.png)
|
39
38
|
|
40
39
|
4. When analysing code like the following:
|
@@ -61,10 +60,10 @@ This gem provides features such as:
|
|
61
60
|
are currently supported) to compare your currently uncommitted
|
62
61
|
changes with your last commit.
|
63
62
|
|
64
|
-
|
65
|
-
|
63
|
+
**Warning**: If your code is not as you expect it to be after running
|
64
|
+
RubyCritic, please check your source control system stash.
|
66
65
|
|
67
|
-
Checkout the `/docs` if you want to read more about our [core metrics](https://github.com/whitesmith/rubycritic/blob/
|
66
|
+
Checkout the `/docs` if you want to read more about our [core metrics](https://github.com/whitesmith/rubycritic/blob/main/docs/core-metrics.md).
|
68
67
|
|
69
68
|
## Getting Started
|
70
69
|
|
@@ -128,7 +127,7 @@ $ rubycritic --help
|
|
128
127
|
- `console`
|
129
128
|
- `lint`
|
130
129
|
2. See [custom formatters docs](/docs/formatters.md)
|
131
|
-
3. Faster, analyses diffs w.r.t base_branch (default:
|
130
|
+
3. Faster, analyses diffs w.r.t base_branch (default: main), see `-b`
|
132
131
|
4. Works only with `-b`, default: 0
|
133
132
|
|
134
133
|
You also can use a config file. Just create a `.rubycritic.yml` on your project root path.
|
@@ -138,8 +137,8 @@ Here are one example:
|
|
138
137
|
```yml
|
139
138
|
mode_ci:
|
140
139
|
enabled: true # default is false
|
141
|
-
branch: 'production' # default is
|
142
|
-
branch: 'production' # default is
|
140
|
+
branch: 'production' # default is main
|
141
|
+
branch: 'production' # default is main
|
143
142
|
path: '/tmp/mycustompath' # Set path where report will be saved (tmp/rubycritic by default)
|
144
143
|
threshold_score: 10 # default is 0
|
145
144
|
deduplicate_symlinks: true # default is false
|
@@ -159,7 +158,7 @@ paths: # Files to analyse.
|
|
159
158
|
This means that if you have an existing `Reek` configuration file, you can just put this into your
|
160
159
|
project root and `RubyCritic` will respect this configuration.
|
161
160
|
* [`flay`](https://github.com/seattlerb/flay): We use `flay`'s default configuration.
|
162
|
-
* [`flog`](https://github.com/seattlerb/flog): We use `flog`'s default configuration with a couple of [smaller tweaks](https://github.com/whitesmith/rubycritic/blob/
|
161
|
+
* [`flog`](https://github.com/seattlerb/flog): We use `flog`'s default configuration with a couple of [smaller tweaks](https://github.com/whitesmith/rubycritic/blob/main/lib/rubycritic/analysers/helpers/flog.rb#L5):
|
163
162
|
* `all`: Forces `flog` to report scores on all classes and methods. Without this option `flog` will only give results up to a certain threshold.
|
164
163
|
* `continue`: Makes it so that `flog` does not abort when a ruby file cannot be parsed.
|
165
164
|
* `methods`: Configures `flog` to skip code outside of methods. It prevents `flog` from reporting on the "methods" `private` and `protected`. It also prevents `flog` from reporting on Rails methods like `before_action` and `has_many`.
|
@@ -196,6 +195,9 @@ RubyCritic::RakeTask.new do |task|
|
|
196
195
|
|
197
196
|
# Defaults to false
|
198
197
|
task.verbose = true
|
198
|
+
|
199
|
+
# Fail the Rake task if RubyCritic doesn't pass. Defaults to true
|
200
|
+
task.fail_on_error = true
|
199
201
|
end
|
200
202
|
```
|
201
203
|
|
@@ -208,6 +210,22 @@ RubyCritic::RakeTask.new do |task|
|
|
208
210
|
end
|
209
211
|
```
|
210
212
|
|
213
|
+
If you wish to create multiple Rake tasks (e.g., for local & for ci-specific configuration), you can do so!
|
214
|
+
If you decide to do this, you should provide a clearer description for each task:
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
# for local
|
218
|
+
RubyCritic::RakeTask.new("local", "Run RubyCritic (local configuration)" do |task|
|
219
|
+
# ...
|
220
|
+
end
|
221
|
+
|
222
|
+
# for CI
|
223
|
+
RubyCritic::RakeTask.new("ci", "Run RubyCritic (CI configuration)" do |task|
|
224
|
+
task.options = "--mode-ci"
|
225
|
+
# ...
|
226
|
+
end
|
227
|
+
```
|
228
|
+
|
211
229
|
## Formatters
|
212
230
|
|
213
231
|
See [formatters](docs/formatters.md)
|
@@ -216,10 +234,14 @@ See [formatters](docs/formatters.md)
|
|
216
234
|
|
217
235
|
RubyCritic is supporting Ruby versions:
|
218
236
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
237
|
+
| Ruby version | Latest RubyCritic version |
|
238
|
+
| - | - |
|
239
|
+
| 2.4 | [v4.7.0](https://github.com/whitesmith/rubycritic/tree/v4.7.0) |
|
240
|
+
| 2.5 | [v4.7.0](https://github.com/whitesmith/rubycritic/tree/v4.7.0) |
|
241
|
+
| 2.6 | [v4.7.0](https://github.com/whitesmith/rubycritic/tree/v4.7.0) |
|
242
|
+
| 2.7 | latest |
|
243
|
+
| 3.0 | latest |
|
244
|
+
| 3.1 | latest |
|
223
245
|
|
224
246
|
## Improving RubyCritic
|
225
247
|
|
@@ -229,7 +251,7 @@ Arguably, the [better_errors gem][7] only got popular after receiving a [(pretty
|
|
229
251
|
|
230
252
|
Similarly, Pull Requests that improve the look and feel of the gem, that tweak the calculation of ratings or that fix existing issues will be most welcome. Just commenting on an issue and giving some insight into how something should work will be appreciated. No contribution is too small.
|
231
253
|
|
232
|
-
See RubyCritic's [contributing guidelines](https://github.com/whitesmith/rubycritic/blob/
|
254
|
+
See RubyCritic's [contributing guidelines](https://github.com/whitesmith/rubycritic/blob/main/CONTRIBUTING.md) about how to proceed.
|
233
255
|
|
234
256
|
## Contributors
|
235
257
|
|
@@ -252,7 +274,7 @@ RubyCritic is maintained and funded by [Whitesmith][9]. Tweet your questions or
|
|
252
274
|
[3]: https://github.com/seattlerb/flog
|
253
275
|
[4]: https://github.com/whitesmith/guard-rubycritic
|
254
276
|
[5]: http://jenkins-ci.org/
|
255
|
-
[6]: https://github.com/whitesmith/rubycritic/blob/
|
277
|
+
[6]: https://github.com/whitesmith/rubycritic/blob/main/docs/building-own-code-climate.md
|
256
278
|
[7]: https://github.com/charliesome/better_errors
|
257
279
|
[8]: https://github.com/charliesome/better_errors/pull/22
|
258
280
|
[9]: http://www.whitesmith.co/
|
@@ -57,7 +57,7 @@ module RubyCritic
|
|
57
57
|
'Instantiate a given class as formatter and call report for reporting.',
|
58
58
|
'Two ways are possible to load the formatter.',
|
59
59
|
'If the class is not autorequired the REQUIREPATH can be given together',
|
60
|
-
'with the CLASSNAME to be loaded
|
60
|
+
'with the CLASSNAME to be loaded separated by a :.',
|
61
61
|
'Example: rubycritic/markdown/reporter.rb:RubyCritic::MarkDown::Reporter',
|
62
62
|
'or if the file is already required the CLASSNAME is enough',
|
63
63
|
'Example: RubyCritic::MarkDown::Reporter',
|
@@ -77,8 +77,8 @@ module RubyCritic
|
|
77
77
|
end
|
78
78
|
|
79
79
|
opts.on('-m', '--mode-ci [BASE_BRANCH]',
|
80
|
-
'Use CI mode (faster, analyses diffs w.r.t base_branch (default:
|
81
|
-
self.base_branch = branch || '
|
80
|
+
'Use CI mode (faster, analyses diffs w.r.t base_branch (default: main))') do |branch|
|
81
|
+
self.base_branch = branch || 'main'
|
82
82
|
set_current_branch
|
83
83
|
self.mode = :ci
|
84
84
|
end
|
@@ -130,6 +130,7 @@ module RubyCritic
|
|
130
130
|
attr_accessor :mode, :root, :formats, :formatters, :deduplicate_symlinks,
|
131
131
|
:suppress_ratings, :minimum_score, :churn_after, :no_browser,
|
132
132
|
:parser, :base_branch, :feature_branch, :threshold_score
|
133
|
+
|
133
134
|
def paths
|
134
135
|
@argv unless @argv.empty?
|
135
136
|
end
|
@@ -38,7 +38,7 @@ module RubyCritic
|
|
38
38
|
private
|
39
39
|
|
40
40
|
def base_branch
|
41
|
-
return options.dig('mode_ci', 'branch') || '
|
41
|
+
return options.dig('mode_ci', 'branch') || 'main' if options.dig('mode_ci', 'enabled').to_s == 'true'
|
42
42
|
|
43
43
|
options['branch']
|
44
44
|
end
|
@@ -10,7 +10,7 @@ module RubyCritic
|
|
10
10
|
:feature_branch, :base_branch_score, :feature_branch_score,
|
11
11
|
:base_root_directory, :feature_root_directory,
|
12
12
|
:compare_root_directory, :threshold_score, :base_branch_collection,
|
13
|
-
:feature_branch_collection, :churn_after
|
13
|
+
:feature_branch_collection, :churn_after, :ruby_extensions
|
14
14
|
|
15
15
|
def set(options)
|
16
16
|
self.mode = options[:mode] || :default
|
@@ -20,6 +20,7 @@ module RubyCritic
|
|
20
20
|
self.open_with = options[:open_with]
|
21
21
|
self.no_browser = options[:no_browser]
|
22
22
|
self.threshold_score = options[:threshold_score].to_i
|
23
|
+
self.ruby_extensions = options[:ruby_extensions] || %w[.rb .rake .thor]
|
23
24
|
setup_version_control(options)
|
24
25
|
setup_formats(options)
|
25
26
|
end
|
@@ -25,7 +25,9 @@
|
|
25
25
|
<td class="center">
|
26
26
|
<% if Config.build_mode? %>
|
27
27
|
<% master_analysed_module = Config.base_branch_collection.find(analysed_module.pathname) %>
|
28
|
-
<% if master_analysed_module
|
28
|
+
<% if !master_analysed_module %>
|
29
|
+
<span class="empty-span glyphicon"></span>
|
30
|
+
<% elsif master_analysed_module.cost > analysed_module.cost %>
|
29
31
|
<span class="glyphicon glyphicon-arrow-up green-color"></span>
|
30
32
|
<% elsif master_analysed_module.cost < analysed_module.cost %>
|
31
33
|
<span class="glyphicon glyphicon-arrow-down red-color"></span>
|
@@ -32,7 +32,7 @@
|
|
32
32
|
<% if @show_status %>
|
33
33
|
<ul class="nav nav-pills">
|
34
34
|
<li role="presentation">
|
35
|
-
<
|
35
|
+
<span class="status-<%= smell.status %> circled-text circle"><%= smell.status %></span>
|
36
36
|
</li>
|
37
37
|
</ul>
|
38
38
|
<% end %>
|
@@ -10,7 +10,7 @@ module RubyCritic
|
|
10
10
|
TEMPLATE_PATH = File.expand_path('templates/list.erb', __dir__)
|
11
11
|
|
12
12
|
def erb_template
|
13
|
-
@erb_template ||= ERB.new(File.read(TEMPLATE_PATH),
|
13
|
+
@erb_template ||= ERB.new(File.read(TEMPLATE_PATH), trim_mode: '-')
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
data/lib/rubycritic/rake_task.rb
CHANGED
@@ -36,11 +36,17 @@ module RubyCritic
|
|
36
36
|
# "-p / --path" since that is set separately. Defaults to ''.
|
37
37
|
attr_writer :options
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
# Whether or not to fail Rake task when RubyCritic does not pass.
|
40
|
+
# Defaults to true.
|
41
|
+
attr_writer :fail_on_error
|
42
|
+
|
43
|
+
def initialize(name = :rubycritic, description = 'Run RubyCritic')
|
44
|
+
@name = name
|
45
|
+
@description = description
|
46
|
+
@paths = FileList['.']
|
47
|
+
@options = ''
|
48
|
+
@verbose = false
|
49
|
+
@fail_on_error = true
|
44
50
|
|
45
51
|
yield self if block_given?
|
46
52
|
define_task
|
@@ -48,20 +54,24 @@ module RubyCritic
|
|
48
54
|
|
49
55
|
private
|
50
56
|
|
51
|
-
attr_reader :name, :paths, :verbose, :options
|
57
|
+
attr_reader :name, :description, :paths, :verbose, :options, :fail_on_error
|
52
58
|
|
53
59
|
def define_task
|
54
|
-
desc
|
60
|
+
desc description
|
55
61
|
task(name) { run_task }
|
56
62
|
end
|
57
63
|
|
58
64
|
def run_task
|
59
|
-
if verbose
|
60
|
-
puts "\n\n!!! Running `#{name}` rake command\n"
|
61
|
-
puts "!!! Inspecting #{paths} #{options.empty? ? '' : "with options #{options}"}\n\n"
|
62
|
-
end
|
65
|
+
print_starting_up_output if verbose
|
63
66
|
application = RubyCritic::Cli::Application.new(options_as_arguments + paths)
|
64
|
-
application.execute
|
67
|
+
return unless application.execute.nonzero? && fail_on_error
|
68
|
+
|
69
|
+
abort('RubyCritic did not pass - exiting!')
|
70
|
+
end
|
71
|
+
|
72
|
+
def print_starting_up_output
|
73
|
+
puts "\n\n!!! Running `#{name}` rake command\n"
|
74
|
+
puts "!!! Inspecting #{paths} #{options.empty? ? '' : "with options #{options}"}\n\n"
|
65
75
|
end
|
66
76
|
|
67
77
|
def options_as_arguments
|
@@ -81,7 +81,9 @@ module RubyCritic
|
|
81
81
|
|
82
82
|
def self.current_branch
|
83
83
|
branch_list = `git branch`
|
84
|
-
branch_list.match(/\*.*$/)[0].gsub('* ', '')
|
84
|
+
branch = branch_list.match(/\*.*$/)[0].gsub('* ', '')
|
85
|
+
branch = branch.gsub(/\(HEAD detached at (.*)\)$/, '\1') if branch =~ /\(HEAD detached at (.*)\)$/
|
86
|
+
branch
|
85
87
|
end
|
86
88
|
|
87
89
|
private
|
@@ -7,6 +7,7 @@ module RubyCritic
|
|
7
7
|
class SourceLocator
|
8
8
|
RUBY_EXTENSION = '.rb'.freeze
|
9
9
|
RUBY_FILES = File.join('**', "*#{RUBY_EXTENSION}")
|
10
|
+
RUBY_SHEBANG = '#!/usr/bin/env ruby'.freeze
|
10
11
|
|
11
12
|
def initialize(paths)
|
12
13
|
@initial_paths = Array(paths)
|
@@ -39,7 +40,7 @@ module RubyCritic
|
|
39
40
|
path_list = @initial_paths.flat_map do |path|
|
40
41
|
if File.directory?(path)
|
41
42
|
Pathname.glob(File.join(path, RUBY_FILES))
|
42
|
-
elsif File.exist?(path) &&
|
43
|
+
elsif File.exist?(path) && ruby_file?(path)
|
43
44
|
Pathname.new(path)
|
44
45
|
end
|
45
46
|
end.compact
|
@@ -48,5 +49,9 @@ module RubyCritic
|
|
48
49
|
|
49
50
|
path_list.map(&:cleanpath)
|
50
51
|
end
|
52
|
+
|
53
|
+
def ruby_file?(path)
|
54
|
+
Config.ruby_extensions.include?(File.extname(path)) || File.open(path, &:gets).to_s.match?(RUBY_SHEBANG)
|
55
|
+
end
|
51
56
|
end
|
52
57
|
end
|
data/lib/rubycritic/version.rb
CHANGED
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: 4.
|
4
|
+
version: 4.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:
|
11
|
+
date: 2023-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: flay
|
@@ -270,7 +270,7 @@ dependencies:
|
|
270
270
|
requirements:
|
271
271
|
- - "~>"
|
272
272
|
- !ruby/object:Gem::Version
|
273
|
-
version: 1.
|
273
|
+
version: 1.4.1
|
274
274
|
- - "<"
|
275
275
|
- !ruby/object:Gem::Version
|
276
276
|
version: 2.0.0
|
@@ -280,7 +280,7 @@ dependencies:
|
|
280
280
|
requirements:
|
281
281
|
- - "~>"
|
282
282
|
- !ruby/object:Gem::Version
|
283
|
-
version: 1.
|
283
|
+
version: 1.4.1
|
284
284
|
- - "<"
|
285
285
|
- !ruby/object:Gem::Version
|
286
286
|
version: 2.0.0
|
@@ -392,14 +392,14 @@ dependencies:
|
|
392
392
|
requirements:
|
393
393
|
- - "~>"
|
394
394
|
- !ruby/object:Gem::Version
|
395
|
-
version: 0.
|
395
|
+
version: 0.75.0
|
396
396
|
type: :development
|
397
397
|
prerelease: false
|
398
398
|
version_requirements: !ruby/object:Gem::Requirement
|
399
399
|
requirements:
|
400
400
|
- - "~>"
|
401
401
|
- !ruby/object:Gem::Version
|
402
|
-
version: 0.
|
402
|
+
version: 0.75.0
|
403
403
|
description: RubyCritic is a tool that wraps around various static analysis gems to
|
404
404
|
provide a quality report of your Ruby code.
|
405
405
|
email:
|
@@ -535,14 +535,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
535
535
|
requirements:
|
536
536
|
- - ">="
|
537
537
|
- !ruby/object:Gem::Version
|
538
|
-
version: 2.
|
538
|
+
version: 2.7.0
|
539
539
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
540
540
|
requirements:
|
541
541
|
- - ">="
|
542
542
|
- !ruby/object:Gem::Version
|
543
543
|
version: '0'
|
544
544
|
requirements: []
|
545
|
-
rubygems_version: 3.
|
545
|
+
rubygems_version: 3.1.6
|
546
546
|
signing_key:
|
547
547
|
specification_version: 4
|
548
548
|
summary: RubyCritic is a Ruby code quality reporter
|