diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 01d8a6b..1b3c60c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ on: - '*' jobs: - linting: + cookstyle: runs-on: ubuntu-latest strategy: matrix: @@ -24,3 +24,6 @@ jobs: run: | mkdir -p .cache curl -L https://omnitruck.cinc.sh/install.sh | sudo bash -s -- -P cinc-workstation -d .cache -v ${{ matrix.cinc_workstation_version }} + - name: cookstyle + run: | + cinc exec rake cookstyle diff --git a/.gitignore b/.gitignore index 003bc0e..9b57504 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ coverage exp.* pkg/ shared_test_repo/ +.envrc # Berkshelf .vagrant diff --git a/.rubocop.yml b/.rubocop.yml index 335d344..4b1f9c2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,6 @@ --- +inherit_from: .rubocop_todo.yml + AllCops: DisplayCopNames: true Exclude: @@ -7,7 +9,7 @@ AllCops: TargetRubyVersion: 2.5 Metrics/AbcSize: Max: 29 -Metrics/LineLength: +Layout/LineLength: Max: 100 Include: - spec/**/*.rb @@ -17,7 +19,7 @@ Style/Documentation: Enabled: false Layout/DotPosition: EnforcedStyle: trailing -Layout/AlignHash: +Layout/HashAlignment: EnforcedHashRocketStyle: table EnforcedColonStyle: table Style/NumericLiterals: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..1e2dcd6 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,114 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-03-29 19:15:26 UTC using RuboCop version 1.25.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# Cop supports --auto-correct. +Chef/Correctness/IncorrectLibraryInjection: + Exclude: + - '**/metadata.rb' + - '**/Berksfile' + - 'recipes/sysctl.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: **/spec/*.rb +Chef/Deprecations/ChefSpecCoverageReport: + Exclude: + - 'spec/spec_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: **/metadata.rb +Chef/RedundantCode/LongDescriptionMetadata: + Exclude: + - 'metadata.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: **/metadata.rb +Chef/RedundantCode/RecipeMetadata: + Exclude: + - 'metadata.rb' + +# Offense count: 65 +# Cop supports --auto-correct. +Chef/Style/CommentFormat: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Chef/Style/IncludeRecipeWithParentheses: + Exclude: + - '**/attributes/*.rb' + - '**/metadata.rb' + - '**/Berksfile' + - 'recipes/packages.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Chef/Style/UnnecessaryPlatformCaseStatement: + Exclude: + - '**/metadata.rb' + - '**/Berksfile' + - 'attributes/default.rb' + - 'attributes/sysctl.rb' + - 'recipes/packages.rb' + - 'recipes/selinux.rb' + - 'recipes/sysctl.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +Chef/Style/UsePlatformHelpers: + Exclude: + - '**/metadata.rb' + - '**/libraries/*' + - '**/Berksfile' + - 'attributes/sysctl.rb' + - 'recipes/auditd.rb' + - 'recipes/default.rb' + - 'recipes/minimize_access.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'attributes/default.rb' + - 'recipes/auditd.rb' + - 'recipes/minimize_access.rb' + - 'recipes/yum.rb' + - 'spec/recipes/default_spec.rb' + - 'spec/recipes/sysctl_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'attributes/default.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'spec/recipes/login_defs_spec.rb' + - 'spec/recipes/securetty_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 6 diff --git a/Gemfile b/Gemfile index 1d3ce98..13d58ef 100644 --- a/Gemfile +++ b/Gemfile @@ -2,26 +2,6 @@ source 'https://rubygems.org' -gem 'berkshelf', '~> 7.0' -gem 'chef', '~> 14.11' - -group :test do - gem 'chefspec', '~> 7.3.4' - gem 'coveralls', require: false - gem 'foodcritic', '~> 15.1' - gem 'rake' - gem 'rubocop', '~> 0.65.0' - gem 'simplecov', '~> 0.16' -end - -group :integration do - gem 'kitchen-digitalocean' - gem 'kitchen-dokken' - gem 'kitchen-inspec', '~> 1.0.1' - gem 'kitchen-vagrant' - gem 'test-kitchen', '~> 1.24' -end - group :tools do gem 'github_changelog_generator', '~> 1.14' end diff --git a/Rakefile b/Rakefile index 9e5b9c2..8919d54 100644 --- a/Rakefile +++ b/Rakefile @@ -2,9 +2,7 @@ # rubocop:disable Style/SymbolArray -require 'foodcritic' require 'rspec/core/rake_task' -require 'rubocop/rake_task' require 'base64' require 'chef/cookbook/metadata' @@ -16,7 +14,7 @@ task default: [:lint, :spec] # Lint the cookbook desc 'Run all linters: rubocop and foodcritic' -task lint: [:rubocop, :foodcritic] +task lint: [:cookstyle] # Run the whole shebang desc 'Run all tests' @@ -29,20 +27,9 @@ task :spec do RSpec::Core::RakeTask.new(:spec) end -# Foodcritic -desc 'Run foodcritic lint checks' -task :foodcritic do - puts 'Running Foodcritic tests...' - FoodCritic::Rake::LintTask.new do |t| - t.options = { fail_tags: ['any'] } - puts 'done.' - end -end - -# Rubocop -desc 'Run Rubocop lint checks' -task :rubocop do - RuboCop::RakeTask.new +desc 'Run cookstyle on cookbooks in this repository' +task :cookstyle do + sh 'cookstyle --fail-level r' end # Automatically generate a changelog for this project. Only loaded if diff --git a/chefignore b/chefignore index 14e5f19..78f55cf 100644 --- a/chefignore +++ b/chefignore @@ -110,3 +110,4 @@ coverage/* Gemfile Gemfile.lock chefignore +.envrc