rubocop_todo_corrector 0.1.1 → 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/CHANGELOG.md +22 -0
- data/Gemfile.lock +2 -1
- data/README.md +13 -1
- data/lib/rubocop_todo_corrector/cli.rb +9 -2
- data/lib/rubocop_todo_corrector/commands/correct.rb +31 -0
- data/lib/rubocop_todo_corrector/commands/describe.rb +0 -2
- data/lib/rubocop_todo_corrector/commands/pick.rb +2 -2
- data/lib/rubocop_todo_corrector/commands.rb +1 -0
- data/lib/rubocop_todo_corrector/cop_document_parser.rb +2 -0
- data/lib/rubocop_todo_corrector/version.rb +1 -1
- data/templates/description.md.erb +4 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c85c8d566f2b49425a572f879680331084e81e9d3ef8de784f01d76a02405ea2
|
4
|
+
data.tar.gz: b42c06c055c914dd5ec4c26147c9de35f77361b08b621d3dd415d9bbbe498408
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30fe5e842703e0f9416d15fa5a11a36c8caf66481266381fcad1fcf422bb6b21632276119e3c442710e45a9728ca8c87c035883adb19d59a8a1c966f15d7f989
|
7
|
+
data.tar.gz: c8bbb8075412c6f784e39f73455371fabd593e2c3ca9409eb68abd683f54b4170aa46e94375c6f3c6db2cd5a4a72808cc7b8c6acd999e3131f7ba8efb36b155b
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,28 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 0.4.0 - 2022-05-16
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
|
9
|
+
- Fix misspell: `occured` -> `occurred`.
|
10
|
+
|
11
|
+
## 0.3.0 - 2022-05-15
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
|
15
|
+
- Change `describe` output so that commit-message-ready text is described.
|
16
|
+
|
17
|
+
## 0.2.0 - 2022-05-15
|
18
|
+
|
19
|
+
### Added
|
20
|
+
|
21
|
+
- Add `correct` command.
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Improve description on no named example.
|
26
|
+
|
5
27
|
## 0.1.1 - 2022-05-15
|
6
28
|
|
7
29
|
### Changed
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# RubocopTodoCorrector
|
2
2
|
|
3
3
|
[![test](https://github.com/r7kamura/rubocop_todo_corrector/actions/workflows/test.yml/badge.svg)](https://github.com/r7kamura/rubocop_todo_corrector/actions/workflows/test.yml)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/rubocop_todo_corrector.svg)](https://rubygems.org/gems/rubocop_todo_corrector)
|
4
5
|
|
5
6
|
Auto-correct offenses defined in .rubocop_todo.yml.
|
6
7
|
|
@@ -24,6 +25,7 @@ gem install rubocop_todo_corrector
|
|
24
25
|
$ rubocop_todo_corrector
|
25
26
|
Commands:
|
26
27
|
rubocop_todo_corrector bundle # Run `bundle install` to install RuboCop related gems.
|
28
|
+
rubocop_todo_corrector correct # Run `rubocop --auto-correct-all`.
|
27
29
|
rubocop_todo_corrector describe --cop-name=COP_NAME # Output Markdown description for specified cop.
|
28
30
|
rubocop_todo_corrector generate # Run `rubocop --auto-gen-config` to generate .rubocop_todo.yml.
|
29
31
|
rubocop_todo_corrector help [COMMAND] # Describe available commands or one specific command
|
@@ -41,6 +43,16 @@ Usage:
|
|
41
43
|
Run `bundle install` to install RuboCop related gems.
|
42
44
|
```
|
43
45
|
|
46
|
+
### correct
|
47
|
+
|
48
|
+
```console
|
49
|
+
$ rubocop_todo_corrector help correct
|
50
|
+
Usage:
|
51
|
+
rubocop_todo_corrector correct
|
52
|
+
|
53
|
+
Run `rubocop --auto-correct-all`.
|
54
|
+
```
|
55
|
+
|
44
56
|
### describe
|
45
57
|
|
46
58
|
```console
|
@@ -74,7 +86,7 @@ Usage:
|
|
74
86
|
Options:
|
75
87
|
[--mode=MODE]
|
76
88
|
# Default: random
|
77
|
-
# Possible values: first, last,
|
89
|
+
# Possible values: first, last, least_occurred, most_occurred, random
|
78
90
|
|
79
91
|
Output an auto-correctable Cop from .rubocop_todo.yml.
|
80
92
|
```
|
@@ -14,6 +14,13 @@ module RubocopTodoCorrector
|
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
|
+
desc 'correct', 'Run `rubocop --auto-correct-all`.'
|
18
|
+
def correct
|
19
|
+
Commands::Correct.call(
|
20
|
+
temporary_gemfile_path: 'tmp/Gemfile_rubocop_todo_corrector.rb'
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
17
24
|
desc 'describe', 'Output Markdown description for specified cop.'
|
18
25
|
option(
|
19
26
|
:cop_name,
|
@@ -42,8 +49,8 @@ module RubocopTodoCorrector
|
|
42
49
|
enum: %w[
|
43
50
|
first
|
44
51
|
last
|
45
|
-
|
46
|
-
|
52
|
+
least_occurred
|
53
|
+
most_occurred
|
47
54
|
random
|
48
55
|
],
|
49
56
|
type: :string
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubocopTodoCorrector
|
4
|
+
module Commands
|
5
|
+
class Correct
|
6
|
+
class << self
|
7
|
+
# @param [String] temporary_gemfile_path
|
8
|
+
def call(
|
9
|
+
temporary_gemfile_path:
|
10
|
+
)
|
11
|
+
new(
|
12
|
+
temporary_gemfile_path: temporary_gemfile_path
|
13
|
+
).call
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(
|
18
|
+
temporary_gemfile_path:
|
19
|
+
)
|
20
|
+
@temporary_gemfile_path = temporary_gemfile_path
|
21
|
+
end
|
22
|
+
|
23
|
+
def call
|
24
|
+
::Kernel.system(
|
25
|
+
{ 'BUNDLE_GEMFILE' => @temporary_gemfile_path },
|
26
|
+
'bundle exec rubocop --auto-correct-all'
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -57,11 +57,11 @@ module RubocopTodoCorrector
|
|
57
57
|
auto_correctable_cops.first
|
58
58
|
when 'last'
|
59
59
|
auto_correctable_cops.last
|
60
|
-
when '
|
60
|
+
when 'least_occurred'
|
61
61
|
auto_correctable_cops.min_by do |cop|
|
62
62
|
cop[:offenses_count]
|
63
63
|
end
|
64
|
-
when '
|
64
|
+
when 'most_occurred'
|
65
65
|
auto_correctable_cops.max_by do |cop|
|
66
66
|
cop[:offenses_count]
|
67
67
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module RubocopTodoCorrector
|
4
4
|
module Commands
|
5
5
|
autoload :Bundle, 'rubocop_todo_corrector/commands/bundle'
|
6
|
+
autoload :Correct, 'rubocop_todo_corrector/commands/correct'
|
6
7
|
autoload :Describe, 'rubocop_todo_corrector/commands/describe'
|
7
8
|
autoload :Generate, 'rubocop_todo_corrector/commands/generate'
|
8
9
|
autoload :Pick, 'rubocop_todo_corrector/commands/pick'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
Auto-correct <%= @cop_name %>
|
2
|
+
|
1
3
|
## Summary
|
2
4
|
|
3
5
|
Auto-corrected [<%= @cop_name %>](<%= cop_url %>).
|
@@ -13,8 +15,10 @@ Auto-corrected [<%= @cop_name %>](<%= cop_url %>).
|
|
13
15
|
>
|
14
16
|
> #### Examples
|
15
17
|
<% @cop_document[:examples].each do |example| -%>
|
18
|
+
<% unless example[:name].empty? -%>
|
16
19
|
>
|
17
20
|
> <%= example[:name].strip %>
|
21
|
+
<% end -%>
|
18
22
|
>
|
19
23
|
> ```ruby
|
20
24
|
<% example[:text].each_line do |line| -%>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop_todo_corrector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- lib/rubocop_todo_corrector/cli.rb
|
76
76
|
- lib/rubocop_todo_corrector/commands.rb
|
77
77
|
- lib/rubocop_todo_corrector/commands/bundle.rb
|
78
|
+
- lib/rubocop_todo_corrector/commands/correct.rb
|
78
79
|
- lib/rubocop_todo_corrector/commands/describe.rb
|
79
80
|
- lib/rubocop_todo_corrector/commands/generate.rb
|
80
81
|
- lib/rubocop_todo_corrector/commands/pick.rb
|