rubocop-changes 0.4.0 → 0.7.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: 4a94905b21e4303a0e32552697c0766e15aa6caedba8a96a047f5ecc5f5393fd
4
- data.tar.gz: 98efe986e967c29ef194427f0cab777b9d611d230b1add48f44716e475d2164e
3
+ metadata.gz: 2d17f6a268625b8b30740a9e1409576f00374bf777632a3c1e6b068678a70d9c
4
+ data.tar.gz: 16eaed76c02755b4a0239c52f36ad8c2ab7369098abd2cdf77fc7bfa8f8d13e6
5
5
  SHA512:
6
- metadata.gz: 34ae25af5ff70f8428c54dca710d8b0e423b8f599ab4b854e73d080ccc4db008dd9a85f34feeaefa98d6c2faabb4bcef0c8ab3a30bfa371b42c1592f65779972
7
- data.tar.gz: 392d5448f21ebe2bdf11e8b3b09bcb6d54212906bbebca4da3850efddd78e6ec3f3653b421754c9696747c76be63aeb4b75c86aa8aa60dd3bf8375c9898e6d2e
6
+ metadata.gz: 7e611a8344770358d7690dc7cf58d0421b06853e696d03e0bc99ae42d6c9e3b5e24f2de7c0fef195f6fd54c14d64527cc0ba2a3190187645f713c4a6e8ef6c17
7
+ data.tar.gz: 4c7b4eb56b4eaa7f7a59c5016b9e26f5d3b4d60246804a67481c94e35cdd0334f1799fc88b2cb34189a0ec8bf57a51a72940d5ca114bab95b32be33c5ade3842
@@ -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.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,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-changes (0.4.0)
4
+ rubocop-changes (0.7.0)
5
5
  git_diff_parser (~> 3.2)
6
- rubocop (~> 0.80)
6
+ rubocop (>= 1.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -12,12 +12,13 @@ GEM
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 (3.0.0.0)
15
+ json (2.6.2)
16
+ parallel (1.22.1)
17
+ parser (3.1.2.0)
18
18
  ast (~> 2.4.1)
19
- rainbow (3.0.0)
19
+ rainbow (3.1.1)
20
20
  rake (13.0.3)
21
+ regexp_parser (2.5.0)
21
22
  rexml (3.2.5)
22
23
  rspec (3.9.0)
23
24
  rspec-core (~> 3.9.0)
@@ -32,16 +33,20 @@ GEM
32
33
  diff-lcs (>= 1.2.0, < 2.0)
33
34
  rspec-support (~> 3.9.0)
34
35
  rspec-support (3.9.0)
35
- rubocop (0.81.0)
36
- jaro_winkler (~> 1.5.1)
36
+ rubocop (1.31.2)
37
+ json (~> 2.3)
37
38
  parallel (~> 1.10)
38
- parser (>= 2.7.0.1)
39
+ parser (>= 3.1.0.0)
39
40
  rainbow (>= 2.2.2, < 4.0)
40
- rexml
41
+ regexp_parser (>= 1.8, < 3.0)
42
+ rexml (>= 3.2.5, < 4.0)
43
+ rubocop-ast (>= 1.18.0, < 2.0)
41
44
  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)
45
+ unicode-display_width (>= 1.4.0, < 3.0)
46
+ rubocop-ast (1.19.1)
47
+ parser (>= 3.1.1.0)
48
+ ruby-progressbar (1.11.0)
49
+ unicode-display_width (2.2.0)
45
50
 
46
51
  PLATFORMS
47
52
  ruby
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
@@ -12,7 +12,8 @@ offenses = Rubocop::Changes::Checker.new(
12
12
  format: args.format,
13
13
  quiet: args.quiet,
14
14
  commit: args.commit,
15
- auto_correct: args.auto_correct
15
+ auto_correct: args.auto_correct,
16
+ base_branch: args.base_branch
16
17
  ).run
17
18
 
18
19
  exit offenses.count.positive? ? 1 : 0
@@ -10,17 +10,20 @@ require 'rubocop/changes/shell'
10
10
  module Rubocop
11
11
  module Changes
12
12
  class UnknownFormat < StandardError; end
13
+ class UnknownBaseBranchError < StandardError; end
13
14
  class UnknownForkPointError < StandardError; end
14
15
 
15
16
  class Checker
16
- def initialize(format:, quiet:, commit:, auto_correct:)
17
+ def initialize(format:, quiet:, commit:, auto_correct:, base_branch:)
17
18
  @format = format
18
19
  @quiet = quiet
19
20
  @commit = commit
20
21
  @auto_correct = auto_correct
22
+ @base_branch = base_branch
21
23
  end
22
24
 
23
25
  def run
26
+ raise UnknownBaseBranchError if base_branch.empty?
24
27
  raise UnknownForkPointError if fork_point.empty?
25
28
  raise UnknownFormat if formatter_klass.nil?
26
29
 
@@ -31,14 +34,14 @@ module Rubocop
31
34
 
32
35
  private
33
36
 
34
- attr_reader :format, :quiet, :commit, :auto_correct
37
+ attr_reader :format, :quiet, :commit, :auto_correct, :base_branch
35
38
 
36
39
  def fork_point
37
40
  @fork_point ||= Shell.run(command)
38
41
  end
39
42
 
40
43
  def command
41
- return 'git merge-base HEAD origin/master' unless commit
44
+ return "git merge-base HEAD origin/#{base_branch}" unless commit
42
45
 
43
46
  "git log -n 1 --pretty=format:\"%h\" #{commit}"
44
47
  end
@@ -120,7 +123,9 @@ module Rubocop
120
123
  end
121
124
 
122
125
  def formatter_klass
123
- @formatter_klass ||= formatters[format]
126
+ return formatters[format] unless formatters[format].is_a? String
127
+
128
+ Kernel.const_get("RuboCop::Formatter::#{formatters[format]}")
124
129
  end
125
130
 
126
131
  def formatters
@@ -5,10 +5,16 @@ require 'optparse'
5
5
  module Rubocop
6
6
  module Changes
7
7
  class Options
8
- Options = Struct.new(:format, :quiet, :commit, :auto_correct)
8
+ Options = Struct.new(:format, :quiet, :commit, :auto_correct, :base_branch)
9
9
 
10
10
  def initialize
11
- @args = Options.new(:simple, false, nil, false) # Defaults
11
+ @args = Options.new(
12
+ :simple,
13
+ false,
14
+ nil,
15
+ false,
16
+ ENV.fetch('RUBOCOP_CHANGES_BASE_BRANCH', 'main')
17
+ ) # Defaults
12
18
  end
13
19
 
14
20
  def parse!
@@ -21,6 +27,7 @@ module Rubocop
21
27
  parse_auto_correct!(opts)
22
28
  parse_help!(opts)
23
29
  parse_version!(opts)
30
+ parse_base_branch!(opts)
24
31
  end.parse!
25
32
 
26
33
  args
@@ -71,6 +78,13 @@ module Rubocop
71
78
  end
72
79
  end
73
80
 
81
+ def parse_base_branch!(opts)
82
+ env_message = 'Also, you can set RUBOCOP_CHANGES_BASE_BRANCH environment variable'
83
+ opts.on('-b', '--base-branch [BRANCH]', "Base branch to compare. #{env_message}") do |v|
84
+ args.base_branch = v
85
+ end
86
+ end
87
+
74
88
  def parse_help!(opts)
75
89
  opts.on('-h', '--help', 'Prints this help') do
76
90
  puts opts
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rubocop
4
4
  module Changes
5
- VERSION = '0.4.0'
5
+ VERSION = '0.7.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,7 +37,7 @@ 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.0'
41
41
 
42
42
  spec.add_development_dependency 'bundler', '~> 2.0'
43
43
  spec.add_development_dependency 'byebug', '~> 10.0'
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.4.0
4
+ version: 0.7.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: 2021-05-17 00:00:00.000000000 Z
11
+ date: 2022-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git_diff_parser
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rubocop
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0.80'
33
+ version: '1.0'
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.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  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.3.5
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