Skip to content

Commit

Permalink
Update RuboCop
Browse files Browse the repository at this point in the history
  • Loading branch information
ekohl committed Aug 23, 2023
1 parent ff9a625 commit c017b0d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 28 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
working-directory: vagrant
- name: Run Rubocop
run: bundle exec rubocop --format github
if: matrix.ruby == '3.1'
working-directory: vagrant
- name: Run tests
run: bundle exec rake
run: bundle exec rake test
working-directory: vagrant
17 changes: 10 additions & 7 deletions vagrant/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
require:
- rubocop-minitest
- rubocop-rake

AllCops:
Include:
- '**/Rakefile'
- 'lib/**/*.rb'
- 'test/**/*.rb'
Exclude:
- !ruby/regexp /katello-installer/
- !ruby/regexp /.spec/
- 'vendor/**/*'
TargetRubyVersion: 2.0
TargetRubyVersion: '2.7'
NewCops: enable

Metrics/LineLength:
Layout/LineLength:
Max: 120

Metrics/ClassLength:
Expand All @@ -18,14 +21,14 @@ Metrics/ClassLength:
Metrics/BlockLength:
Max: 50

Documentation:
Style/Documentation:
Enabled: false # don't require documentation

MethodLength:
Metrics/MethodLength:
Description: 'Avoid methods longer than 30 lines of code.'
Max: 30

HashSyntax:
Style/HashSyntax:
Enabled: false # don't force 1.9 hash syntax

Layout/EmptyLinesAroundClassBody:
Expand Down
19 changes: 7 additions & 12 deletions vagrant/Gemfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
# rubocop:disable Naming/FileName
source 'https://rubygems.org'

if RUBY_VERSION < '2.1'
gem 'psych', '~> 2.0'
end

group :test do
gem 'deep_merge'
gem 'json'
gem 'minitest'
gem 'mocha'
gem 'rake'
if RUBY_VERSION < '3.1'
# we need a rubocop that still can manage Ruby 2.0 code
# but 0.49.x is not compatible with Ruby 3.1
gem 'rubocop', '<0.50'
end
end

# rubocop:enable Naming/FileName
# Make sure the Ruby version is supported
# https://docs.rubocop.org/rubocop/compatibility.html#support-matrix
gem 'rubocop', '~> 1.56.0'
gem 'rubocop-minitest'
gem 'rubocop-performance'
gem 'rubocop-rake'
end
3 changes: 1 addition & 2 deletions vagrant/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ default_tasks = %i[test]
begin
require 'rubocop/rake_task'
RuboCop::RakeTask.new
# insert 0, because Ruby 2.0 doesn't know Array.prepend
default_tasks.insert(0, 'rubocop')
default_tasks.prepend('rubocop')
rescue LoadError
puts 'Rubocop not loaded'
end
Expand Down
4 changes: 2 additions & 2 deletions vagrant/lib/forklift.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.dirname(__FILE__)
$LOAD_PATH.unshift __dir__

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

module Forklift
Expand Down
6 changes: 3 additions & 3 deletions vagrant/lib/forklift/box_distributor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module Forklift
class BoxDistributor

VAGRANTFILE_API_VERSION = '2'.freeze
VAGRANTFILE_API_VERSION = '2'

def initialize(boxes)
@ansible_groups = {}
Expand Down Expand Up @@ -177,12 +177,12 @@ def configure_networks(networks)
def configure_ansible(machine, ansible, box_name)
return unless ansible

if ansible.key?('group') && !ansible['group'].nil?
unless ansible['group'].nil?
@ansible_groups[ansible['group'].to_s] ||= []
@ansible_groups[ansible['group'].to_s] << box_name
end

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

Expand Down
2 changes: 1 addition & 1 deletion vagrant/lib/forklift/box_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def add_boxes!(box_file)

def filter_boxes!
box_config = Settings.new.settings['boxes']
return unless box_config && box_config.key?('exclude')
return unless box_config&.key?('exclude')

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

0 comments on commit c017b0d

Please sign in to comment.