boxt_ruby_style_guide 7.7.3 → 7.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: bb14b8f791b4feded3f27f40c3bb50de7087c97f6c68177831a0d480e52e3860
4
- data.tar.gz: db0f26c2a9cd3f5dc8137a74c03819f0744a09c64be7cdad45eb250994dd2ee3
3
+ metadata.gz: 7e8f3ee70573d3493385981a232a6b08389bdf815827b097aa7a24478f7e5a80
4
+ data.tar.gz: 7a7fede5a038a4e0b764b3ad629d83bafeeed03d9b980c4b851baefbf777c45a
5
5
  SHA512:
6
- metadata.gz: 07e967593138ce3ac4fe0aea5f6eca2a53c46611e2a3694a3a582abd0d5e52fcbb1a461d8e3917d2fecdae8529f70be656bc849bdaed13391695cfa6f2c027ca
7
- data.tar.gz: 301463c3158cc8f859b408fbf8a0fc8a4c4cb8bcb102d64d7af2ab0a53d606753c1b61e574b6cea6eaa8d4ce1b44b44358ad8b59a349e21886889737b5725155
6
+ metadata.gz: ffe098e6a1fa3323b8897fbf5cdbff05b0e4e37d66988fdecb15a0f866b7e110c430f6ce427bc15c7ce82fa9a4165029ee514788046c451ea271b6fa65a78bdd
7
+ data.tar.gz: 3a090c5cd4ce2bd4055866e9587842a759800b580c4cc196bc936c5005da60052789e117153bb3bb38175d6197176c6a5fba54ab193c5daea931f16dde00ae63
data/README.md CHANGED
@@ -24,13 +24,6 @@ And then execute:
24
24
  bundle
25
25
  ```
26
26
 
27
- To make the lint rake tasks available to non Rails apps and gems, add the following to the project's `Rakefile`:
28
-
29
- ```ruby
30
- require "boxt_ruby_style_guide"
31
- BoxtRubyStyleGuide.install_tasks
32
- ```
33
-
34
27
  Rails apps should have access to the lint tasks by default.
35
28
 
36
29
  ## Usage
@@ -75,14 +68,14 @@ Lint tasks to run against files listed as changed by Git.
75
68
  To run `rubocop` against any changed files use:
76
69
 
77
70
  ```sh
78
- rake lint:rubocop RUBOCOP_LINT_BASE=your-base-branch
71
+ RUBOCOP_LINT_BASE=your-base-branch rake lint:rubocop
79
72
  ```
80
73
 
81
74
  To run `rubocop` with autofix, use one of the following:
82
75
 
83
76
  ```sh
84
- rake lint:rubocop_a RUBOCOP_LINT_BASE=your-base-branch
85
- rake lint:rubocop_A RUBOCOP_LINT_BASE=your-base-branch
77
+ RUBOCOP_LINT_BASE=your-base-branch rake lint:rubocop -a
78
+ RUBOCOP_LINT_BASE=your-base-branch rake lint:rubocop -A
86
79
  ```
87
80
 
88
81
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.7.3
1
+ 7.8.0
@@ -15,7 +15,7 @@ module BoxtRubyStyleGuide
15
15
 
16
16
  attr_reader :base
17
17
 
18
- def initialize(base = "master")
18
+ def initialize(base:)
19
19
  @base = base
20
20
  end
21
21
 
@@ -1,55 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "boxt_ruby_style_guide"
4
- require "rubocop"
5
-
6
- require "boxt_ruby_style_guide/git_diff"
7
4
  require "boxt_ruby_style_guide/filepath_matcher"
8
-
9
- ##
10
- # The base branch to compare HEAD with for changes
11
- BASE_BRANCH = "develop"
12
-
13
- ##
14
- # Name of the master Rubocop lint task to run
15
- RUBOCOP_TASK_NAME = :"lint:execute_rubocop"
16
-
17
- ##
18
- # Pattern for matching autofix options
19
- AUTO_REGEX = /\A-a\Z/i.freeze
5
+ require "boxt_ruby_style_guide/git_diff"
6
+ require "rubocop"
20
7
 
21
8
  namespace :lint do
22
9
  desc "Runs rubocop against all files with committed changes different from base branch"
23
10
  task :rubocop do
24
- Rake::Task[RUBOCOP_TASK_NAME].invoke
25
- end
26
-
27
- desc "Runs rubocop against all files using -a (soft autofix) option"
28
- task :rubocop_a do
29
- Rake::Task[RUBOCOP_TASK_NAME].invoke("-a")
30
- end
31
-
32
- desc "Runs rubocop against all files using -A (hard autofix) option"
33
- task :rubocop_A do
34
- Rake::Task[RUBOCOP_TASK_NAME].invoke("-A")
35
- end
11
+ file_paths = sanitized_file_paths
12
+ puts "File paths: #{file_paths.join(', ')}"
36
13
 
37
- task :execute_rubocop, [:auto_flag] do |_t, args|
38
- if sanitized_file_paths.any?
39
- # Sanitize args to make sure only a single "a" or "A" is accepted
40
- auto_flag = AUTO_REGEX.match(args[:auto_flag])
41
- exec("bundle exec rubocop #{sanitized_file_paths.join(" ")} #{auto_flag}".strip)
14
+ if file_paths.any?
15
+ auto_flag_opt = ARGV.select { |a| ["-a", "-A"].include?(a) }.first
16
+ exec("bundle exec rubocop #{file_paths.join(' ')} #{auto_flag_opt}".strip)
42
17
  else
43
- puts "No matching Ruby files changed"
18
+ puts "No Ruby files changed"
44
19
  end
45
20
  end
46
21
  end
47
22
 
48
23
  private
49
24
 
50
- # Returns Array
25
+ # Returns an array of files
51
26
  def sanitized_file_paths
52
- base = ENV.fetch("RUBOCOP_LINT_BASE", BASE_BRANCH)
53
- changed_files = BoxtRubyStyleGuide::GitDiff.new(base).all
27
+ base = ENV.fetch("RUBOCOP_LINT_BASE", "main")
28
+ changed_files = BoxtRubyStyleGuide::GitDiff.new(base: base).all
54
29
  BoxtRubyStyleGuide::FilepathMatcher.new(*changed_files).all_matches
55
30
  end
metadata CHANGED
@@ -1,63 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxt_ruby_style_guide
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.7.3
4
+ version: 7.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boxt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-23 00:00:00.000000000 Z
11
+ date: 2020-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.4.0
19
+ version: '1.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.4.0
26
+ version: '1.4'
27
27
  - !ruby/object:Gem::Dependency
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.92.0
33
+ version: 1.4.2
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.92.0
41
- - !ruby/object:Gem::Dependency
42
- name: rails
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">"
46
- - !ruby/object:Gem::Version
47
- version: '5'
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: '7'
51
- type: :development
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ">"
56
- - !ruby/object:Gem::Version
57
- version: '5'
58
- - - "<"
59
- - !ruby/object:Gem::Version
60
- version: '7'
40
+ version: 1.4.2
61
41
  - !ruby/object:Gem::Dependency
62
42
  name: rubocop-faker
63
43
  requirement: !ruby/object:Gem::Requirement
@@ -92,14 +72,14 @@ dependencies:
92
72
  requirements:
93
73
  - - '='
94
74
  - !ruby/object:Gem::Version
95
- version: 1.43.2
75
+ version: 2.0.0
96
76
  type: :runtime
97
77
  prerelease: false
98
78
  version_requirements: !ruby/object:Gem::Requirement
99
79
  requirements:
100
80
  - - '='
101
81
  - !ruby/object:Gem::Version
102
- version: 1.43.2
82
+ version: 2.0.0
103
83
  - !ruby/object:Gem::Dependency
104
84
  name: bundler
105
85
  requirement: !ruby/object:Gem::Requirement
@@ -142,6 +122,26 @@ dependencies:
142
122
  - - ">="
143
123
  - !ruby/object:Gem::Version
144
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rails
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">"
130
+ - !ruby/object:Gem::Version
131
+ version: '5'
132
+ - - "<"
133
+ - !ruby/object:Gem::Version
134
+ version: '7'
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">"
140
+ - !ruby/object:Gem::Version
141
+ version: '5'
142
+ - - "<"
143
+ - !ruby/object:Gem::Version
144
+ version: '7'
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: rake
147
147
  requirement: !ruby/object:Gem::Requirement