rubocop-changes 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69887f58dce906adc8e7acef28816ec73fdf2900d361439662fb37c1fb78452e
4
- data.tar.gz: 9706e4fb62633c8a0d5926d343e6e803a3033e47d8b818774d67bbe32dd08ff0
3
+ metadata.gz: 4a94905b21e4303a0e32552697c0766e15aa6caedba8a96a047f5ecc5f5393fd
4
+ data.tar.gz: 98efe986e967c29ef194427f0cab777b9d611d230b1add48f44716e475d2164e
5
5
  SHA512:
6
- metadata.gz: 0dd7213e9f9ed0569573bac73c022db2245b05de28af0468a5d523824ef45f7de45e7890d0c1c67262fdc40be712bfd7f7bec4b0d605e4600a49a26b121308ea
7
- data.tar.gz: 2bc7e555c03dbf7125c60d8418a95584ec561f0d1aa178c1ff188d3edbb331a82031779e1804cbca4c7f4ab2ae5062ab953a7fd25819769aefd156e110b993a1
6
+ metadata.gz: 34ae25af5ff70f8428c54dca710d8b0e423b8f599ab4b854e73d080ccc4db008dd9a85f34feeaefa98d6c2faabb4bcef0c8ab3a30bfa371b42c1592f65779972
7
+ data.tar.gz: 392d5448f21ebe2bdf11e8b3b09bcb6d54212906bbebca4da3850efddd78e6ec3f3653b421754c9696747c76be63aeb4b75c86aa8aa60dd3bf8375c9898e6d2e
data/Gemfile.lock CHANGED
@@ -1,24 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-changes (0.3.0)
4
+ rubocop-changes (0.4.0)
5
5
  git_diff_parser (~> 3.2)
6
6
  rubocop (~> 0.80)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- ast (2.4.0)
11
+ ast (2.4.2)
12
12
  byebug (10.0.2)
13
13
  diff-lcs (1.3)
14
14
  git_diff_parser (3.2.0)
15
15
  jaro_winkler (1.5.4)
16
16
  parallel (1.19.1)
17
- parser (2.7.1.0)
18
- ast (~> 2.4.0)
17
+ parser (3.0.0.0)
18
+ ast (~> 2.4.1)
19
19
  rainbow (3.0.0)
20
- rake (10.5.0)
21
- rexml (3.2.4)
20
+ rake (13.0.3)
21
+ rexml (3.2.5)
22
22
  rspec (3.9.0)
23
23
  rspec-core (~> 3.9.0)
24
24
  rspec-expectations (~> 3.9.0)
@@ -49,9 +49,9 @@ PLATFORMS
49
49
  DEPENDENCIES
50
50
  bundler (~> 2.0)
51
51
  byebug (~> 10.0)
52
- rake (~> 10.0)
52
+ rake (~> 13.0)
53
53
  rspec (~> 3.0)
54
54
  rubocop-changes!
55
55
 
56
56
  BUNDLED WITH
57
- 2.0.2
57
+ 2.1.4
data/exe/rubocop-changes CHANGED
@@ -11,7 +11,8 @@ args = Rubocop::Changes::Options.new.parse!
11
11
  offenses = Rubocop::Changes::Checker.new(
12
12
  format: args.format,
13
13
  quiet: args.quiet,
14
- commit: args.commit
14
+ commit: args.commit,
15
+ auto_correct: args.auto_correct
15
16
  ).run
16
17
 
17
18
  exit offenses.count.positive? ? 1 : 0
@@ -13,10 +13,11 @@ module Rubocop
13
13
  class UnknownForkPointError < StandardError; end
14
14
 
15
15
  class Checker
16
- def initialize(format:, quiet:, commit:)
16
+ def initialize(format:, quiet:, commit:, auto_correct:)
17
17
  @format = format
18
18
  @quiet = quiet
19
19
  @commit = commit
20
+ @auto_correct = auto_correct
20
21
  end
21
22
 
22
23
  def run
@@ -30,7 +31,7 @@ module Rubocop
30
31
 
31
32
  private
32
33
 
33
- attr_reader :format, :quiet, :commit
34
+ attr_reader :format, :quiet, :commit, :auto_correct
34
35
 
35
36
  def fork_point
36
37
  @fork_point ||= Shell.run(command)
@@ -59,7 +60,26 @@ module Rubocop
59
60
  end
60
61
 
61
62
  def rubocop
62
- Shell.run("rubocop --force-exclusion -f j #{ruby_changed_files.join(' ')}")
63
+ shell_command = [
64
+ 'rubocop',
65
+ exclussion_modifier,
66
+ formatter_modifier,
67
+ auto_correct_modifier
68
+ ].compact.join(' ')
69
+
70
+ Shell.run(shell_command)
71
+ end
72
+
73
+ def exclussion_modifier
74
+ '--force-exclusion'
75
+ end
76
+
77
+ def formatter_modifier
78
+ "-f j #{ruby_changed_files.join(' ')}"
79
+ end
80
+
81
+ def auto_correct_modifier
82
+ '-a' if @auto_correct
63
83
  end
64
84
 
65
85
  def rubocop_json
@@ -5,10 +5,10 @@ require 'optparse'
5
5
  module Rubocop
6
6
  module Changes
7
7
  class Options
8
- Options = Struct.new(:format, :quiet, :commit)
8
+ Options = Struct.new(:format, :quiet, :commit, :auto_correct)
9
9
 
10
10
  def initialize
11
- @args = Options.new(:simple, false, nil) # Defaults
11
+ @args = Options.new(:simple, false, nil, false) # Defaults
12
12
  end
13
13
 
14
14
  def parse!
@@ -18,6 +18,7 @@ module Rubocop
18
18
  parse_formatter!(opts)
19
19
  parse_commit!(opts)
20
20
  parse_quiet!(opts)
21
+ parse_auto_correct!(opts)
21
22
  parse_help!(opts)
22
23
  parse_version!(opts)
23
24
  end.parse!
@@ -64,6 +65,12 @@ module Rubocop
64
65
  end
65
66
  end
66
67
 
68
+ def parse_auto_correct!(opts)
69
+ opts.on('-a', '--auto-correct', 'Auto correct errors') do |v|
70
+ args.auto_correct = v
71
+ end
72
+ end
73
+
67
74
  def parse_help!(opts)
68
75
  opts.on('-h', '--help', 'Prints this help') do
69
76
  puts opts
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rubocop
4
4
  module Changes
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
@@ -41,6 +41,6 @@ Gem::Specification.new do |spec|
41
41
 
42
42
  spec.add_development_dependency 'bundler', '~> 2.0'
43
43
  spec.add_development_dependency 'byebug', '~> 10.0'
44
- spec.add_development_dependency 'rake', '~> 10.0'
44
+ spec.add_development_dependency 'rake', '~> 13.0'
45
45
  spec.add_development_dependency 'rspec', '~> 3.0'
46
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-changes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ferran Basora
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-14 00:00:00.000000000 Z
11
+ date: 2021-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git_diff_parser
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement