rubocop_todo_corrector 0.9.0 → 0.10.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: 61752242b12ed25751b22323c3c0d177acefa0d89a23146607c126c3382921e7
4
- data.tar.gz: be9d3d0f9c9428bdf7e2967a293dffe199539ea8a071545b0cbb4d914e1854c5
3
+ metadata.gz: e0b057086a834c7f6ec21014fae505b444094e01bc4556e47e91c81f387e3239
4
+ data.tar.gz: 8a56da11f2c70a840097588e539512e06edede97ba9fe185fd8df05096fa734f
5
5
  SHA512:
6
- metadata.gz: 15a1cb26be0f48eca2430c827985be3eb9426684c9123a23d8f1d7f2c379cd56fda991edf58e6e25b58f65fd769919c20cad8ac9292b9c3a7576d272bc0b29e4
7
- data.tar.gz: 3506ce4ca3b8fc368c79bd90ab6b18eb6cdabb35d6364891fc928917a5f232904cd020885915d0b2245fd720fe116f57ea7746759a9ca30b84051cc2a89e0cb3
6
+ metadata.gz: f54c8912b371c74034d95f1e46f18c07c9bc5c3544ea07ffdbd37650ac0980cfdf296485a798af14006ceaae2376c669bf53ea9dc64607402d63c91f6754a3c8
7
+ data.tar.gz: a2ffcc354d8508eb8164b1e45c4e2cd4927758f9963b900e74517a3edf523c00adb4a5235a005016ed486dddbef30be66eea7e8f129ab6496998e6775ac1e38c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.10.0 - 2022-07-27
6
+
7
+ ### Added
8
+
9
+ - Add `ignore` command.
10
+
5
11
  ## 0.9.0 - 2022-07-27
6
12
 
7
13
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop_todo_corrector (0.9.0)
4
+ rubocop_todo_corrector (0.10.0)
5
5
  bundler
6
6
  thor
7
7
  yard
data/README.md CHANGED
@@ -26,10 +26,11 @@ $ rubocop_todo_corrector
26
26
  Commands:
27
27
  rubocop_todo_corrector bundle # Run `bundle install` to install RuboCop related gems.
28
28
  rubocop_todo_corrector clean # Remove temporary files.
29
- rubocop_todo_corrector correct # Run `rubocop --auto-correct-all`.
29
+ rubocop_todo_corrector correct # Run `rubocop --auto-correct(-all)`.
30
30
  rubocop_todo_corrector describe --cop-name=COP_NAME # Output Markdown description for specified cop.
31
31
  rubocop_todo_corrector generate # Run `rubocop --auto-gen-config` to generate .rubocop_todo.yml.
32
32
  rubocop_todo_corrector help [COMMAND] # Describe available commands or one specific command
33
+ rubocop_todo_corrector ignore --cop-name=COP_NAME # Ignore specified cop by appending it to ignore file.
33
34
  rubocop_todo_corrector pick # Output an auto-correctable Cop from .rubocop_todo.yml.
34
35
  rubocop_todo_corrector remove --cop-name=COP_NAME # Remove section with specified cop name from .rubocop_todo.yml.
35
36
  ```
@@ -40,6 +41,8 @@ By specifying cop names in `.rubocop_todo_corrector_ignore`, you can exclude the
40
41
 
41
42
  ```
42
43
  Style/StringConcatenation
44
+
45
+ # Comment line is available like this.
43
46
  Style/StringLiterals
44
47
  ```
45
48
 
@@ -55,6 +55,19 @@ module RubocopTodoCorrector
55
55
  )
56
56
  end
57
57
 
58
+ desc 'ignore', 'Ignore specified cop by appending it to ignore file.'
59
+ option(
60
+ :cop_name,
61
+ type: :string,
62
+ required: true
63
+ )
64
+ def ignore
65
+ Commands::Ignore.call(
66
+ ignore_file_path: '.rubocop_todo_corrector_ignore',
67
+ cop_name: options[:cop_name]
68
+ )
69
+ end
70
+
58
71
  desc 'pick', 'Output an auto-correctable Cop from .rubocop_todo.yml.'
59
72
  option(
60
73
  :mode,
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+
5
+ module RubocopTodoCorrector
6
+ module Commands
7
+ class Ignore
8
+ class << self
9
+ # @param [String] cop_name
10
+ # @param [String] ignore_file_path
11
+ def call(
12
+ cop_name:,
13
+ ignore_file_path:
14
+ )
15
+ new(
16
+ cop_name:,
17
+ ignore_file_path:
18
+ ).call
19
+ end
20
+ end
21
+
22
+ def initialize(
23
+ cop_name:,
24
+ ignore_file_path:
25
+ )
26
+ @cop_name = cop_name
27
+ @ignore_file_path = ignore_file_path
28
+ end
29
+
30
+ def call
31
+ IgnoreFile.new(path: @ignore_file_path).append_cop_name(@cop_name)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -7,6 +7,7 @@ module RubocopTodoCorrector
7
7
  autoload :Correct, 'rubocop_todo_corrector/commands/correct'
8
8
  autoload :Describe, 'rubocop_todo_corrector/commands/describe'
9
9
  autoload :Generate, 'rubocop_todo_corrector/commands/generate'
10
+ autoload :Ignore, 'rubocop_todo_corrector/commands/ignore'
10
11
  autoload :Pick, 'rubocop_todo_corrector/commands/pick'
11
12
  autoload :Remove, 'rubocop_todo_corrector/commands/remove'
12
13
  end
@@ -9,6 +9,15 @@ module RubocopTodoCorrector
9
9
  @path = path
10
10
  end
11
11
 
12
+ # @param [String] cop_name
13
+ def append_cop_name(cop_name)
14
+ return if include?(cop_name)
15
+
16
+ appendix = "#{cop_name}\n"
17
+ appendix.prepend("\n") if !content.empty? && !content.end_with?("\n")
18
+ pathname.write("#{content}#{appendix}")
19
+ end
20
+
12
21
  # @return [Array<String>]
13
22
  def ignored_cop_names
14
23
  content.split("\n").map do |line|
@@ -27,6 +36,12 @@ module RubocopTodoCorrector
27
36
  end
28
37
  end
29
38
 
39
+ # @param [String] cop_name
40
+ # @return [Boolean]
41
+ def include?(cop_name)
42
+ ignored_cop_names.include?(cop_name)
43
+ end
44
+
30
45
  # @return [Pathname]
31
46
  def pathname
32
47
  @pathname ||= ::Pathname.new(@path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubocopTodoCorrector
4
- VERSION = '0.9.0'
4
+ VERSION = '0.10.0'
5
5
  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.9.0
4
+ version: 0.10.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-26 00:00:00.000000000 Z
11
+ date: 2022-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,6 +79,7 @@ files:
79
79
  - lib/rubocop_todo_corrector/commands/correct.rb
80
80
  - lib/rubocop_todo_corrector/commands/describe.rb
81
81
  - lib/rubocop_todo_corrector/commands/generate.rb
82
+ - lib/rubocop_todo_corrector/commands/ignore.rb
82
83
  - lib/rubocop_todo_corrector/commands/pick.rb
83
84
  - lib/rubocop_todo_corrector/commands/remove.rb
84
85
  - lib/rubocop_todo_corrector/cop_document_parser.rb