From b06edb2adc102f0e7d56c2a94e54019d2592a93b Mon Sep 17 00:00:00 2001 From: Martin Schurz Date: Fri, 18 Mar 2022 20:39:51 +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 3161ad1..5484145 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,31 +2,3 @@ AllCops: Exclude: - vendor/**/* -Documentation: - Enabled: false -ParameterAlignment: - Enabled: true -HashSyntax: - Enabled: true -LineLength: - Enabled: false -EmptyLinesAroundBlockBody: - Enabled: false -Style/IfUnlessModifier: - 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 ed8b932..2ede8d3 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'cookstyle' require 'rake/testtask' require 'rubocop/rake_task' @@ -9,6 +10,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 e646854c3386a02e265d6ed8db0fe6c226159d66 Mon Sep 17 00:00:00 2001 From: Martin Schurz Date: Fri, 18 Mar 2022 20:41:09 +0100 Subject: [PATCH 2/2] apply cookstyle fixes Signed-off-by: Martin Schurz --- controls/os_spec.rb | 6 +++--- controls/package_spec.rb | 6 +++--- controls/sysctl_spec.rb | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/controls/os_spec.rb b/controls/os_spec.rb index 21b7888..acd629a 100644 --- a/controls/os_spec.rb +++ b/controls/os_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # -# Copyright 2015, Patrick Muench +# Copyright:: 2015, Patrick Muench # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,8 +29,8 @@ shadow_group = 'root' shadow_group = 'shadow' if os.debian? || os.suse? || os.name == 'alpine' container_execution = begin virtualization.role == 'guest' && virtualization.system =~ /^(lxc|docker)$/ -rescue NoMethodError - false + rescue NoMethodError + false end blacklist = input( diff --git a/controls/package_spec.rb b/controls/package_spec.rb index 7e05e6b..e47677f 100644 --- a/controls/package_spec.rb +++ b/controls/package_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # -# Copyright 2015, Patrick Muench +# Copyright:: 2015, Patrick Muench # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,8 +21,8 @@ container_execution = begin virtualization.role == 'guest' && virtualization.system =~ /^(lxc|docker)$/ -rescue NoMethodError - false + rescue NoMethodError + false end control 'package-01' do diff --git a/controls/sysctl_spec.rb b/controls/sysctl_spec.rb index 1e3d96b..2afca30 100644 --- a/controls/sysctl_spec.rb +++ b/controls/sysctl_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # -# Copyright 2015, Patrick Muench +# Copyright:: 2015, Patrick Muench # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,8 +23,8 @@ sysctl_forwarding = input('sysctl_forwarding', value: false, description: 'Is ne kernel_modules_disabled = input('kernel_modules_disabled', value: 0, description: 'Should loading of kernel modules be disabled?') container_execution = begin virtualization.role == 'guest' && virtualization.system =~ /^(lxc|docker)$/ -rescue NoMethodError - false + rescue NoMethodError + false end control 'sysctl-01' do