From b42a621cff812c86c2b299c397c5baf7d0ba9d7c Mon Sep 17 00:00:00 2001 From: nikhil2611 Date: Wed, 9 Apr 2025 16:52:51 +0530 Subject: [PATCH 1/2] replacing the chefstyle to cookstyle Signed-off-by: nikhil2611 --- .expeditor/verify.pipeline.yml | 7 ------ .rubocop.yml | 14 +++++------ Gemfile | 1 - Rakefile | 23 ------------------- .../repo/cookbooks/example/recipes/default.rb | 2 +- 5 files changed, 8 insertions(+), 39 deletions(-) diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml index 724faebbc..b81b9e7ec 100644 --- a/.expeditor/verify.pipeline.yml +++ b/.expeditor/verify.pipeline.yml @@ -54,10 +54,3 @@ steps: docker: image: ruby:3.1 -- label: chefstyle-tests-ruby-3.1 - command: - - .expeditor/run_linux_tests.sh "rake style:chefstyle" - expeditor: - executor: - docker: - image: ruby:3.1 diff --git a/.rubocop.yml b/.rubocop.yml index 62ed74a22..7c47aa4ce 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,24 +1,24 @@ ---- -require: - - chefstyle - AllCops: TargetRubyVersion: 3.1 Include: - - "**/*.rb" + - "**/*.rb" Exclude: - - "vendor/**/*" - - "spec/**/*" + - "vendor/**/*" + - "spec/**/*" + Style/StringLiterals: Exclude: - "spec/unit/fixtures/**/*" - "lib/chef-cli/skeletons/**/*" + Layout/TrailingWhitespace: Exclude: - "spec/unit/fixtures/**/*" + Style/PercentLiteralDelimiters: Exclude: - "lib/chef-cli/skeletons/**/*" + Layout/TrailingEmptyLines: Exclude: - "spec/unit/fixtures/**/*" diff --git a/Gemfile b/Gemfile index d7097f9e0..8b3a32bd8 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,6 @@ group :test do gem "rspec-expectations", "~> 3.8" gem "rspec-mocks", "~> 3.8" gem "cookstyle" - gem "chefstyle" gem "faraday_middleware" gem "chef-test-kitchen-enterprise", git: "https://github.com/chef/chef-test-kitchen-enterprise", branch: "main" gem "simplecov", require: false diff --git a/Rakefile b/Rakefile index f25cfd7f5..403173531 100644 --- a/Rakefile +++ b/Rakefile @@ -30,28 +30,5 @@ namespace :style do rescue LoadError => e puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV["CI"] end - - begin - require "rubocop/rake_task" - - ignore_dirs = Regexp.union(%w{ - lib/chef-cli/skeletons/code_generator - spec/unit/fixtures/chef-runner-cookbooks - spec/unit/fixtures/cookbook_cache - spec/unit/fixtures/example_cookbook - spec/unit/fixtures/example_cookbook_metadata_json_only - spec/unit/fixtures/example_cookbook_no_metadata - spec/unit/fixtures/local_path_cookbooks - }) - - desc "Run Chef Ruby style checks" - RuboCop::RakeTask.new(:chefstyle) do |t| - t.requires = ["chefstyle"] - t.patterns = `rubocop --list-target-files`.split("\n").reject { |f| f =~ ignore_dirs } - t.options = ["--display-cop-names"] - end - rescue LoadError => e - puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV["CI"] - end end diff --git a/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb b/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb index 82f8fa310..e3f5f0e18 100644 --- a/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +++ b/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb @@ -1,7 +1,7 @@ # This is a Chef Infra Client recipe file. It can be used to specify resources # which will apply configuration to a server. -log "Welcome to Chef Infra Client, #{node["example"]["name"]}!" do +log "Welcome to Chef Infra Client, #{node['example']['name']}!" do level :info end From 119f4927e346db06b6c8dedabc8fe5c523501dfb Mon Sep 17 00:00:00 2001 From: nikhil2611 Date: Wed, 9 Apr 2025 18:44:20 +0530 Subject: [PATCH 2/2] fixing styling Signed-off-by: nikhil2611 --- Rakefile | 1 + .../files/default/repo/cookbooks/example/recipes/default.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 403173531..4b823da01 100644 --- a/Rakefile +++ b/Rakefile @@ -19,6 +19,7 @@ require "bundler/gem_tasks" namespace :style do begin + require "cookstyle/chefstyle" require "rubocop/rake_task" desc "Run Cookbook Ruby style checks" diff --git a/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb b/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb index e3f5f0e18..82f8fa310 100644 --- a/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +++ b/lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb @@ -1,7 +1,7 @@ # This is a Chef Infra Client recipe file. It can be used to specify resources # which will apply configuration to a server. -log "Welcome to Chef Infra Client, #{node['example']['name']}!" do +log "Welcome to Chef Infra Client, #{node["example"]["name"]}!" do level :info end