Skip to content

Commit

Permalink
Add chefstyle library file for Rake backwards compatibility
Browse files Browse the repository at this point in the history
There's a decent amount of Rake code that uses `require "chefstyle"` to set the
defaults for RuboCop (eg
https://github.com/chef/ohai/blob/6d64237f9987c3bf51805e19884e6e710c3a40f6/Rakefile#L19),
and rather than doing surgery on each repo's Rakefile, it'd be easier to keep
that same behavior for loading the configuration and cops. With this change
a migration involving Rake should only involve a Gemfile update and changing
`require "chefstyle"` to `require "cookstyle/chefstyle"`.

Signed-off-by: David Crosby <[email protected]>
  • Loading branch information
dafyddcrosby committed Jan 30, 2024
1 parent ace8dd0 commit 626c232
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 6 additions & 7 deletions bin/cookstyle
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

if ARGV.include?('--chefstyle')
ARGV.delete('--chefstyle')
module Cookstyle
CHEFSTYLE_CONFIG = true
end
end

Check failure on line 4 in bin/cookstyle

View workflow job for this annotation

GitHub Actions / cookstyle

[Correctable] Layout/EmptyLines: Extra blank line detected. (https://rubystyle.guide#two-or-more-empty-lines)
$LOAD_PATH.unshift File.join(__dir__, %w(.. lib))

require 'cookstyle'
if ARGV.include?('--chefstyle')
ARGV.delete('--chefstyle')
require 'cookstyle/chefstyle'
else
require 'cookstyle'
end

# force the fail level to :convention so that we can set all our new rules to
# the lowest level of :refactor without failing everyone's CI jobs
Expand Down
4 changes: 4 additions & 0 deletions lib/cookstyle/chefstyle.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Cookstyle

Check failure on line 1 in lib/cookstyle/chefstyle.rb

View workflow job for this annotation

GitHub Actions / cookstyle

[Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
CHEFSTYLE_CONFIG = true
end
require_relative '../cookstyle'

0 comments on commit 626c232

Please sign in to comment.