rubocop_todo_corrector 0.12.0 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45d1eb10f7da8503c49e40459f9ad3634be640b16df9cd9d6d39f3a3e1201247
4
- data.tar.gz: 6e696ba691aaa2f61946ae58f267ed5de87571199a2a6cd8e7636a7ec2d056a1
3
+ metadata.gz: 6de4f9dc6b91ba8fbf73c74704955b28807dc370aada671af16f689de690f4a4
4
+ data.tar.gz: 4ec7f847e031075fc4ac31928a28036d14777773d8cb1352a851bb68f20c6951
5
5
  SHA512:
6
- metadata.gz: c36fe6f928ecad20c2817c2bc67a232998577b77d233239f1969fccc6381938fd2c6f00453c4c727f747abb276f15ed967871bc93aa29165f1140347e0e854c1
7
- data.tar.gz: dca597c40eed65bfcb583b6e6ad219a62b8285ad18009eeb0288a014d27957e70cecc7e0ed98ab6e959106bf9def7f11101d3362754468a789e7091b660b754b
6
+ metadata.gz: 8a20c4c0b46c8806fa47e5f53ab9ffe1862a8544be737dbae29f3343f4d254e63f8ba43aa89e8ac8d8bcc50cde1f29c56bcf10f7153a6e49a76078f57f5c32ff
7
+ data.tar.gz: 7a95a3f15eb5f3a368a9b9fc1bc5b5faa9c2837fa54e6631bf096eb767b92a71119aec305cd08465c4fa371598cfc0fc2410262bc993dc27e4957c623e4ddb16
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop_todo_corrector (0.12.0)
4
+ rubocop_todo_corrector (0.14.1)
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)
@@ -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
- cop_source_path:
46
+ cop_url:
42
47
  )
43
48
  ::Kernel.puts(description)
44
49
  end
@@ -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
@@ -37,6 +38,14 @@ module RubocopTodoCorrector
37
38
 
38
39
  # @return [String]
39
40
  def description
41
+ ::Asciidoctor.convert(
42
+ docstring,
43
+ safe: :safe
44
+ )
45
+ end
46
+
47
+ # @return [String]
48
+ def docstring
40
49
  yard_class_object.docstring
41
50
  end
42
51
 
@@ -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
@@ -9,17 +10,17 @@ module RubocopTodoCorrector
9
10
  class << self
10
11
  # @param [String] cop_document
11
12
  # @param [String] cop_name
12
- # @param [String] cop_source_path
13
+ # @param [String] cop_url
13
14
  # @return [String]
14
15
  def call(
15
16
  cop_document:,
16
17
  cop_name:,
17
- cop_source_path:
18
+ cop_url:
18
19
  )
19
20
  new(
20
21
  cop_document:,
21
22
  cop_name:,
22
- cop_source_path:
23
+ cop_url:
23
24
  ).call
24
25
  end
25
26
  end
@@ -27,11 +28,11 @@ module RubocopTodoCorrector
27
28
  def initialize(
28
29
  cop_document:,
29
30
  cop_name:,
30
- cop_source_path:
31
+ cop_url:
31
32
  )
32
33
  @cop_document = cop_document
33
34
  @cop_name = cop_name
34
- @cop_source_path = cop_source_path
35
+ @cop_url = cop_url
35
36
  end
36
37
 
37
38
  # @return [String]
@@ -41,23 +42,6 @@ module RubocopTodoCorrector
41
42
 
42
43
  private
43
44
 
44
- # @return [String]
45
- def cop_url
46
- if gem_name
47
- "https://www.rubydoc.info/gems/#{gem_name}/RuboCop/Cop/#{@cop_name}"
48
- else
49
- "https://www.google.com/search?q=rubocop+#{::URI.encode_www_form_component(@cop_name.inspect)}"
50
- end
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
- ]
59
- end
60
-
61
45
  # @return [String]
62
46
  def template_content
63
47
  ::File.read(TEMPLATE_PATH)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubocopTodoCorrector
4
- VERSION = '0.12.0'
4
+ VERSION = '0.14.1'
5
5
  end
@@ -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'
@@ -2,7 +2,7 @@ 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
 
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.12.0
4
+ version: 0.14.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-08-07 00:00:00.000000000 Z
11
+ date: 2022-08-17 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,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.