rubocop_lineup 0.2.0 → 0.6.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
- SHA1:
3
- metadata.gz: 2a55e094b399226f398dbad21723ff58589c3988
4
- data.tar.gz: 9f56dead4432a8a87c85d070093d311600500e9d
2
+ SHA256:
3
+ metadata.gz: 3e492d503ab9687aee7fa158ef3ecb9c0fd36aa27a99dce4b94e698a3e3100ac
4
+ data.tar.gz: 158b2a8782b44f2dd5783eef874ce57b9144495252cdd9039d1ae4422212bf6a
5
5
  SHA512:
6
- metadata.gz: e75a2f07204d1a6cfeadbcb71051c2f9ecff7194909f32dd5c01ca709e5fd0719f68ad2d0fa3f3f078e9f8b15db894e14068e51ac2c2dbca76fe2ea829745095
7
- data.tar.gz: a01da1538723ff07e023a9549d38d7246a80dab6acb64c5b4a57c1ea5a3557c848a5707255c1cac3dc63c10e2805a1c972f2eb6bea6a82e34239f938361abe33
6
+ metadata.gz: 60681a39fd3bdf79ed02066af766b0852f127853bb9b1be6db5eb54daf3de1260f3b7e206da200a214a4ad5c6df1b0916df55f3c980e01038155598d48f8b5b6
7
+ data.tar.gz: c211247847d7c752e9b5dc33e6b8fe6b74292a3c4c5ef5cff9c5312370dfcb529b05f3a6874becfcf0a26f0a1e38588dd717c1375dc925ac37aa3ced102c902d
data/.gitignore CHANGED
@@ -1,9 +1,10 @@
1
- /.bundle/
1
+ **/.bundle/
2
2
  /.yardoc
3
3
  /_yardoc/
4
4
  /bin/
5
5
  /coverage/
6
6
  /doc/
7
+ /gemfiles/*lock
7
8
  /pkg/
8
9
  /spec/reports/
9
10
  /tmp/
@@ -12,3 +13,6 @@
12
13
  .rspec_status
13
14
 
14
15
  Gemfile.lock
16
+
17
+ # Don't commit built gems
18
+ *.gem
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: "2.1"
2
+ TargetRubyVersion: 2.4
3
3
  Exclude:
4
4
  - "bin/**"
5
5
 
@@ -1 +1 @@
1
- 2.4.4
1
+ 2.6.3
@@ -1,5 +1,21 @@
1
- sudo: false
2
1
  language: ruby
2
+
3
3
  rvm:
4
- - 2.4.4
5
- before_install: gem install bundler -v 1.16.1
4
+ - 2.4.6
5
+ - 2.5.5
6
+ - 2.6.3
7
+
8
+ gemfile:
9
+ - gemfiles/rubocop_latest.gemfile
10
+ - gemfiles/rubocop_0.86.0.gemfile
11
+ - gemfiles/rubocop_0.82.0.gemfile
12
+ - gemfiles/rubocop_0.77.0.gemfile
13
+ - gemfiles/rubocop_0.69.0.gemfile
14
+ - gemfiles/rubocop_0.61.1.gemfile
15
+ - gemfiles/rubocop_0.58.2.gemfile
16
+ - gemfiles/rubocop_0.56.0.gemfile
17
+ - gemfiles/rubocop_0.52.1.gemfile
18
+ - gemfiles/rubocop_0.46.0.gemfile
19
+
20
+
21
+ before_install: gem install bundler -v 1.17.3
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ appraise "rubocop-latest" do
4
+ gem "rubocop"
5
+ end
6
+
7
+ appraise "rubocop-0.86.0" do
8
+ gem "rubocop", "0.86.0"
9
+ end
10
+
11
+ appraise "rubocop-0.82.0" do
12
+ gem "rubocop", "0.82.0"
13
+ end
14
+
15
+ appraise "rubocop-0.77.0" do
16
+ gem "rubocop", "0.77.0"
17
+ end
18
+
19
+ appraise "rubocop-0.69.0" do
20
+ gem "rubocop", "0.69.0"
21
+ end
22
+
23
+ appraise "rubocop-0.61.1" do
24
+ gem "rubocop", "0.61.1"
25
+ end
26
+
27
+ appraise "rubocop-0.58.2" do
28
+ gem "rubocop", "0.58.2"
29
+ end
30
+
31
+ appraise "rubocop-0.56.0" do
32
+ gem "rubocop", "0.56.0"
33
+ end
34
+
35
+ appraise "rubocop-0.52.1" do
36
+ gem "rubocop", "0.52.1"
37
+ end
38
+
39
+ appraise "rubocop-0.46.0" do
40
+ gem "rubocop", "0.46.0"
41
+ end
data/Gemfile CHANGED
@@ -6,3 +6,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # Specify your gem's dependencies in rubocop_lineup.gemspec
8
8
  gemspec
9
+
10
+ group :development do
11
+ gem "appraisal"
12
+ end
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # RubocopLineup
2
2
 
3
+ [![Build Status](https://travis-ci.com/mysterysci/rubocop_lineup.svg?branch=master)](https://travis-ci.com/mysterysci/rubocop_lineup)
4
+
3
5
  ![Image of Old-Timey Police Lineup](https://upload.wikimedia.org/wikipedia/commons/0/04/Oppstilling-2.jpg)
4
6
 
5
7
  If yer trying to bring in a new sheriff to the wild, wild west of your legacy codebase,
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source "https://rubygems.org"
6
+
7
+ gem "rubocop", "0.46.0"
8
+
9
+ group :development do
10
+ gem "appraisal"
11
+ end
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source "https://rubygems.org"
6
+
7
+ gem "rubocop", "0.52.1"
8
+
9
+ group :development do
10
+ gem "appraisal"
11
+ end
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source "https://rubygems.org"
6
+
7
+ gem "rubocop", "0.56.0"
8
+
9
+ group :development do
10
+ gem "appraisal"
11
+ end
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source "https://rubygems.org"
6
+
7
+ gem "rubocop", "0.58.2"
8
+
9
+ group :development do
10
+ gem "appraisal"
11
+ end
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source "https://rubygems.org"
6
+
7
+ gem "rubocop", "0.61.1"
8
+
9
+ group :development do
10
+ gem "appraisal"
11
+ end
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source "https://rubygems.org"
6
+
7
+ gem "rubocop", "0.69.0"
8
+
9
+ group :development do
10
+ gem "appraisal"
11
+ end
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source "https://rubygems.org"
6
+
7
+ gem "rubocop", "0.77.0"
8
+
9
+ group :development do
10
+ gem "appraisal"
11
+ end
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source "https://rubygems.org"
6
+
7
+ gem "rubocop", "0.82.0"
8
+
9
+ group :development do
10
+ gem "appraisal"
11
+ end
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source "https://rubygems.org"
6
+
7
+ gem "rubocop", "0.86.0"
8
+
9
+ group :development do
10
+ gem "appraisal"
11
+ end
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by Appraisal
4
+
5
+ source "https://rubygems.org"
6
+
7
+ gem "rubocop"
8
+
9
+ group :development do
10
+ gem "appraisal"
11
+ end
12
+
13
+ gemspec path: "../"
@@ -4,6 +4,7 @@ require "rubocop_lineup/version"
4
4
  require "rubocop_lineup/line_number_calculator"
5
5
  require "rubocop_lineup/diff_liner"
6
6
  require "rubocop_lineup/duck_punch_rubocop"
7
+ require "yaml"
7
8
 
8
9
  module RubocopLineup
9
10
  # This defaults the parent branch to 'master'. This is a reasonable
@@ -12,11 +13,13 @@ module RubocopLineup
12
13
  # parent branch. There are ways to calculate the parent branch name
13
14
  # that cover common cases, but that's more complicated and may be added
14
15
  # in a future version.
15
- def self.line_em_up(directory, parent_branch = "master")
16
+ def self.line_em_up(directory, base_branch = nil)
17
+ base_branch ||= base_branch_from_config || "master"
18
+
16
19
  @line_em_up ||= begin
17
20
  Dir.chdir(directory) do
18
21
  uncommitted = DiffLiner.diff_uncommitted.file_line_changes
19
- committed_on_branch = DiffLiner.diff_branch(parent_branch).file_line_changes
22
+ committed_on_branch = DiffLiner.diff_branch(base_branch).file_line_changes
20
23
 
21
24
  # When a file has committed changes AND uncommitted_changes,
22
25
  # we will only include the lines from the uncommitted changes
@@ -31,4 +34,16 @@ module RubocopLineup
31
34
  def self.reset
32
35
  @line_em_up = nil
33
36
  end
37
+
38
+ def self.rubocop_lineup_config_file
39
+ ".rubocop_lineup.yml"
40
+ end
41
+
42
+ def self.base_branch_from_config
43
+ return unless File.exist?(rubocop_lineup_config_file)
44
+
45
+ settings = YAML.load_file(rubocop_lineup_config_file)
46
+
47
+ settings[:base_branch]
48
+ end
34
49
  end
@@ -9,9 +9,16 @@ module DuckPunch
9
9
  files_hash = RubocopLineup.line_em_up(Dir.pwd)
10
10
  return false unless files_hash.key?(source_file)
11
11
 
12
- offending_lines = (line_number..(last_line || line_number)).to_a
13
12
  changed_line_numbers = files_hash[source_file]
14
- (changed_line_numbers & offending_lines).empty? ? false : super
13
+ changed_line_numbers.include?(line_number) ? super : false
14
+
15
+ # Removing support for any line of a block where one or more lines were changed.
16
+ # It's too unpredictable. Linter cops should probably never do this, but I'm
17
+ # not sure how to go about that right now.
18
+ #
19
+ # offending_lines = (line_number..(last_line || line_number)).to_a
20
+ # changed_line_numbers = files_hash[source_file]
21
+ # (changed_line_numbers & offending_lines).empty? ? false : super
15
22
  end
16
23
 
17
24
  def last_line
@@ -26,9 +33,14 @@ module DuckPunch
26
33
  end
27
34
 
28
35
  module TargetFinder
29
- def find(args)
36
+ def find(args, mode=nil)
30
37
  # returns an array of full file paths that are the files to inspect.
31
- files = super(args)
38
+ if mode
39
+ files = super(args, mode)
40
+ else
41
+ # legacy support before mode was added in rubocop
42
+ files = super(args)
43
+ end
32
44
  files_hash = RubocopLineup.line_em_up(Dir.pwd)
33
45
  files & files_hash.keys
34
46
  end
@@ -6,9 +6,7 @@ module RubocopLineup
6
6
  # presumes the text has been parsed already to just the -/+ bits
7
7
  # e.g. "-1 +1"
8
8
  def self.git_line_summary_to_numbers(text)
9
- # TODO: Ruby Golf this - a regex with proper grouping could probably be better.
10
- _changed, added = text.split(/ /).reject(&:empty?)
11
- start, count = added.sub(/^-/, "").split(/,/).map(&:to_i)
9
+ start, count = text.scan(/\+(.*)/).join.scan(/\d+/).flatten.map(&:to_i)
12
10
  count ||= 1
13
11
  (start..(start + count - 1)).to_a
14
12
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubocopLineup
4
- VERSION = "0.2.0".freeze
4
+ VERSION = "0.6.0"
5
5
  end
@@ -21,13 +21,13 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.required_ruby_version = "~> 2.1"
24
+ spec.required_ruby_version = "~> 2.4"
25
25
 
26
26
  spec.add_dependency "git", "~> 1.3"
27
- spec.add_dependency "rubocop", "~> 0.55"
27
+ spec.add_dependency "rubocop", "~> 0.35"
28
28
 
29
- spec.add_development_dependency "bundler", "~> 1.16"
29
+ spec.add_development_dependency "bundler", "> 1.16"
30
30
  spec.add_development_dependency "pry"
31
- spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rake", "~> 12.3"
32
32
  spec.add_development_dependency "rspec", "~> 3.0"
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop_lineup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrismo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-16 00:00:00.000000000 Z
11
+ date: 2020-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -30,26 +30,26 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.55'
33
+ version: '0.35'
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.55'
40
+ version: '0.35'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.16'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.16'
55
55
  - !ruby/object:Gem::Dependency
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '12.3'
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: '12.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -106,12 +106,23 @@ files:
106
106
  - ".rubocop.yml"
107
107
  - ".ruby-version"
108
108
  - ".travis.yml"
109
+ - Appraisals
109
110
  - Gemfile
110
111
  - LICENSE.txt
111
112
  - README.md
112
113
  - Rakefile
113
114
  - bin/console
114
115
  - bin/setup
116
+ - gemfiles/rubocop_0.46.0.gemfile
117
+ - gemfiles/rubocop_0.52.1.gemfile
118
+ - gemfiles/rubocop_0.56.0.gemfile
119
+ - gemfiles/rubocop_0.58.2.gemfile
120
+ - gemfiles/rubocop_0.61.1.gemfile
121
+ - gemfiles/rubocop_0.69.0.gemfile
122
+ - gemfiles/rubocop_0.77.0.gemfile
123
+ - gemfiles/rubocop_0.82.0.gemfile
124
+ - gemfiles/rubocop_0.86.0.gemfile
125
+ - gemfiles/rubocop_latest.gemfile
115
126
  - lib/rubocop_lineup.rb
116
127
  - lib/rubocop_lineup/diff_liner.rb
117
128
  - lib/rubocop_lineup/duck_punch_rubocop.rb
@@ -130,15 +141,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
141
  requirements:
131
142
  - - "~>"
132
143
  - !ruby/object:Gem::Version
133
- version: '2.1'
144
+ version: '2.4'
134
145
  required_rubygems_version: !ruby/object:Gem::Requirement
135
146
  requirements:
136
147
  - - ">="
137
148
  - !ruby/object:Gem::Version
138
149
  version: '0'
139
150
  requirements: []
140
- rubyforge_project:
141
- rubygems_version: 2.6.14.1
151
+ rubygems_version: 3.0.3
142
152
  signing_key:
143
153
  specification_version: 4
144
154
  summary: Rubocop plugin to restrict cops to only changed lines.