rubocop_todo_corrector 0.13.0 → 0.14.0

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: 3e370ea5e7275cba3675a1e5ebae1aababaddb87917bb7ac5507efb6b3e5fb79
4
- data.tar.gz: 5a235861dbdf945bf4fd1a3c271cedb2f08e76397706d2f48e16adec0e94e8a4
3
+ metadata.gz: 7c875171ee57cc0510b2bc3eeee96c57155f4380fad714346f02089e726a7e05
4
+ data.tar.gz: 10b096061782d6a714ec7a740c8bf75dff966c9a6e175fe76847c6203dd26f19
5
5
  SHA512:
6
- metadata.gz: 55cd6960281b726f3cd5ab258d112c2fbbe8d589fd57045ce1186b06af17502883a591709fcc40f7ac773b785f05a01784a35f6a641d21de01f6334d0cef829a
7
- data.tar.gz: a05b1ca686adb83f7eae952c0357109b0f18973f0e85965468518264b89b1a531a071d387a7209226837f66abef89680c2b43fac90daa1aa181f2cd63fae6da1
6
+ metadata.gz: 1a1d903624ee552a520d9aafad408520ba3d059705fb0368f4abb3a11920f8b5ac48002bca0e3e98f41897b7c46d62aca06397f3e983dbc989d362d880e7be9e
7
+ data.tar.gz: 1f1413ba984a873283d92c3679576e9d8c6072f0456b4f8fc42ad7b03c88c83aa2cd019bb67254ccde8d5fa8dbc3ce529c683976d7e7c07b8e675d76966b448f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop_todo_corrector (0.13.0)
4
+ rubocop_todo_corrector (0.14.0)
5
5
  asciidoctor
6
6
  bundler
7
7
  thor
@@ -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
- 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
- ]
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]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubocopTodoCorrector
4
- VERSION = '0.13.0'
4
+ VERSION = '0.14.0'
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'
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.13.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-12 00:00:00.000000000 Z
11
+ date: 2022-08-15 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.