rubocop-changes 0.7.0 → 0.8.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: 2d17f6a268625b8b30740a9e1409576f00374bf777632a3c1e6b068678a70d9c
4
- data.tar.gz: 16eaed76c02755b4a0239c52f36ad8c2ab7369098abd2cdf77fc7bfa8f8d13e6
3
+ metadata.gz: '09daace2e31cf1451cba68fe23ac1c6ab439f281b23d1634c004fe316b67cd8e'
4
+ data.tar.gz: dc982a2074301f56ad4658c97cd09b9e2f657498476d52c60d2bea242f60b32e
5
5
  SHA512:
6
- metadata.gz: 7e611a8344770358d7690dc7cf58d0421b06853e696d03e0bc99ae42d6c9e3b5e24f2de7c0fef195f6fd54c14d64527cc0ba2a3190187645f713c4a6e8ef6c17
7
- data.tar.gz: 4c7b4eb56b4eaa7f7a59c5016b9e26f5d3b4d60246804a67481c94e35cdd0334f1799fc88b2cb34189a0ec8bf57a51a72940d5ca114bab95b32be33c5ade3842
6
+ metadata.gz: cc9ccaf62d221526a6405f8e57a8b4c7b5ede8963a43b5793ab4013914da4eca6535f4c00c55d32038dddde15e7966f5e7c280615ab8900f57fdfb308db19f2c
7
+ data.tar.gz: a1d648e0776098ceb27e23d0f3efb6742d7b71fef4cfb28e628e8e0f9f4cd5d64daf829a8782196306519322cba50afa6c2c2585c896612595674b2f85e6565a
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,17 @@ 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
+ if path_prefix
77
+ path.gsub(/^#{path_prefix}\//, '')
78
+ else
79
+ path
80
+ end
81
+ end
63
82
  end
64
83
 
65
84
  def rubocop
@@ -78,11 +97,11 @@ module Rubocop
78
97
  end
79
98
 
80
99
  def formatter_modifier
81
- "-f j #{ruby_changed_files.join(' ')}"
100
+ "-f j #{ruby_changed_files_from_pwd.join(' ')}"
82
101
  end
83
102
 
84
103
  def auto_correct_modifier
85
- '-a' if @auto_correct
104
+ '-A' if @auto_correct
86
105
  end
87
106
 
88
107
  def rubocop_json
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rubocop
4
4
  module Changes
5
- VERSION = '0.7.0'
5
+ VERSION = '0.8.0'
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.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: 2022-07-20 00:00:00.000000000 Z
11
+ date: 2023-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git_diff_parser