From 540ffab1791fa91262ed86fd6e4919162d93fb3b Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Fri, 3 Jul 2020 14:49:20 -0400 Subject: [PATCH] RuboCop & Ruby 2.7 updates --- .rubocop.yml | 1 + Gemfile | 6 +-- Gemfile.lock | 47 +++++++++++++------ Rakefile | 13 ++--- link/nix/zshrc | 3 ++ puppet/production/Puppetfile | 3 -- .../site/custom_libs/lib/facter/os_release.rb | 2 +- 7 files changed, 44 insertions(+), 31 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9047799..69bd7a8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,6 +3,7 @@ AllCops: - 'vendor/**/*' - 'spec/fixtures/**/*' TargetRubyVersion: 2.5 + NewCops: enable Style/CommentedKeyword: Enabled: false diff --git a/Gemfile b/Gemfile index 949f090..b86639c 100644 --- a/Gemfile +++ b/Gemfile @@ -3,13 +3,13 @@ # vim:ft=ruby source 'https://rubygems.org' -# rubocop:disable ConditionalAssignment +# rubocop:disable Style/ConditionalAssignment if ENV.key?('PUPPET_VERSION') puppetversion = ENV['PUPPET_VERSION'].to_s else - puppetversion = ['>= 5', '< 6'] + puppetversion = ['>= 6', '< 7'] end -# rubocop:enable ConditionalAssignment +# rubocop:enable Style/ConditionalAssignment group :production do gem 'os', '~> 1.1' diff --git a/Gemfile.lock b/Gemfile.lock index b4b084d..31e3bbf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,12 +6,14 @@ GEM public_suffix (>= 2.0.2, < 5.0) ast (2.4.1) colored2 (3.1.2) + concurrent-ruby (1.1.6) cri (2.15.10) - diff-lcs (1.3) + deep_merge (1.2.1) + diff-lcs (1.4.4) equatable (0.6.1) - facter (2.5.7) - facter (2.5.7-universal-darwin) - CFPropertyList (~> 2.2) + facter (4.0.29) + hocon (~> 1.3) + thor (>= 1.0.1, < 2.0) faraday (0.17.3) multipart-post (>= 1.2, < 3) faraday_middleware (0.14.0) @@ -25,6 +27,8 @@ GEM gettext (>= 3.0.2, < 3.3.0) locale hiera (3.6.0) + hocon (1.3.1) + httpclient (2.8.3) json (2.3.1) json-schema (2.8.1) addressable (>= 2.4) @@ -42,24 +46,34 @@ GEM parallel (1.19.2) parser (2.7.1.4) ast (~> 2.4.1) - pastel (0.7.3) + pastel (0.7.4) equatable (~> 0.6) tty-color (~> 0.5) pathspec (0.2.1) public_suffix (4.0.5) - puppet (5.5.20) - facter (> 2.0.1, < 4) - fast_gettext (~> 1.1.2) + puppet (6.16.0) + concurrent-ruby (~> 1.0) + deep_merge (~> 1.0) + facter (> 2.0.1, < 5) + fast_gettext (~> 1.1) hiera (>= 3.2.1, < 4) + httpclient (~> 2.8) locale (~> 2.1) multi_json (~> 1.10) - puppet (5.5.20-universal-darwin) + puppet-resource_api (~> 1.5) + semantic_puppet (~> 1.0) + puppet (6.16.0-universal-darwin) CFPropertyList (~> 2.2) - facter (> 2.0.1, < 4) - fast_gettext (~> 1.1.2) + concurrent-ruby (~> 1.0) + deep_merge (~> 1.0) + facter (> 2.0.1, < 5) + fast_gettext (~> 1.1) hiera (>= 3.2.1, < 4) + httpclient (~> 2.8) locale (~> 2.1) multi_json (~> 1.10) + puppet-resource_api (~> 1.5) + semantic_puppet (~> 1.0) puppet-lint (2.4.2) puppet-lint-absolute_classname-check (2.0.0) puppet-lint (>= 1.0, < 3.0) @@ -81,7 +95,9 @@ GEM puppet-lint (>= 2.1, < 3.0) puppet-lint-variable_contains_upcase (1.2.0) puppet-lint (>= 1.0, < 3.0) - puppet-syntax (3.0.1) + puppet-resource_api (1.8.13) + hocon (>= 1.0) + puppet-syntax (3.1.0) puppet (>= 5) rake puppet_forge (2.3.4) @@ -140,6 +156,7 @@ GEM semantic_puppet (1.0.2) spdx-licenses (1.2.0) text (1.3.1) + thor (1.0.1) trollop (2.9.10) tty-color (0.5.1) tty-command (0.9.0) @@ -157,7 +174,7 @@ GEM tty-cursor (~> 0.7) tty-screen (~> 0.7) wisper (~> 2.0.0) - tty-screen (0.7.1) + tty-screen (0.8.0) unicode-display_width (1.7.0) wisper (2.0.1) xmlrpc (0.3.0) @@ -173,7 +190,7 @@ DEPENDENCIES json (>= 2.0.2) metadata-json-lint (~> 2.4) os (~> 1.1) - puppet (>= 5, < 6) + puppet (>= 6, < 7) puppet-lint (~> 2.3) puppet-lint-absolute_classname-check (~> 2.0) puppet-lint-absolute_template_path (~> 1.0) @@ -197,4 +214,4 @@ DEPENDENCIES yamllint (~> 0.0.9) BUNDLED WITH - 2.0.2 + 2.1.2 diff --git a/Rakefile b/Rakefile index 0910ef1..2c0be51 100644 --- a/Rakefile +++ b/Rakefile @@ -14,13 +14,8 @@ exclude_paths = [ 'spec/**/*' ] -RuboCop::RakeTask.new(:rubocop) do |task| - # task.patterns = ['lib/**/*.rb'] - # only show the files with failures - # task.formatters = ['files'] - # don't abort rake on failure - # task.fail_on_error = false -end +# https://docs.rubocop.org/rubocop/0.86/integration_with_other_tools.html#rake-integration +RuboCop::RakeTask.new PuppetLint::RakeTask.new :lint do |config| config.fail_on_warnings = true @@ -37,9 +32,9 @@ task :validate do end Dir['bin/**/*.rb', 'spec/**/*.rb'].each do |ruby_file| - # rubocop:disable RegexpLiteral + # rubocop:disable Style/RegexpLiteral sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ - # rubocop:enable RegexpLiteral + # rubocop:enable Style/RegexpLiteral end Dir['puppet/site/*/templates/**/*.erb'].each do |template| sh "erb -P -x -T '-' #{template} | ruby -c" diff --git a/link/nix/zshrc b/link/nix/zshrc index bf351af..e7e7cbc 100644 --- a/link/nix/zshrc +++ b/link/nix/zshrc @@ -142,6 +142,9 @@ if [[ `uname` == 'Darwin' ]]; then # use homebrew's ruby [ -d /usr/local/opt/ruby/bin ] && export PATH=/usr/local/opt/ruby/bin:$PATH + # hide ruby 2.7's extra output + export RUBYOPT='-W:no-deprecated -W:no-experimental' + # add gems to path GEMBIN="$(gem environment gemdir)/bin" export PATH=$PATH:$GEMBIN diff --git a/puppet/production/Puppetfile b/puppet/production/Puppetfile index b4de430..304f284 100644 --- a/puppet/production/Puppetfile +++ b/puppet/production/Puppetfile @@ -1,11 +1,8 @@ # frozen_string_literal: true forge 'http://forge.puppetlabs.com' - -# rubocop:disable Metrics/LineLength # The next line translates to '../../vendor/puppet_modules' aka ~/.dotfiles/vendor/puppet_modules moduledir "#{File.dirname(File.dirname(File.dirname(__FILE__)))}/vendor/puppet_modules" -# rubocop:enable Metrics/LineLength mod 'puppetlabs-apt', '7.3.0' mod 'puppetlabs-stdlib', '4.25.1' diff --git a/puppet/production/site/custom_libs/lib/facter/os_release.rb b/puppet/production/site/custom_libs/lib/facter/os_release.rb index 3d9f94f..4e5678d 100644 --- a/puppet/production/site/custom_libs/lib/facter/os_release.rb +++ b/puppet/production/site/custom_libs/lib/facter/os_release.rb @@ -13,7 +13,7 @@ Facter.add(:os_release) do line_data = line.split('=') key = line_data[0].downcase - value = line_data[1].strip.gsub(/(^\")|(\"$)/, '') + value = line_data[1].strip.gsub(/(^")|("$)/, '') os_release_hash[key] = value end end