From 6a1830e860ff80ca138fbe48ee5ae2b2ebe94c66 Mon Sep 17 00:00:00 2001 From: Ashique P S Date: Mon, 13 Mar 2023 18:55:18 +0530 Subject: [PATCH 1/4] Fixed the false positive issue with CronDFileOrTemplate Signed-off-by: Ashique P S --- lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb b/lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb index 4d396ed7..0e7636a5 100644 --- a/lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb +++ b/lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb @@ -101,7 +101,7 @@ class CronDFileOrTemplate < Base def on_block(node) file_or_template?(node) do |file_name| - break unless file_name.start_with?('/etc/cron.d') + break unless file_name.match?(%r{/etc/cron\.d\b}i) add_offense(node, severity: :refactor) end @@ -110,7 +110,7 @@ def on_block(node) # and check if their value contains '/etc/cron.d' # covers the case where the argument to the path property is provided via a method like File.join code_property.each_descendant do |d| - add_offense(node, severity: :refactor) if d.respond_to?(:value) && d.value.match?(%r{/etc/cron\.d}i) + add_offense(node, severity: :refactor) if d.respond_to?(:value) && d.value.match?(%r{/etc/cron\.d\b}i) end end end From 2e55558372046418a1c14c43103fbc9ed7959eb6 Mon Sep 17 00:00:00 2001 From: Ashique P S Date: Wed, 15 Mar 2023 14:53:12 +0530 Subject: [PATCH 2/4] Replaced the match method with start_with Signed-off-by: Ashique P S --- lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb b/lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb index 0e7636a5..e2c82ff4 100644 --- a/lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb +++ b/lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb @@ -101,7 +101,7 @@ class CronDFileOrTemplate < Base def on_block(node) file_or_template?(node) do |file_name| - break unless file_name.match?(%r{/etc/cron\.d\b}i) + break unless file_name.start_with?(%r{/etc/cron\.d\b}i) add_offense(node, severity: :refactor) end From b5c56cda02db9a5dc3acef39b5a5f0df86fe029d Mon Sep 17 00:00:00 2001 From: Ashique P S Date: Mon, 20 Mar 2023 12:39:36 +0530 Subject: [PATCH 3/4] Github workflow fixes and updated the required ruby version to 2.7 Signed-off-by: Ashique P S --- .github/workflows/unit.yml | 4 ++-- cookstyle.gemspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 698cbe9b..ba865f76 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -13,10 +13,10 @@ jobs: fail-fast: false matrix: os: [windows-2019, ubuntu-latest] - ruby: ['2.5', '2.6', '2.7', '3.0', '3.1'] + ruby: ['2.7', '3.0', '3.1'] runs-on: ${{ matrix.os }} env: - BUNDLE_WITHOUT: profiling,debug,docs + BUNDLE_WITHOUT: profiling debug docs name: Unit test on ${{ matrix.os }} with Ruby ${{ matrix.ruby }} steps: - uses: actions/checkout@v2 diff --git a/cookstyle.gemspec b/cookstyle.gemspec index 50b78217..c53a1f9d 100644 --- a/cookstyle.gemspec +++ b/cookstyle.gemspec @@ -11,7 +11,7 @@ Gem::Specification.new do |spec| spec.summary = 'Cookstyle is a code linting tool that helps you to write better Chef Infra cookbooks by detecting and automatically correcting style, syntax, and logic mistakes in your code.' spec.license = 'Apache-2.0' spec.homepage = 'https://docs.chef.io/workstation/cookstyle/' - spec.required_ruby_version = '>= 2.5' + spec.required_ruby_version = '>= 2.7' # the gemspec and Gemfile are necessary for appbundling of the gem spec.files = %w(LICENSE cookstyle.gemspec Gemfile) + Dir.glob('{lib,bin,config}/**/*') From 7db63a3592566192f4d17fc94506e0a9d8320c4a Mon Sep 17 00:00:00 2001 From: Ashique P S Date: Mon, 20 Mar 2023 12:41:47 +0530 Subject: [PATCH 4/4] Updated the required ruby version on lint.yml file Signed-off-by: Ashique P S --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ea44b40b..6b6740b6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.5 + ruby-version: 2.7 bundler-cache: true - uses: r7kamura/rubocop-problem-matchers-action@v1 # this shows the failures in the PR - run: bundle exec cookstyle