rubocop-changes 0.3.0 → 0.6.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: 69887f58dce906adc8e7acef28816ec73fdf2900d361439662fb37c1fb78452e
4
- data.tar.gz: 9706e4fb62633c8a0d5926d343e6e803a3033e47d8b818774d67bbe32dd08ff0
3
+ metadata.gz: ee87c885eb2498625bb6f9fc0a59719cbd1c59d71419fd32e1fc3128aa201ce0
4
+ data.tar.gz: 947199d33a4427840836b901f780661b98f32428ac6aaaae8012c5cf449e4a48
5
5
  SHA512:
6
- metadata.gz: 0dd7213e9f9ed0569573bac73c022db2245b05de28af0468a5d523824ef45f7de45e7890d0c1c67262fdc40be712bfd7f7bec4b0d605e4600a49a26b121308ea
7
- data.tar.gz: 2bc7e555c03dbf7125c60d8418a95584ec561f0d1aa178c1ff188d3edbb331a82031779e1804cbca4c7f4ab2ae5062ab953a7fd25819769aefd156e110b993a1
6
+ metadata.gz: 6eb29fc5b10fcdcbbb9966d5d287459def271a9ac1d593e81d227c7c1e78fb15e1a74018e93c6fd6251d24d4037da6df7b6a5c1b7e862fabaf56a7cfd70368e6
7
+ data.tar.gz: e43732b83c2f830f69fa795ac96d6c80bce7c1f48e0e54c9a4e076fc1614056b264268241dd9deee99a1520b99f97219c005cb6a60ec90c09bbb8be1b4423d01
@@ -0,0 +1,23 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby: ["2.5", "2.6", "2.7", "3.0", "3.1", ruby-head]
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ bundler-cache: true # 'bundle install' and cache gems
21
+ ruby-version: ${{ matrix.ruby }}
22
+ - name: Run tests
23
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -10,3 +10,6 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
  .byebug_history
13
+
14
+ *.gem
15
+ .idea
data/.rubocop.yml CHANGED
@@ -1,3 +1,7 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ NewCops: disable
4
+
1
5
  Lint/RaiseException:
2
6
  Enabled: false
3
7
 
@@ -16,5 +20,8 @@ Style/HashTransformValues:
16
20
  Style/Documentation:
17
21
  Enabled: false
18
22
 
23
+ Style/FrozenStringLiteralComment:
24
+ Enabled: false
25
+
19
26
  Layout/LineLength:
20
27
  Max: 120
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rubocop-changes.gemspec
4
4
  gemspec
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.5.0)
5
5
  git_diff_parser (~> 3.2)
6
- rubocop (~> 0.80)
6
+ rubocop (~> 1.25)
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
- jaro_winkler (1.5.4)
16
- parallel (1.19.1)
17
- parser (2.7.1.0)
18
- ast (~> 2.4.0)
19
- rainbow (3.0.0)
20
- rake (10.5.0)
21
- rexml (3.2.4)
15
+ parallel (1.21.0)
16
+ parser (3.1.0.0)
17
+ ast (~> 2.4.1)
18
+ rainbow (3.1.1)
19
+ rake (13.0.3)
20
+ regexp_parser (2.2.0)
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)
@@ -32,16 +32,19 @@ GEM
32
32
  diff-lcs (>= 1.2.0, < 2.0)
33
33
  rspec-support (~> 3.9.0)
34
34
  rspec-support (3.9.0)
35
- rubocop (0.81.0)
36
- jaro_winkler (~> 1.5.1)
35
+ rubocop (1.25.0)
37
36
  parallel (~> 1.10)
38
- parser (>= 2.7.0.1)
37
+ parser (>= 3.1.0.0)
39
38
  rainbow (>= 2.2.2, < 4.0)
39
+ regexp_parser (>= 1.8, < 3.0)
40
40
  rexml
41
+ rubocop-ast (>= 1.15.1, < 2.0)
41
42
  ruby-progressbar (~> 1.7)
42
- unicode-display_width (>= 1.4.0, < 2.0)
43
- ruby-progressbar (1.10.1)
44
- unicode-display_width (1.7.0)
43
+ unicode-display_width (>= 1.4.0, < 3.0)
44
+ rubocop-ast (1.15.1)
45
+ parser (>= 3.0.1.1)
46
+ ruby-progressbar (1.11.0)
47
+ unicode-display_width (2.1.0)
45
48
 
46
49
  PLATFORMS
47
50
  ruby
@@ -49,9 +52,9 @@ PLATFORMS
49
52
  DEPENDENCIES
50
53
  bundler (~> 2.0)
51
54
  byebug (~> 10.0)
52
- rake (~> 10.0)
55
+ rake (~> 13.0)
53
56
  rspec (~> 3.0)
54
57
  rubocop-changes!
55
58
 
56
59
  BUNDLED WITH
57
- 2.0.2
60
+ 2.1.4
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Rubocop::Changes
2
2
 
3
3
  [![Gem Version](https://img.shields.io/gem/v/rubocop-changes)](https://rubygems.org/gems/rubocop-changes)
4
- [![Build Status](https://img.shields.io/travis/com/fcsonline/rubocop-changes/master)](https://travis-ci.com/fcsonline/rubocop-changes)
4
+ [![Build Status](https://github.com/fcsonline/rubocop-changes/actions/workflows/ci.yml/badge.svg)](https://github.com/fcsonline/rubocop-changes/actions/workflows/ci.yml)
5
5
 
6
6
  `rubocop-changes` runs rubocop and shows only the offenses you introduced since
7
7
  the fork point of your git branch. Will not complain about existing offenses in
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "rubocop/changes"
3
+ require 'bundler/setup'
4
+ require 'rubocop/changes'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "rubocop/changes"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
data/exe/rubocop-changes CHANGED
@@ -11,7 +11,9 @@ 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,
16
+ base_branch: args.base_branch
15
17
  ).run
16
18
 
17
19
  exit offenses.count.positive? ? 1 : 0
@@ -13,10 +13,12 @@ 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:, base_branch:)
17
17
  @format = format
18
18
  @quiet = quiet
19
19
  @commit = commit
20
+ @auto_correct = auto_correct
21
+ @base_branch = base_branch
20
22
  end
21
23
 
22
24
  def run
@@ -30,14 +32,14 @@ module Rubocop
30
32
 
31
33
  private
32
34
 
33
- attr_reader :format, :quiet, :commit
35
+ attr_reader :format, :quiet, :commit, :auto_correct
34
36
 
35
37
  def fork_point
36
38
  @fork_point ||= Shell.run(command)
37
39
  end
38
40
 
39
41
  def command
40
- return 'git merge-base HEAD origin/master' unless commit
42
+ return "git merge-base HEAD origin/#{@base_branch}" unless commit
41
43
 
42
44
  "git log -n 1 --pretty=format:\"%h\" #{commit}"
43
45
  end
@@ -59,7 +61,26 @@ module Rubocop
59
61
  end
60
62
 
61
63
  def rubocop
62
- Shell.run("rubocop --force-exclusion -f j #{ruby_changed_files.join(' ')}")
64
+ shell_command = [
65
+ 'rubocop',
66
+ exclussion_modifier,
67
+ formatter_modifier,
68
+ auto_correct_modifier
69
+ ].compact.join(' ')
70
+
71
+ Shell.run(shell_command)
72
+ end
73
+
74
+ def exclussion_modifier
75
+ '--force-exclusion'
76
+ end
77
+
78
+ def formatter_modifier
79
+ "-f j #{ruby_changed_files.join(' ')}"
80
+ end
81
+
82
+ def auto_correct_modifier
83
+ '-a' if @auto_correct
63
84
  end
64
85
 
65
86
  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, :base_branch)
9
9
 
10
10
  def initialize
11
- @args = Options.new(:simple, false, nil) # Defaults
11
+ @args = Options.new(:simple, false, nil, false, 'main') # Defaults
12
12
  end
13
13
 
14
14
  def parse!
@@ -18,8 +18,10 @@ 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)
24
+ parse_base_branch!(opts)
23
25
  end.parse!
24
26
 
25
27
  args
@@ -64,6 +66,18 @@ module Rubocop
64
66
  end
65
67
  end
66
68
 
69
+ def parse_auto_correct!(opts)
70
+ opts.on('-a', '--auto-correct', 'Auto correct errors') do |v|
71
+ args.auto_correct = v
72
+ end
73
+ end
74
+
75
+ def parse_base_branch!(opts)
76
+ opts.on('-b', '--base_branch [BRANCH]', 'Base branch to compare') do |v|
77
+ args.base_branch = v
78
+ end
79
+ end
80
+
67
81
  def parse_help!(opts)
68
82
  opts.on('-h', '--help', 'Prints this help') do
69
83
  puts opts
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rubocop
4
4
  module Changes
5
- VERSION = '0.3.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.name = 'rubocop-changes'
7
7
  spec.version = Rubocop::Changes::VERSION
8
8
  spec.platform = Gem::Platform::RUBY
9
- spec.required_ruby_version = '>= 2.3.0'
9
+ spec.required_ruby_version = '>= 2.5.0'
10
10
  spec.authors = ['Ferran Basora']
11
11
  spec.email = ['fcsonline@gmail.com']
12
12
 
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  # Specify which files should be added to the gem when it is released.
29
29
  # The `git ls-files -z` loads the files in the RubyGem that have been added
30
30
  # into git.
31
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
32
32
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
33
  end
34
34
  spec.bindir = 'exe'
@@ -37,10 +37,10 @@ Gem::Specification.new do |spec|
37
37
  spec.require_paths = ['lib']
38
38
 
39
39
  spec.add_runtime_dependency 'git_diff_parser', '~> 3.2'
40
- spec.add_runtime_dependency 'rubocop', '~> 0.80'
40
+ spec.add_runtime_dependency 'rubocop', '~> 1.25'
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.6.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: 2022-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git_diff_parser
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.80'
33
+ version: '1.25'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.80'
40
+ version: '1.25'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -107,10 +107,10 @@ extra_rdoc_files:
107
107
  - LICENSE.txt
108
108
  - README.md
109
109
  files:
110
+ - ".github/workflows/ci.yml"
110
111
  - ".gitignore"
111
112
  - ".rspec"
112
113
  - ".rubocop.yml"
113
- - ".travis.yml"
114
114
  - CODE_OF_CONDUCT.md
115
115
  - Gemfile
116
116
  - Gemfile.lock
@@ -141,14 +141,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - ">="
143
143
  - !ruby/object:Gem::Version
144
- version: 2.3.0
144
+ version: 2.5.0
145
145
  required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  requirements:
147
147
  - - ">="
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubygems_version: 3.0.1
151
+ rubygems_version: 3.1.2
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Rubocop on changed lines from git fork point
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- rvm:
4
- - 2.3.3
5
- - 2.4.0
6
- before_install:
7
- - gem update bundler
8
- notifications:
9
- email:
10
- - fcsonline@gmail.com