rubocop_todo_corrector 0.5.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/Gemfile.lock +1 -1
- data/README.md +10 -5
- data/lib/rubocop_todo_corrector/cli.rb +14 -2
- data/lib/rubocop_todo_corrector/commands/correct.rb +17 -1
- data/lib/rubocop_todo_corrector/commands/pick.rb +10 -1
- data/lib/rubocop_todo_corrector/cop_document_parser.rb +1 -0
- data/lib/rubocop_todo_corrector/rubocop_todo_section_parser.rb +17 -6
- data/lib/rubocop_todo_corrector/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78ebb6430a735647bdf5174b57e594385e52238e041622590771e0fe433b725f
|
4
|
+
data.tar.gz: d8bba18c545e8cae9ef03d271d432df33277e2c7ba92d578139d9425dd10cdc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3eee8ffc0e2f7df0837613b06e65231b0c7013b69dae419ec7842f92354c350a7608a8ec0f9c8ba1a757b4308c90f5f7bcbe073ab49196e91c9295e11b0bcfb8
|
7
|
+
data.tar.gz: 47e6a365002f3c8e3e551f1020647e95e2dad184c3a561685ce56667cb773c9334d0bab2d72c23f650cb849a1c3c7d831ce3fbd499ca0558373e11ebfed772aa
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 0.7.1 - 2022-05-28
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
|
9
|
+
- Fix YARD unknown tag warning.
|
10
|
+
|
11
|
+
## 0.7.0 - 2022-05-27
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
- Support rubocop 1.30 .rubocop_todo.yml format.
|
16
|
+
|
17
|
+
## 0.6.0 - 2022-05-16
|
18
|
+
|
19
|
+
### Added
|
20
|
+
|
21
|
+
- Add `--only-safe` option to `correct` and `pick` command (default: `true`).
|
22
|
+
|
5
23
|
## 0.5.0 - 2022-05-16
|
6
24
|
|
7
25
|
### Changed
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -29,7 +29,7 @@ Commands:
|
|
29
29
|
rubocop_todo_corrector describe --cop-name=COP_NAME # Output Markdown description for specified cop.
|
30
30
|
rubocop_todo_corrector generate # Run `rubocop --auto-gen-config` to generate .rubocop_todo.yml.
|
31
31
|
rubocop_todo_corrector help [COMMAND] # Describe available commands or one specific command
|
32
|
-
rubocop_todo_corrector pick #
|
32
|
+
rubocop_todo_corrector pick # Output an auto-correctable Cop from .rubocop_todo.yml.
|
33
33
|
rubocop_todo_corrector remove --cop-name=COP_NAME # Remove section with specified cop name from .rubocop_todo.yml.
|
34
34
|
```
|
35
35
|
|
@@ -46,11 +46,14 @@ Run `bundle install` to install RuboCop related gems.
|
|
46
46
|
### correct
|
47
47
|
|
48
48
|
```console
|
49
|
-
$ rubocop_todo_corrector help correct
|
50
49
|
Usage:
|
51
50
|
rubocop_todo_corrector correct
|
52
51
|
|
53
|
-
|
52
|
+
Options:
|
53
|
+
[--only-safe], [--no-only-safe]
|
54
|
+
# Default: true
|
55
|
+
|
56
|
+
Run `rubocop --auto-correct(-all)`.
|
54
57
|
```
|
55
58
|
|
56
59
|
### describe
|
@@ -85,8 +88,10 @@ Usage:
|
|
85
88
|
|
86
89
|
Options:
|
87
90
|
[--mode=MODE]
|
88
|
-
|
89
|
-
|
91
|
+
# Default: random
|
92
|
+
# Possible values: first, last, least_occurred, most_occurred, random
|
93
|
+
[--only-safe], [--no-only-safe]
|
94
|
+
# Default: true
|
90
95
|
|
91
96
|
Output an auto-correctable Cop from .rubocop_todo.yml.
|
92
97
|
```
|
@@ -14,9 +14,15 @@ module RubocopTodoCorrector
|
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
|
-
desc 'correct', 'Run `rubocop --auto-correct-all`.'
|
17
|
+
desc 'correct', 'Run `rubocop --auto-correct(-all)`.'
|
18
|
+
option(
|
19
|
+
:only_safe,
|
20
|
+
default: true,
|
21
|
+
type: :boolean
|
22
|
+
)
|
18
23
|
def correct
|
19
24
|
Commands::Correct.call(
|
25
|
+
only_safe: options[:only_safe],
|
20
26
|
temporary_gemfile_path: 'tmp/Gemfile_rubocop_todo_corrector.rb'
|
21
27
|
)
|
22
28
|
end
|
@@ -42,7 +48,7 @@ module RubocopTodoCorrector
|
|
42
48
|
)
|
43
49
|
end
|
44
50
|
|
45
|
-
desc 'pick', '
|
51
|
+
desc 'pick', 'Output an auto-correctable Cop from .rubocop_todo.yml.'
|
46
52
|
option(
|
47
53
|
:mode,
|
48
54
|
default: 'random',
|
@@ -55,9 +61,15 @@ module RubocopTodoCorrector
|
|
55
61
|
],
|
56
62
|
type: :string
|
57
63
|
)
|
64
|
+
option(
|
65
|
+
:only_safe,
|
66
|
+
default: true,
|
67
|
+
type: :boolean
|
68
|
+
)
|
58
69
|
def pick
|
59
70
|
Commands::Pick.call(
|
60
71
|
mode: options[:mode],
|
72
|
+
only_safe: options[:only_safe],
|
61
73
|
rubocop_todo_path: '.rubocop_todo.yml'
|
62
74
|
)
|
63
75
|
end
|
@@ -4,28 +4,44 @@ module RubocopTodoCorrector
|
|
4
4
|
module Commands
|
5
5
|
class Correct
|
6
6
|
class << self
|
7
|
+
# @param [Boolean] only_safe
|
7
8
|
# @param [String] temporary_gemfile_path
|
8
9
|
def call(
|
10
|
+
only_safe:,
|
9
11
|
temporary_gemfile_path:
|
10
12
|
)
|
11
13
|
new(
|
14
|
+
only_safe:,
|
12
15
|
temporary_gemfile_path:
|
13
16
|
).call
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
20
|
def initialize(
|
21
|
+
only_safe:,
|
18
22
|
temporary_gemfile_path:
|
19
23
|
)
|
24
|
+
@only_safe = only_safe
|
20
25
|
@temporary_gemfile_path = temporary_gemfile_path
|
21
26
|
end
|
22
27
|
|
23
28
|
def call
|
24
29
|
::Kernel.system(
|
25
30
|
{ 'BUNDLE_GEMFILE' => @temporary_gemfile_path },
|
26
|
-
|
31
|
+
"bundle exec rubocop #{rubocop_options}"
|
27
32
|
)
|
28
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
# @return [String]
|
38
|
+
def rubocop_options
|
39
|
+
if @only_safe
|
40
|
+
'--auto-correct'
|
41
|
+
else
|
42
|
+
'--auto-correct-all'
|
43
|
+
end
|
44
|
+
end
|
29
45
|
end
|
30
46
|
end
|
31
47
|
end
|
@@ -7,13 +7,16 @@ module RubocopTodoCorrector
|
|
7
7
|
class Pick
|
8
8
|
class << self
|
9
9
|
# @param [String] mode
|
10
|
+
# @param [Boolean] only_safe
|
10
11
|
# @param [String] rubocop_todo_path
|
11
12
|
def call(
|
12
13
|
mode:,
|
14
|
+
only_safe:,
|
13
15
|
rubocop_todo_path:
|
14
16
|
)
|
15
17
|
new(
|
16
18
|
mode:,
|
19
|
+
only_safe:,
|
17
20
|
rubocop_todo_path:
|
18
21
|
).call
|
19
22
|
end
|
@@ -21,9 +24,11 @@ module RubocopTodoCorrector
|
|
21
24
|
|
22
25
|
def initialize(
|
23
26
|
mode:,
|
27
|
+
only_safe:,
|
24
28
|
rubocop_todo_path:
|
25
29
|
)
|
26
30
|
@mode = mode
|
31
|
+
@only_safe = only_safe
|
27
32
|
@rubocop_todo_path = rubocop_todo_path
|
28
33
|
end
|
29
34
|
|
@@ -42,7 +47,11 @@ module RubocopTodoCorrector
|
|
42
47
|
# @return [Array<Hash>]
|
43
48
|
def auto_correctable_cops
|
44
49
|
rubocop_todo[:cops].select do |cop|
|
45
|
-
|
50
|
+
if @only_safe
|
51
|
+
cop[:safe_auto_correctable]
|
52
|
+
else
|
53
|
+
cop[:auto_correctable]
|
54
|
+
end
|
46
55
|
end
|
47
56
|
end
|
48
57
|
|
@@ -42,6 +42,7 @@ module RubocopTodoCorrector
|
|
42
42
|
# @return [YARD::CodeObjects::ClassObject]
|
43
43
|
def yard_class_object
|
44
44
|
@yard_class_object ||= begin
|
45
|
+
::YARD::Tags::Library.define_tag('Cop Safety Information', :safety)
|
45
46
|
::YARD.parse(@source_path)
|
46
47
|
yardoc = ::YARD::Registry.all(:class).first
|
47
48
|
::YARD::Registry.clear
|
@@ -18,19 +18,18 @@ module RubocopTodoCorrector
|
|
18
18
|
# @return [Hash]
|
19
19
|
def call
|
20
20
|
{
|
21
|
-
auto_correctable
|
21
|
+
auto_correctable:,
|
22
22
|
name:,
|
23
|
-
offenses_count
|
23
|
+
offenses_count:,
|
24
|
+
safe_auto_correctable:
|
24
25
|
}
|
25
26
|
end
|
26
27
|
|
27
28
|
private
|
28
29
|
|
29
30
|
# @return [Boolean]
|
30
|
-
def auto_correctable
|
31
|
-
|
32
|
-
@content.include?('# This cop supports safe auto-correction') ||
|
33
|
-
@content.include?('# This cop supports unsafe auto-correction')
|
31
|
+
def auto_correctable
|
32
|
+
safe_auto_correctable || unsafe_auto_correctable
|
34
33
|
end
|
35
34
|
|
36
35
|
# @return [String, nil]
|
@@ -45,5 +44,17 @@ module RubocopTodoCorrector
|
|
45
44
|
'offenses_count'
|
46
45
|
]&.to_i
|
47
46
|
end
|
47
|
+
|
48
|
+
def safe_auto_correctable
|
49
|
+
@content.include?('# Cop supports --auto-correct.') || # Before rubocop 1.26
|
50
|
+
@content.include?('# This cop supports safe auto-correction') || # Before rubocop 1.30
|
51
|
+
@content.include?('# This cop supports safe autocorrection')
|
52
|
+
end
|
53
|
+
|
54
|
+
def unsafe_auto_correctable
|
55
|
+
@content.include?('# Cop supports --auto-correct-all') ||
|
56
|
+
@content.include?('# This cop supports unsafe auto-correction') ||
|
57
|
+
@content.include?('# This cop supports unsafe autocorrection')
|
58
|
+
end
|
48
59
|
end
|
49
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|