rubocop_todo_corrector 0.13.0 → 0.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rubocop_todo_corrector/commands/describe.rb +6 -1
- data/lib/rubocop_todo_corrector/cop_document_parser.rb +0 -9
- data/lib/rubocop_todo_corrector/cop_url_finder.rb +64 -0
- data/lib/rubocop_todo_corrector/description_renderer.rb +21 -17
- data/lib/rubocop_todo_corrector/version.rb +1 -1
- data/lib/rubocop_todo_corrector.rb +1 -0
- data/templates/description.md.erb +4 -8
- metadata +3 -3
- data/CHANGELOG.md +0 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dff04eb883e0fd8b45e35cf11bf14351a6e93f397e40117a87c2f8beefce2cdc
|
4
|
+
data.tar.gz: f75586ac0a17d1b025925b4faca387eca5d069b9ccf149a1d56f27da1493bede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c72738de0ffbf7845926c46950c97800bb991f24bfe032b0c6209d71a1f79ebf42967c56c907462f175cefbec631e27f16c092ce60afb4401e816a7283d50dc
|
7
|
+
data.tar.gz: 291c3db91da97dcda17875a33844643128c9bd1607957300f064d4ee3e3bb4da545d8efd0dd6e32549d1fac6d0a7094d62e1b721a40b209e1b183f7743e99851
|
data/Gemfile.lock
CHANGED
@@ -35,10 +35,15 @@ module RubocopTodoCorrector
|
|
35
35
|
cop_document = CopDocumentParser.call(source_path: cop_source_path)
|
36
36
|
return unless cop_document
|
37
37
|
|
38
|
+
cop_url = CopUrlFinder.call(
|
39
|
+
cop_name: @cop_name,
|
40
|
+
cop_source_path:,
|
41
|
+
temporary_gemfile_path: @temporary_gemfile_path
|
42
|
+
)
|
38
43
|
description = DescriptionRenderer.call(
|
39
44
|
cop_document:,
|
40
45
|
cop_name: @cop_name,
|
41
|
-
|
46
|
+
cop_url:
|
42
47
|
)
|
43
48
|
::Kernel.puts(description)
|
44
49
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'asciidoctor'
|
4
3
|
require 'yard'
|
5
4
|
|
6
5
|
module RubocopTodoCorrector
|
@@ -38,14 +37,6 @@ module RubocopTodoCorrector
|
|
38
37
|
|
39
38
|
# @return [String]
|
40
39
|
def description
|
41
|
-
::Asciidoctor.convert(
|
42
|
-
docstring,
|
43
|
-
safe: :safe
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
# @return [String]
|
48
|
-
def docstring
|
49
40
|
yard_class_object.docstring
|
50
41
|
end
|
51
42
|
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
|
5
|
+
module RubocopTodoCorrector
|
6
|
+
class CopUrlFinder
|
7
|
+
class << self
|
8
|
+
# @param [String] cop_name
|
9
|
+
# @param [String] cop_source_path
|
10
|
+
# @param [String] temporary_gemfile_path
|
11
|
+
# @return [String]
|
12
|
+
def call(
|
13
|
+
cop_name:,
|
14
|
+
cop_source_path:,
|
15
|
+
temporary_gemfile_path:
|
16
|
+
)
|
17
|
+
new(
|
18
|
+
cop_name:,
|
19
|
+
cop_source_path:,
|
20
|
+
temporary_gemfile_path:
|
21
|
+
).call
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(
|
26
|
+
cop_name:,
|
27
|
+
cop_source_path:,
|
28
|
+
temporary_gemfile_path:
|
29
|
+
)
|
30
|
+
@cop_name = cop_name
|
31
|
+
@cop_source_path = cop_source_path
|
32
|
+
@temporary_gemfile_path = temporary_gemfile_path
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String]
|
36
|
+
def call
|
37
|
+
if !captured_url.empty?
|
38
|
+
captured_url
|
39
|
+
elsif gem_name
|
40
|
+
"https://www.rubydoc.info/gems/#{gem_name}/RuboCop/Cop/#{@cop_name}"
|
41
|
+
else
|
42
|
+
"https://www.google.com/search?q=rubocop+#{::URI.encode_www_form_component(@cop_name.inspect)}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
# @return [String, nil]
|
49
|
+
def captured_url
|
50
|
+
@captured_url ||= ::Open3.capture2(
|
51
|
+
{ 'BUNDLE_GEMFILE' => @temporary_gemfile_path },
|
52
|
+
"bundle exec rubocop --show-docs-url #{@cop_name}"
|
53
|
+
).first.strip
|
54
|
+
end
|
55
|
+
|
56
|
+
# @return [String, nil]
|
57
|
+
def gem_name
|
58
|
+
@gem_name ||= @cop_source_path[
|
59
|
+
%r{/gems/([\w-]+)-\d+(?:\.\w+)*/lib},
|
60
|
+
1
|
61
|
+
]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'asciidoctor'
|
3
4
|
require 'erb'
|
5
|
+
require 'open3'
|
4
6
|
|
5
7
|
module RubocopTodoCorrector
|
6
8
|
class DescriptionRenderer
|
@@ -9,17 +11,17 @@ module RubocopTodoCorrector
|
|
9
11
|
class << self
|
10
12
|
# @param [String] cop_document
|
11
13
|
# @param [String] cop_name
|
12
|
-
# @param [String]
|
14
|
+
# @param [String] cop_url
|
13
15
|
# @return [String]
|
14
16
|
def call(
|
15
17
|
cop_document:,
|
16
18
|
cop_name:,
|
17
|
-
|
19
|
+
cop_url:
|
18
20
|
)
|
19
21
|
new(
|
20
22
|
cop_document:,
|
21
23
|
cop_name:,
|
22
|
-
|
24
|
+
cop_url:
|
23
25
|
).call
|
24
26
|
end
|
25
27
|
end
|
@@ -27,11 +29,11 @@ module RubocopTodoCorrector
|
|
27
29
|
def initialize(
|
28
30
|
cop_document:,
|
29
31
|
cop_name:,
|
30
|
-
|
32
|
+
cop_url:
|
31
33
|
)
|
32
34
|
@cop_document = cop_document
|
33
35
|
@cop_name = cop_name
|
34
|
-
@
|
36
|
+
@cop_url = cop_url
|
35
37
|
end
|
36
38
|
|
37
39
|
# @return [String]
|
@@ -41,21 +43,23 @@ module RubocopTodoCorrector
|
|
41
43
|
|
42
44
|
private
|
43
45
|
|
46
|
+
# Convert AsciiDoc to HTML.
|
47
|
+
# @param [String] string
|
44
48
|
# @return [String]
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
49
|
+
def asciidoc(string)
|
50
|
+
::Asciidoctor.convert(
|
51
|
+
string,
|
52
|
+
safe: :safe
|
53
|
+
)
|
51
54
|
end
|
52
55
|
|
53
|
-
#
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
# Prepend quote marker to each line.
|
57
|
+
# @param [String] string
|
58
|
+
# @return [String]
|
59
|
+
def quote(string)
|
60
|
+
string.each_line.map do |line|
|
61
|
+
"> #{line}".strip
|
62
|
+
end.join("\n")
|
59
63
|
end
|
60
64
|
|
61
65
|
# @return [String]
|
@@ -8,6 +8,7 @@ module RubocopTodoCorrector
|
|
8
8
|
autoload :Commands, 'rubocop_todo_corrector/commands'
|
9
9
|
autoload :CopDocumentParser, 'rubocop_todo_corrector/cop_document_parser'
|
10
10
|
autoload :CopSourceDetector, 'rubocop_todo_corrector/cop_source_detector'
|
11
|
+
autoload :CopUrlFinder, 'rubocop_todo_corrector/cop_url_finder'
|
11
12
|
autoload :DescriptionRenderer, 'rubocop_todo_corrector/description_renderer'
|
12
13
|
autoload :GemNamesDetector, 'rubocop_todo_corrector/gem_names_detector'
|
13
14
|
autoload :GemVersionDetector, 'rubocop_todo_corrector/gem_version_detector'
|
@@ -2,20 +2,18 @@ Auto-correct <%= @cop_name %>
|
|
2
2
|
|
3
3
|
## Summary
|
4
4
|
|
5
|
-
Auto-corrected [<%= @cop_name %>](<%= cop_url %>).
|
5
|
+
Auto-corrected [<%= @cop_name %>](<%= @cop_url %>).
|
6
6
|
|
7
7
|
## Details
|
8
8
|
|
9
9
|
### <%= @cop_name %>
|
10
10
|
|
11
|
-
|
12
|
-
<%= "> #{line}".strip %>
|
13
|
-
<% end -%>
|
11
|
+
<%= quote(asciidoc(@cop_document[:description])) %>
|
14
12
|
<% if @cop_document[:safety] -%>
|
15
13
|
>
|
16
14
|
> #### Safety
|
17
15
|
>
|
18
|
-
|
16
|
+
<%= quote(asciidoc(@cop_document[:safety][:text])) %>
|
19
17
|
<% end -%>
|
20
18
|
<% unless @cop_document[:examples].empty? -%>
|
21
19
|
>
|
@@ -27,9 +25,7 @@ Auto-corrected [<%= @cop_name %>](<%= cop_url %>).
|
|
27
25
|
<% end -%>
|
28
26
|
>
|
29
27
|
> ```ruby
|
30
|
-
|
31
|
-
<%= "> #{line}".strip %>
|
32
|
-
<% end -%>
|
28
|
+
<%= quote(example[:text]) %>
|
33
29
|
> ```
|
34
30
|
<% end -%>
|
35
31
|
<% 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.14.2
|
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-08-
|
11
|
+
date: 2022-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -76,7 +76,6 @@ extra_rdoc_files: []
|
|
76
76
|
files:
|
77
77
|
- ".rspec"
|
78
78
|
- ".rubocop.yml"
|
79
|
-
- CHANGELOG.md
|
80
79
|
- CODE_OF_CONDUCT.md
|
81
80
|
- Gemfile
|
82
81
|
- Gemfile.lock
|
@@ -98,6 +97,7 @@ files:
|
|
98
97
|
- lib/rubocop_todo_corrector/commands/remove.rb
|
99
98
|
- lib/rubocop_todo_corrector/cop_document_parser.rb
|
100
99
|
- lib/rubocop_todo_corrector/cop_source_detector.rb
|
100
|
+
- lib/rubocop_todo_corrector/cop_url_finder.rb
|
101
101
|
- lib/rubocop_todo_corrector/description_renderer.rb
|
102
102
|
- lib/rubocop_todo_corrector/gem_names_detector.rb
|
103
103
|
- lib/rubocop_todo_corrector/gem_version_detector.rb
|
data/CHANGELOG.md
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
## Unreleased
|
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
|
-
|
23
|
-
## 0.10.0 - 2022-07-27
|
24
|
-
|
25
|
-
### Added
|
26
|
-
|
27
|
-
- Add `ignore` command.
|
28
|
-
|
29
|
-
## 0.9.0 - 2022-07-27
|
30
|
-
|
31
|
-
### Added
|
32
|
-
|
33
|
-
- Add `.rubocop_todo_corrector_ignore` file support.
|
34
|
-
|
35
|
-
## 0.8.0 - 2022-07-23
|
36
|
-
|
37
|
-
### Added
|
38
|
-
|
39
|
-
- Add `clean` command.
|
40
|
-
|
41
|
-
## 0.7.1 - 2022-05-28
|
42
|
-
|
43
|
-
### Fixed
|
44
|
-
|
45
|
-
- Fix YARD unknown tag warning.
|
46
|
-
|
47
|
-
## 0.7.0 - 2022-05-27
|
48
|
-
|
49
|
-
### Added
|
50
|
-
|
51
|
-
- Support rubocop 1.30 .rubocop_todo.yml format.
|
52
|
-
|
53
|
-
## 0.6.0 - 2022-05-16
|
54
|
-
|
55
|
-
### Added
|
56
|
-
|
57
|
-
- Add `--only-safe` option to `correct` and `pick` command (default: `true`).
|
58
|
-
|
59
|
-
## 0.5.0 - 2022-05-16
|
60
|
-
|
61
|
-
### Changed
|
62
|
-
|
63
|
-
- Change required ruby version from 3.0 to 3.1.
|
64
|
-
|
65
|
-
## 0.4.0 - 2022-05-16
|
66
|
-
|
67
|
-
### Fixed
|
68
|
-
|
69
|
-
- Fix misspell: `occured` -> `occurred`.
|
70
|
-
|
71
|
-
## 0.3.0 - 2022-05-15
|
72
|
-
|
73
|
-
### Changed
|
74
|
-
|
75
|
-
- Change `describe` output so that commit-message-ready text is described.
|
76
|
-
|
77
|
-
## 0.2.0 - 2022-05-15
|
78
|
-
|
79
|
-
### Added
|
80
|
-
|
81
|
-
- Add `correct` command.
|
82
|
-
|
83
|
-
### Changed
|
84
|
-
|
85
|
-
- Improve description on no named example.
|
86
|
-
|
87
|
-
## 0.1.1 - 2022-05-15
|
88
|
-
|
89
|
-
### Changed
|
90
|
-
|
91
|
-
- Abort if no cop was picked on `pick` command.
|
92
|
-
|
93
|
-
### Fixed
|
94
|
-
|
95
|
-
- Fix bug that `pick` cannot find any cop on rubocop >= 1.26.
|
96
|
-
|
97
|
-
## 0.1.0 - 2022-05-15
|
98
|
-
|
99
|
-
### Added
|
100
|
-
|
101
|
-
- Initial release.
|