rubocop_todo_corrector 0.10.0 → 0.12.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 +18 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/rubocop_todo_corrector/commands/generate.rb +1 -25
- data/lib/rubocop_todo_corrector/cop_document_parser.rb +29 -7
- data/lib/rubocop_todo_corrector/cop_source_detector.rb +1 -1
- data/lib/rubocop_todo_corrector/rubocop_todo_parser.rb +1 -11
- data/lib/rubocop_todo_corrector/version.rb +1 -1
- data/templates/description.md.erb +6 -0
- 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: 45d1eb10f7da8503c49e40459f9ad3634be640b16df9cd9d6d39f3a3e1201247
|
4
|
+
data.tar.gz: 6e696ba691aaa2f61946ae58f267ed5de87571199a2a6cd8e7636a7ec2d056a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c36fe6f928ecad20c2817c2bc67a232998577b77d233239f1969fccc6381938fd2c6f00453c4c727f747abb276f15ed967871bc93aa29165f1140347e0e854c1
|
7
|
+
data.tar.gz: dca597c40eed65bfcb583b6e6ad219a62b8285ad18009eeb0288a014d27957e70cecc7e0ed98ab6e959106bf9def7f11101d3362754468a789e7091b660b754b
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 0.12.0 - 2022-08-08
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- Add Safety section if `@safety` YARD tag is written in Cop class.
|
10
|
+
|
11
|
+
## 0.11.1 - 2022-08-03
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
- Fix `describe` command on more than three nested cop class.
|
16
|
+
|
17
|
+
## 0.11.0 - 2022-07-29
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
|
21
|
+
- Use `rubocop --regenerate-todo` option on `generate` command.
|
22
|
+
|
5
23
|
## 0.10.0 - 2022-07-27
|
6
24
|
|
7
25
|
### Added
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,9 @@
|
|
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
4
|
[![Gem Version](https://badge.fury.io/rb/rubocop_todo_corrector.svg)](https://rubygems.org/gems/rubocop_todo_corrector)
|
5
5
|
|
6
|
-
Auto-correct offenses defined in
|
6
|
+
Auto-correct offenses defined in `.rubocop_todo.yml`.
|
7
|
+
|
8
|
+
This is an internal implementation of [rubocop-todo-corrector](https://github.com/r7kamura/rubocop-todo-corrector) action. See its README for more information about this action.
|
7
9
|
|
8
10
|
## Installation
|
9
11
|
|
@@ -30,33 +30,9 @@ module RubocopTodoCorrector
|
|
30
30
|
def call
|
31
31
|
::Kernel.system(
|
32
32
|
{ 'BUNDLE_GEMFILE' => @temporary_gemfile_path },
|
33
|
-
|
33
|
+
'bundle exec rubocop --regenerate-todo'
|
34
34
|
)
|
35
35
|
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
# @return [String]
|
40
|
-
def rubocop_command
|
41
|
-
rubocop_command_from_todo || 'rubocop --auto-gen-config'
|
42
|
-
end
|
43
|
-
|
44
|
-
# @return [String, nil]
|
45
|
-
def rubocop_command_from_todo
|
46
|
-
return unless rubocop_todo_pathname.exist?
|
47
|
-
|
48
|
-
RubocopTodoParser.call(content: rubocop_todo_content)[:previous_rubocop_command]
|
49
|
-
end
|
50
|
-
|
51
|
-
# @return [String]
|
52
|
-
def rubocop_todo_content
|
53
|
-
rubocop_todo_pathname.read
|
54
|
-
end
|
55
|
-
|
56
|
-
# @return [Pathname]
|
57
|
-
def rubocop_todo_pathname
|
58
|
-
@rubocop_todo_pathname ||= ::Pathname.new(@rubocop_todo_path)
|
59
|
-
end
|
60
36
|
end
|
61
37
|
end
|
62
38
|
end
|
@@ -27,18 +27,40 @@ module RubocopTodoCorrector
|
|
27
27
|
return unless yard_class_object
|
28
28
|
|
29
29
|
{
|
30
|
-
description
|
31
|
-
examples
|
32
|
-
|
33
|
-
name: tag.name,
|
34
|
-
text: tag.text
|
35
|
-
}
|
36
|
-
end
|
30
|
+
description:,
|
31
|
+
examples:,
|
32
|
+
safety:
|
37
33
|
}
|
38
34
|
end
|
39
35
|
|
40
36
|
private
|
41
37
|
|
38
|
+
# @return [String]
|
39
|
+
def description
|
40
|
+
yard_class_object.docstring
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Array<Hash>]
|
44
|
+
def examples
|
45
|
+
yard_class_object.tags('example').map do |tag|
|
46
|
+
{
|
47
|
+
name: tag.name,
|
48
|
+
text: tag.text
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Hash, nil]
|
54
|
+
def safety
|
55
|
+
tag = yard_class_object.tag('safety')
|
56
|
+
return unless tag
|
57
|
+
|
58
|
+
{
|
59
|
+
name: tag.name,
|
60
|
+
text: tag.text
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
42
64
|
# @return [YARD::CodeObjects::ClassObject]
|
43
65
|
def yard_class_object
|
44
66
|
@yard_class_object ||= begin
|
@@ -27,10 +27,7 @@ module RubocopTodoCorrector
|
|
27
27
|
|
28
28
|
# @return [Hash]
|
29
29
|
def call
|
30
|
-
{
|
31
|
-
cops:,
|
32
|
-
previous_rubocop_command:
|
33
|
-
}
|
30
|
+
{ cops: }
|
34
31
|
end
|
35
32
|
|
36
33
|
private
|
@@ -42,13 +39,6 @@ module RubocopTodoCorrector
|
|
42
39
|
end
|
43
40
|
end
|
44
41
|
|
45
|
-
def previous_rubocop_command
|
46
|
-
@content[
|
47
|
-
/`(.+)`/,
|
48
|
-
1
|
49
|
-
]
|
50
|
-
end
|
51
|
-
|
52
42
|
# @return [Array<String>]
|
53
43
|
def cop_sections
|
54
44
|
@content.split("\n\n").grep(COP_NAME_LINE_REGEXP)
|
@@ -11,6 +11,12 @@ Auto-corrected [<%= @cop_name %>](<%= cop_url %>).
|
|
11
11
|
<% @cop_document[:description].each_line do |line| -%>
|
12
12
|
<%= "> #{line}".strip %>
|
13
13
|
<% end -%>
|
14
|
+
<% if @cop_document[:safety] -%>
|
15
|
+
>
|
16
|
+
> #### Safety
|
17
|
+
>
|
18
|
+
> <%= @cop_document[:safety][:text].gsub("\n", " ").strip %>
|
19
|
+
<% end -%>
|
14
20
|
<% unless @cop_document[:examples].empty? -%>
|
15
21
|
>
|
16
22
|
> #### Examples
|
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.12.0
|
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-07
|
11
|
+
date: 2022-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|