rubocop-changes 0.7.0 → 0.8.1

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: 2d17f6a268625b8b30740a9e1409576f00374bf777632a3c1e6b068678a70d9c
4
- data.tar.gz: 16eaed76c02755b4a0239c52f36ad8c2ab7369098abd2cdf77fc7bfa8f8d13e6
3
+ metadata.gz: 50ba12f7f5d19c871a2d3ea88b3e04f08dc568e3c662d6250c32e4a524d5bf9f
4
+ data.tar.gz: c1b438aeea0f9796093617663b00c737a6bc1325fe4e0593125318de005f0422
5
5
  SHA512:
6
- metadata.gz: 7e611a8344770358d7690dc7cf58d0421b06853e696d03e0bc99ae42d6c9e3b5e24f2de7c0fef195f6fd54c14d64527cc0ba2a3190187645f713c4a6e8ef6c17
7
- data.tar.gz: 4c7b4eb56b4eaa7f7a59c5016b9e26f5d3b4d60246804a67481c94e35cdd0334f1799fc88b2cb34189a0ec8bf57a51a72940d5ca114bab95b32be33c5ade3842
6
+ metadata.gz: 598a1939a20f292b1ece470057e7ba633ce5721a3c0950efa45aef16e138fe0f89e4d4c910d46052ba51da5d13af8d64e26820a72bab55c466e491796dfc1127
7
+ data.tar.gz: 56193641cd04df8b28c120ed3bf638da9dddcaae43b8a86f3e9621d3672c4454b38307a1ffec3d9335e6baaa30b8a57c5c2ca374f339419ceb8e4ed32ce00c47
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-changes (0.7.0)
4
+ rubocop-changes (0.8.0)
5
5
  git_diff_parser (~> 3.2)
6
6
  rubocop (>= 1.0)
7
7
 
@@ -12,13 +12,13 @@ GEM
12
12
  byebug (10.0.2)
13
13
  diff-lcs (1.3)
14
14
  git_diff_parser (3.2.0)
15
- json (2.6.2)
15
+ json (2.6.3)
16
16
  parallel (1.22.1)
17
- parser (3.1.2.0)
17
+ parser (3.2.0.0)
18
18
  ast (~> 2.4.1)
19
19
  rainbow (3.1.1)
20
20
  rake (13.0.3)
21
- regexp_parser (2.5.0)
21
+ regexp_parser (2.6.2)
22
22
  rexml (3.2.5)
23
23
  rspec (3.9.0)
24
24
  rspec-core (~> 3.9.0)
@@ -33,20 +33,20 @@ GEM
33
33
  diff-lcs (>= 1.2.0, < 2.0)
34
34
  rspec-support (~> 3.9.0)
35
35
  rspec-support (3.9.0)
36
- rubocop (1.31.2)
36
+ rubocop (1.44.0)
37
37
  json (~> 2.3)
38
38
  parallel (~> 1.10)
39
- parser (>= 3.1.0.0)
39
+ parser (>= 3.2.0.0)
40
40
  rainbow (>= 2.2.2, < 4.0)
41
41
  regexp_parser (>= 1.8, < 3.0)
42
42
  rexml (>= 3.2.5, < 4.0)
43
- rubocop-ast (>= 1.18.0, < 2.0)
43
+ rubocop-ast (>= 1.24.1, < 2.0)
44
44
  ruby-progressbar (~> 1.7)
45
- unicode-display_width (>= 1.4.0, < 3.0)
46
- rubocop-ast (1.19.1)
45
+ unicode-display_width (>= 2.4.0, < 3.0)
46
+ rubocop-ast (1.24.1)
47
47
  parser (>= 3.1.1.0)
48
48
  ruby-progressbar (1.11.0)
49
- unicode-display_width (2.2.0)
49
+ unicode-display_width (2.4.2)
50
50
 
51
51
  PLATFORMS
52
52
  ruby
data/README.md CHANGED
@@ -32,7 +32,9 @@ Or install it yourself as:
32
32
 
33
33
  ## Usage
34
34
 
35
- $ bundle exec rubocop-changes
35
+ $ bundle exec rubocop-changes -b master
36
+
37
+ When you run `rubocop-changes`, you have to specify which is your base branch with `-b` argument. By default is `main`. If you want to avoid to pass this argument everytime you execute this command, you can also set the `RUBOCOP_CHANGES_BASE_BRANCH` environment variable.
36
38
 
37
39
  ## Other gems
38
40
 
@@ -36,6 +36,15 @@ module Rubocop
36
36
 
37
37
  attr_reader :format, :quiet, :commit, :auto_correct, :base_branch
38
38
 
39
+ def path_prefix
40
+ return @path_prefix if defined?(@path_prefix)
41
+ @path_prefix = local_git_root_path && Dir.pwd.gsub(local_git_root_path, '')[1..-1]
42
+ end
43
+
44
+ def local_git_root_path
45
+ @local_git_root_path ||= Shell.run("git rev-parse --show-toplevel")
46
+ end
47
+
39
48
  def fork_point
40
49
  @fork_point ||= Shell.run(command)
41
50
  end
@@ -59,7 +68,13 @@ module Rubocop
59
68
  end
60
69
 
61
70
  def ruby_changed_files
62
- changed_files.select { |changed_file| changed_file =~ /.rb$/ }
71
+ changed_files.select { |changed_file| changed_file =~ /\.rb$/ }
72
+ end
73
+
74
+ def ruby_changed_files_from_pwd
75
+ ruby_changed_files.map do |path|
76
+ from_pwd_path(path)
77
+ end
63
78
  end
64
79
 
65
80
  def rubocop
@@ -78,11 +93,11 @@ module Rubocop
78
93
  end
79
94
 
80
95
  def formatter_modifier
81
- "-f j #{ruby_changed_files.join(' ')}"
96
+ "-f j #{ruby_changed_files_from_pwd.join(' ')}"
82
97
  end
83
98
 
84
99
  def auto_correct_modifier
85
- '-a' if @auto_correct
100
+ '-A' if @auto_correct
86
101
  end
87
102
 
88
103
  def rubocop_json
@@ -91,7 +106,7 @@ module Rubocop
91
106
 
92
107
  def checks
93
108
  @checks ||= ruby_changed_files.map do |file|
94
- analysis = rubocop_json.files.find { |item| item.path == file }
109
+ analysis = rubocop_json.files.find { |item| item.path == from_pwd_path(file) }
95
110
  patch = patches.find { |item| item.file == file }
96
111
 
97
112
  next unless analysis
@@ -150,6 +165,14 @@ module Rubocop
150
165
 
151
166
  formatter.file_finished(check.path, offenses)
152
167
  end
168
+
169
+ def from_pwd_path(path)
170
+ if path_prefix
171
+ path.gsub(/^#{path_prefix}\//, '')
172
+ else
173
+ path
174
+ end
175
+ end
153
176
  end
154
177
  end
155
178
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rubocop
4
4
  module Changes
5
- VERSION = '0.7.0'
5
+ VERSION = '0.8.1'
6
6
  end
7
7
  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.7.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ferran Basora
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-20 00:00:00.000000000 Z
11
+ date: 2023-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git_diff_parser