rubocop_todo_corrector 0.11.1 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/lib/rubocop_todo_corrector/cop_document_parser.rb +38 -7
- data/lib/rubocop_todo_corrector/cop_url_finder.rb +64 -0
- data/lib/rubocop_todo_corrector/description_renderer.rb +6 -13
- data/lib/rubocop_todo_corrector/version.rb +1 -1
- data/lib/rubocop_todo_corrector.rb +1 -0
- data/rubocop_todo_corrector.gemspec +1 -0
- data/templates/description.md.erb +6 -0
- metadata +17 -3
- data/CHANGELOG.md +0 -95
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c875171ee57cc0510b2bc3eeee96c57155f4380fad714346f02089e726a7e05
|
4
|
+
data.tar.gz: 10b096061782d6a714ec7a740c8bf75dff966c9a6e175fe76847c6203dd26f19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a1d903624ee552a520d9aafad408520ba3d059705fb0368f4abb3a11920f8b5ac48002bca0e3e98f41897b7c46d62aca06397f3e983dbc989d362d880e7be9e
|
7
|
+
data.tar.gz: 1f1413ba984a873283d92c3679576e9d8c6072f0456b4f8fc42ad7b03c88c83aa2cd019bb67254ccde8d5fa8dbc3ce529c683976d7e7c07b8e675d76966b448f
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubocop_todo_corrector (0.
|
4
|
+
rubocop_todo_corrector (0.14.0)
|
5
|
+
asciidoctor
|
5
6
|
bundler
|
6
7
|
thor
|
7
8
|
yard
|
@@ -9,6 +10,7 @@ PATH
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
13
|
+
asciidoctor (2.0.17)
|
12
14
|
ast (2.4.2)
|
13
15
|
diff-lcs (1.5.0)
|
14
16
|
parallel (1.22.1)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'asciidoctor'
|
3
4
|
require 'yard'
|
4
5
|
|
5
6
|
module RubocopTodoCorrector
|
@@ -27,18 +28,48 @@ module RubocopTodoCorrector
|
|
27
28
|
return unless yard_class_object
|
28
29
|
|
29
30
|
{
|
30
|
-
description
|
31
|
-
examples
|
32
|
-
|
33
|
-
name: tag.name,
|
34
|
-
text: tag.text
|
35
|
-
}
|
36
|
-
end
|
31
|
+
description:,
|
32
|
+
examples:,
|
33
|
+
safety:
|
37
34
|
}
|
38
35
|
end
|
39
36
|
|
40
37
|
private
|
41
38
|
|
39
|
+
# @return [String]
|
40
|
+
def description
|
41
|
+
::Asciidoctor.convert(
|
42
|
+
docstring,
|
43
|
+
safe: :safe
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [String]
|
48
|
+
def docstring
|
49
|
+
yard_class_object.docstring
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [Array<Hash>]
|
53
|
+
def examples
|
54
|
+
yard_class_object.tags('example').map do |tag|
|
55
|
+
{
|
56
|
+
name: tag.name,
|
57
|
+
text: tag.text
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [Hash, nil]
|
63
|
+
def safety
|
64
|
+
tag = yard_class_object.tag('safety')
|
65
|
+
return unless tag
|
66
|
+
|
67
|
+
{
|
68
|
+
name: tag.name,
|
69
|
+
text: tag.text
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
42
73
|
# @return [YARD::CodeObjects::ClassObject]
|
43
74
|
def yard_class_object
|
44
75
|
@yard_class_object ||= begin
|
@@ -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,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'erb'
|
4
|
+
require 'open3'
|
4
5
|
|
5
6
|
module RubocopTodoCorrector
|
6
7
|
class DescriptionRenderer
|
@@ -43,19 +44,11 @@ module RubocopTodoCorrector
|
|
43
44
|
|
44
45
|
# @return [String]
|
45
46
|
def cop_url
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
# @return [String, nil]
|
54
|
-
def gem_name
|
55
|
-
@gem_name ||= @cop_source_path[
|
56
|
-
%r{/gems/([\w-]+)-\d+(?:\.\w+)*/lib},
|
57
|
-
1
|
58
|
-
]
|
47
|
+
CopUrlFinder.call(
|
48
|
+
cop_name: @cop_name,
|
49
|
+
cop_source_path: @cop_source_path,
|
50
|
+
temporary_gemfile_path: @temporary_gemfile_path
|
51
|
+
)
|
59
52
|
end
|
60
53
|
|
61
54
|
# @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'
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ['lib']
|
31
31
|
|
32
|
+
spec.add_dependency 'asciidoctor'
|
32
33
|
spec.add_dependency 'bundler'
|
33
34
|
spec.add_dependency 'thor'
|
34
35
|
spec.add_dependency 'yard'
|
@@ -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,15 +1,29 @@
|
|
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.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-08-
|
11
|
+
date: 2022-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: asciidoctor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,7 +76,6 @@ extra_rdoc_files: []
|
|
62
76
|
files:
|
63
77
|
- ".rspec"
|
64
78
|
- ".rubocop.yml"
|
65
|
-
- CHANGELOG.md
|
66
79
|
- CODE_OF_CONDUCT.md
|
67
80
|
- Gemfile
|
68
81
|
- Gemfile.lock
|
@@ -84,6 +97,7 @@ files:
|
|
84
97
|
- lib/rubocop_todo_corrector/commands/remove.rb
|
85
98
|
- lib/rubocop_todo_corrector/cop_document_parser.rb
|
86
99
|
- lib/rubocop_todo_corrector/cop_source_detector.rb
|
100
|
+
- lib/rubocop_todo_corrector/cop_url_finder.rb
|
87
101
|
- lib/rubocop_todo_corrector/description_renderer.rb
|
88
102
|
- lib/rubocop_todo_corrector/gem_names_detector.rb
|
89
103
|
- lib/rubocop_todo_corrector/gem_version_detector.rb
|
data/CHANGELOG.md
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
## Unreleased
|
4
|
-
|
5
|
-
## 0.11.1 - 2022-08-03
|
6
|
-
|
7
|
-
### Fixed
|
8
|
-
|
9
|
-
- Fix `describe` command on more than three nested cop class.
|
10
|
-
|
11
|
-
## 0.11.0 - 2022-07-29
|
12
|
-
|
13
|
-
### Changed
|
14
|
-
|
15
|
-
- Use `rubocop --regenerate-todo` option on `generate` command.
|
16
|
-
|
17
|
-
## 0.10.0 - 2022-07-27
|
18
|
-
|
19
|
-
### Added
|
20
|
-
|
21
|
-
- Add `ignore` command.
|
22
|
-
|
23
|
-
## 0.9.0 - 2022-07-27
|
24
|
-
|
25
|
-
### Added
|
26
|
-
|
27
|
-
- Add `.rubocop_todo_corrector_ignore` file support.
|
28
|
-
|
29
|
-
## 0.8.0 - 2022-07-23
|
30
|
-
|
31
|
-
### Added
|
32
|
-
|
33
|
-
- Add `clean` command.
|
34
|
-
|
35
|
-
## 0.7.1 - 2022-05-28
|
36
|
-
|
37
|
-
### Fixed
|
38
|
-
|
39
|
-
- Fix YARD unknown tag warning.
|
40
|
-
|
41
|
-
## 0.7.0 - 2022-05-27
|
42
|
-
|
43
|
-
### Added
|
44
|
-
|
45
|
-
- Support rubocop 1.30 .rubocop_todo.yml format.
|
46
|
-
|
47
|
-
## 0.6.0 - 2022-05-16
|
48
|
-
|
49
|
-
### Added
|
50
|
-
|
51
|
-
- Add `--only-safe` option to `correct` and `pick` command (default: `true`).
|
52
|
-
|
53
|
-
## 0.5.0 - 2022-05-16
|
54
|
-
|
55
|
-
### Changed
|
56
|
-
|
57
|
-
- Change required ruby version from 3.0 to 3.1.
|
58
|
-
|
59
|
-
## 0.4.0 - 2022-05-16
|
60
|
-
|
61
|
-
### Fixed
|
62
|
-
|
63
|
-
- Fix misspell: `occured` -> `occurred`.
|
64
|
-
|
65
|
-
## 0.3.0 - 2022-05-15
|
66
|
-
|
67
|
-
### Changed
|
68
|
-
|
69
|
-
- Change `describe` output so that commit-message-ready text is described.
|
70
|
-
|
71
|
-
## 0.2.0 - 2022-05-15
|
72
|
-
|
73
|
-
### Added
|
74
|
-
|
75
|
-
- Add `correct` command.
|
76
|
-
|
77
|
-
### Changed
|
78
|
-
|
79
|
-
- Improve description on no named example.
|
80
|
-
|
81
|
-
## 0.1.1 - 2022-05-15
|
82
|
-
|
83
|
-
### Changed
|
84
|
-
|
85
|
-
- Abort if no cop was picked on `pick` command.
|
86
|
-
|
87
|
-
### Fixed
|
88
|
-
|
89
|
-
- Fix bug that `pick` cannot find any cop on rubocop >= 1.26.
|
90
|
-
|
91
|
-
## 0.1.0 - 2022-05-15
|
92
|
-
|
93
|
-
### Added
|
94
|
-
|
95
|
-
- Initial release.
|