Skip to content

Commit 97f84bc

Browse files
committed
Update RuboCop
1 parent ff9a625 commit 97f84bc

File tree

7 files changed

+28
-26
lines changed

7 files changed

+28
-26
lines changed

.github/workflows/main.yml

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ jobs:
5959
ruby-version: ${{ matrix.ruby }}
6060
bundler-cache: true
6161
working-directory: vagrant
62+
- name: Run Rubocop
63+
run: bundle exec rubocop --format github
64+
if: matrix.ruby == '3.1'
65+
working-directory: vagrant
6266
- name: Run tests
6367
run: bundle exec rake
6468
working-directory: vagrant

vagrant/.rubocop.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
require:
2+
- rubocop-minitest
3+
- rubocop-rake
4+
15
AllCops:
26
Include:
37
- '**/Rakefile'
@@ -6,10 +10,10 @@ AllCops:
610
Exclude:
711
- !ruby/regexp /katello-installer/
812
- !ruby/regexp /.spec/
9-
- 'vendor/**/*'
10-
TargetRubyVersion: 2.0
13+
TargetRubyVersion: '2.7'
14+
NewCops: enable
1115

12-
Metrics/LineLength:
16+
Layout/LineLength:
1317
Max: 120
1418

1519
Metrics/ClassLength:
@@ -18,14 +22,14 @@ Metrics/ClassLength:
1822
Metrics/BlockLength:
1923
Max: 50
2024

21-
Documentation:
25+
Style/Documentation:
2226
Enabled: false # don't require documentation
2327

24-
MethodLength:
28+
Metrics/MethodLength:
2529
Description: 'Avoid methods longer than 30 lines of code.'
2630
Max: 30
2731

28-
HashSyntax:
32+
Style/HashSyntax:
2933
Enabled: false # don't force 1.9 hash syntax
3034

3135
Layout/EmptyLinesAroundClassBody:

vagrant/Gemfile

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
# rubocop:disable Naming/FileName
21
source 'https://rubygems.org'
32

4-
if RUBY_VERSION < '2.1'
5-
gem 'psych', '~> 2.0'
6-
end
7-
83
group :test do
94
gem 'deep_merge'
105
gem 'json'
116
gem 'minitest'
127
gem 'mocha'
138
gem 'rake'
14-
if RUBY_VERSION < '3.1'
15-
# we need a rubocop that still can manage Ruby 2.0 code
16-
# but 0.49.x is not compatible with Ruby 3.1
17-
gem 'rubocop', '<0.50'
18-
end
19-
end
209

21-
# rubocop:enable Naming/FileName
10+
# Make sure the Ruby version is supported
11+
# https://docs.rubocop.org/rubocop/compatibility.html#support-matrix
12+
gem 'rubocop', '~> 1.56.0'
13+
gem 'rubocop-minitest'
14+
gem 'rubocop-performance'
15+
gem 'rubocop-rake'
16+
end

vagrant/Rakefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ default_tasks = %i[test]
1313
begin
1414
require 'rubocop/rake_task'
1515
RuboCop::RakeTask.new
16-
# insert 0, because Ruby 2.0 doesn't know Array.prepend
17-
default_tasks.insert(0, 'rubocop')
16+
default_tasks.prepend('rubocop')
1817
rescue LoadError
1918
puts 'Rubocop not loaded'
2019
end

vagrant/lib/forklift.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# frozen_string_literal: true
22

3-
$LOAD_PATH.unshift File.dirname(__FILE__)
3+
$LOAD_PATH.unshift __dir__
44

5-
files = Dir[File.dirname(__FILE__) + '/forklift/**/*.rb']
5+
files = Dir["#{__dir__}/forklift/**/*.rb"]
66
files.uniq.each { |f| require f }
77

88
module Forklift

vagrant/lib/forklift/box_distributor.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
module Forklift
66
class BoxDistributor
77

8-
VAGRANTFILE_API_VERSION = '2'.freeze
8+
VAGRANTFILE_API_VERSION = '2'
99

1010
def initialize(boxes)
1111
@ansible_groups = {}
@@ -177,12 +177,12 @@ def configure_networks(networks)
177177
def configure_ansible(machine, ansible, box_name)
178178
return unless ansible
179179

180-
if ansible.key?('group') && !ansible['group'].nil?
180+
unless ansible['group'].nil?
181181
@ansible_groups[ansible['group'].to_s] ||= []
182182
@ansible_groups[ansible['group'].to_s] << box_name
183183
end
184184

185-
if ansible.key?('server') && !ansible['server'].nil?
185+
unless ansible['server'].nil?
186186
@ansible_groups["server-#{box_name}"] = ansible['server']
187187
end
188188

vagrant/lib/forklift/box_factory.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def add_boxes!(box_file)
3131

3232
def filter_boxes!
3333
box_config = Settings.new.settings['boxes']
34-
return unless box_config && box_config.key?('exclude')
34+
return unless box_config&.key?('exclude')
3535

3636
@boxes.reject! do |name, _box|
3737
box_config['exclude'].any? { |exclude| name.match(/#{exclude}/) }

0 commit comments

Comments
 (0)