From 84e148018eb5eca1e60fa9a694b8d8ef1f4ad624 Mon Sep 17 00:00:00 2001 From: Martin Schurz Date: Fri, 18 Mar 2022 20:33:22 +0100 Subject: [PATCH 1/2] use cookstyle for linting Signed-off-by: Martin Schurz --- .rubocop.yml | 28 ---------------------------- Gemfile | 1 + Rakefile | 5 +++++ 3 files changed, 6 insertions(+), 28 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b3c997c..5484145 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,31 +2,3 @@ AllCops: Exclude: - vendor/**/* -Documentation: - Enabled: false -Layout/ParameterAlignment: - Enabled: true -HashSyntax: - Enabled: true -LineLength: - Enabled: false -EmptyLinesAroundBlockBody: - Enabled: false -Style/Encoding: - Enabled: false -MethodLength: - Max: 40 -NumericLiterals: - MinDigits: 10 -Metrics/BlockLength: - Max: 35 -Metrics/CyclomaticComplexity: - Max: 10 -Metrics/PerceivedComplexity: - Max: 10 -Metrics/AbcSize: - Max: 30 -# Lint/AmbiguousBlockAssociation is incompatible with RSpec -# https://github.com/rubocop-hq/rubocop/issues/4222 -Lint/AmbiguousBlockAssociation: - Enabled: false diff --git a/Gemfile b/Gemfile index a076fc4..3a0b06c 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source 'https://rubygems.org' +gem 'cookstyle' gem 'highline' gem 'rack' gem 'rake' diff --git a/Rakefile b/Rakefile index 045b0fd..9afcd19 100755 --- a/Rakefile +++ b/Rakefile @@ -2,6 +2,7 @@ # encoding: utf-8 # frozen_string_literal: true +require 'cookstyle' require 'rake/testtask' require 'rubocop/rake_task' @@ -11,6 +12,10 @@ task :rubocop do RuboCop::RakeTask.new end +RuboCop::RakeTask.new(:cookstyle) do |task| + task.options << '--display-cop-names' +end + # lint the project desc 'Run robocop linter' task lint: [:rubocop] From 06789a745a02127b15e5690bd871f7b0b190ee7a Mon Sep 17 00:00:00 2001 From: Martin Schurz Date: Fri, 18 Mar 2022 20:34:00 +0100 Subject: [PATCH 2/2] apply cookstyle fixes Signed-off-by: Martin Schurz --- Rakefile | 2 -- controls/patches.rb | 1 - libraries/linux_updates.rb | 7 ++----- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index 9afcd19..82f16c3 100755 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,4 @@ #!/usr/bin/env rake -# encoding: utf-8 # frozen_string_literal: true require 'cookstyle' @@ -51,5 +50,4 @@ task :changelog do Rake::Task[:changelog].execute rescue LoadError puts '>>>>> GitHub Changelog Generator not loaded, omitting tasks' - end diff --git a/controls/patches.rb b/controls/patches.rb index 509b0ce..509ccbf 100644 --- a/controls/patches.rb +++ b/controls/patches.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 # frozen_string_literal: true # copyright: 2016, Christoph Hartmann diff --git a/libraries/linux_updates.rb b/libraries/linux_updates.rb index d173fd5..33ac5bf 100644 --- a/libraries/linux_updates.rb +++ b/libraries/linux_updates.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 # frozen_string_literal: true # copyright: 2016, Christoph Hartmann @@ -49,7 +48,7 @@ def updates end def uptodate? - return nil if @update_mgmt.nil? + return if @update_mgmt.nil? u = @update_mgmt.updates return false if u.nil? || !u['available'].empty? @@ -198,7 +197,6 @@ def debian_base class RHELUpdateFetcher < UpdateFetcher def packages - # rubocop:disable Style/FormatStringToken rhel_packages = <<~PRINT_JSON sleep 2 && echo " " echo -n '{"installed":[' @@ -207,7 +205,6 @@ def packages echo -n ']}' PRINT_JSON parse_json(rhel_packages) - # rubocop:enable Style/FormatStringToken end def updates @@ -219,7 +216,7 @@ def updates unless cmd.exit_status.zero? # essentially we want https://github.com/chef/inspec/issues/1205 warn 'Could not determine patch status.' - return nil + return end first = cmd.stdout.index('{')