rubocop_todo_corrector 0.1.0 → 0.3.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 +27 -1
- data/Gemfile.lock +1 -1
- data/README.md +12 -0
- data/lib/rubocop_todo_corrector/cli.rb +7 -0
- 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 +5 -1
- 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/rubocop_todo_section_parser.rb +3 -3
- 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: ff46eb10969e63064eaf439a4879103de5ea54ae8db44c7c185cb939e3d4b2fd
|
4
|
+
data.tar.gz: d1b4762bf9bdf6c98fb76311c5389b0175f39434c0f0ccfe8dc8ea4dcbecc3c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6290910045e5aa18a0c7e5689949836f687fb4d7fcd765769450d5a4c33d63476b99d9f2687be6bac7720cf13cc777b400e913f2f41d17a3fefc866eb70d6829
|
7
|
+
data.tar.gz: d739558dfa006d7110f36b9289505911cabbe9c500c00fb990781d04a9856a25db11910c1eae0fc9a8145e1e45955784b8a05f0706af710b106e4a35d5ba409a
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,33 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
-
## 0.
|
5
|
+
## 0.3.0 - 2022-05-15
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
- Change `describe` output so that commit-message-ready text is described.
|
10
|
+
|
11
|
+
## 0.2.0 - 2022-05-15
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
- Add `correct` command.
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
19
|
+
- Improve description on no named example.
|
20
|
+
|
21
|
+
## 0.1.1 - 2022-05-15
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Abort if no cop was picked on `pick` command.
|
26
|
+
|
27
|
+
### Fixed
|
28
|
+
|
29
|
+
- Fix bug that `pick` cannot find any cop on rubocop >= 1.26.
|
30
|
+
|
31
|
+
## 0.1.0 - 2022-05-15
|
6
32
|
|
7
33
|
### Added
|
8
34
|
|
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
|
@@ -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,
|
@@ -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
|
@@ -30,7 +30,11 @@ module RubocopTodoCorrector
|
|
30
30
|
def call
|
31
31
|
check_rubocop_todo_existence
|
32
32
|
cop_name = picked_cop&.[](:name)
|
33
|
-
|
33
|
+
if cop_name
|
34
|
+
::Kernel.puts(cop_name)
|
35
|
+
else
|
36
|
+
::Kernel.abort('No cop was picked.')
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
40
|
private
|
@@ -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'
|
@@ -28,9 +28,9 @@ module RubocopTodoCorrector
|
|
28
28
|
|
29
29
|
# @return [Boolean]
|
30
30
|
def auto_correctable?
|
31
|
-
@content.include?('# Cop supports --auto-correct
|
32
|
-
@content.include?('#
|
33
|
-
@content.include?('#
|
31
|
+
@content.include?('# Cop supports --auto-correct') ||
|
32
|
+
@content.include?('# This cop supports safe auto-correction') ||
|
33
|
+
@content.include?('# This cop supports unsafe auto-correction')
|
34
34
|
end
|
35
35
|
|
36
36
|
# @return [String, nil]
|
@@ -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.3.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
|