Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: run cookstyle #281

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- '*'

jobs:
linting:
cookstyle:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ coverage
exp.*
pkg/
shared_test_repo/
.envrc

# Berkshelf
.vagrant
Expand Down
6 changes: 4 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
inherit_from: .rubocop_todo.yml

AllCops:
DisplayCopNames: true
Exclude:
Expand All @@ -7,7 +9,7 @@ AllCops:
TargetRubyVersion: 2.5
Metrics/AbcSize:
Max: 29
Metrics/LineLength:
Layout/LineLength:
Max: 100
Include:
- spec/**/*.rb
Expand All @@ -17,7 +19,7 @@ Style/Documentation:
Enabled: false
Layout/DotPosition:
EnforcedStyle: trailing
Layout/AlignHash:
Layout/HashAlignment:
EnforcedHashRocketStyle: table
EnforcedColonStyle: table
Style/NumericLiterals:
Expand Down
114 changes: 114 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 0 additions & 20 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 4 additions & 17 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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'
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions chefignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,4 @@ coverage/*
Gemfile
Gemfile.lock
chefignore
.envrc