Skip to content

Commit 7cd4ac3

Browse files
committed
updating linting to use cookstyle and correct linting errors
Signed-off-by: John McCrae <john.mccrae@progress.com>
1 parent 5ec5aa7 commit 7cd4ac3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+276
-196
lines changed

components/ruby/.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Feel free to correct anything in this file
2+
3+
AllCops:
4+
TargetRubyVersion: 3.1

components/ruby/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source "https://rubygems.org"
33
gemspec
44

55
group :development do
6-
gem "chefstyle", "~> 2.2", ">= 2.2.2"
6+
gem "cookstyle", "~> 8.0"
77
gem "rake", "~> 13.0", ">= 13.0.6"
88
gem "rspec", "~> 3.11"
99
end

components/ruby/Gemfile.lock

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ GEM
2828
tomlrb (~> 1.2)
2929
chef-utils (18.8.46)
3030
concurrent-ruby
31-
chefstyle (2.2.3)
32-
rubocop (= 1.25.1)
3331
coderay (1.1.3)
3432
concurrent-ruby (1.3.5)
33+
cookstyle (8.5.0)
34+
rubocop (= 1.81.0)
3535
crack (1.0.0)
3636
bigdecimal
3737
rexml
@@ -67,20 +67,31 @@ GEM
6767
ffi (1.17.2-arm-linux-gnu)
6868
ffi (1.17.2-arm-linux-musl)
6969
ffi (1.17.2-arm64-darwin)
70+
ffi (1.17.2-x64-mingw-ucrt)
7071
ffi (1.17.2-x86-linux-gnu)
7172
ffi (1.17.2-x86-linux-musl)
7273
ffi (1.17.2-x86_64-darwin)
7374
ffi (1.17.2-x86_64-linux-gnu)
7475
ffi (1.17.2-x86_64-linux-musl)
76+
ffi-win32-extensions (1.0.4)
77+
ffi
7578
fuzzyurl (0.9.0)
7679
hashdiff (1.2.1)
80+
json (2.15.1)
81+
language_server-protocol (3.17.0.5)
82+
lint_roller (1.1.0)
7783
method_source (1.1.0)
7884
mixlib-config (3.0.27)
7985
tomlrb
8086
mixlib-log (3.2.3)
8187
ffi (>= 1.15.5)
8288
mixlib-shellout (3.3.9)
8389
chef-utils
90+
mixlib-shellout (3.3.9-x64-mingw-ucrt)
91+
chef-utils
92+
ffi-win32-extensions (~> 1.0.3)
93+
win32-process (~> 0.9)
94+
wmi-lite (~> 1.0)
8495
moneta (1.6.0)
8596
multipart-post (2.4.1)
8697
ostruct (0.1.0)
@@ -113,15 +124,17 @@ GEM
113124
diff-lcs (>= 1.2.0, < 2.0)
114125
rspec-support (~> 3.13.0)
115126
rspec-support (3.13.6)
116-
rubocop (1.25.1)
127+
rubocop (1.81.0)
128+
json (~> 2.3)
129+
language_server-protocol (~> 3.17.0.2)
130+
lint_roller (~> 1.1.0)
117131
parallel (~> 1.10)
118-
parser (>= 3.1.0.0)
132+
parser (>= 3.3.0.2)
119133
rainbow (>= 2.2.2, < 4.0)
120-
regexp_parser (>= 1.8, < 3.0)
121-
rexml
122-
rubocop-ast (>= 1.15.1, < 2.0)
134+
regexp_parser (>= 2.9.3, < 3.0)
135+
rubocop-ast (>= 1.47.1, < 2.0)
123136
ruby-progressbar (~> 1.7)
124-
unicode-display_width (>= 1.4.0, < 3.0)
137+
unicode-display_width (>= 2.4.0, < 4.0)
125138
rubocop-ast (1.47.1)
126139
parser (>= 3.3.7.2)
127140
prism (~> 1.4)
@@ -145,7 +158,10 @@ GEM
145158
addressable (>= 2.8.0)
146159
crack (>= 0.3.2)
147160
hashdiff (>= 0.4.0, < 2.0.0)
161+
win32-process (0.10.0)
162+
ffi (>= 1.0.0)
148163
wisper (2.0.1)
164+
wmi-lite (1.0.7)
149165

150166
PLATFORMS
151167
aarch64-linux-gnu
@@ -154,6 +170,7 @@ PLATFORMS
154170
arm-linux-musl
155171
arm64-darwin
156172
ruby
173+
x64-mingw-ucrt
157174
x86-linux-gnu
158175
x86-linux-musl
159176
x86_64-darwin
@@ -163,7 +180,7 @@ PLATFORMS
163180
DEPENDENCIES
164181
byebug
165182
chef-licensing!
166-
chefstyle (~> 2.2, >= 2.2.2)
183+
cookstyle (~> 8.0)
167184
pry
168185
rake (~> 13.0, >= 13.0.6)
169186
rspec (~> 3.11)

components/ruby/Rakefile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ require "rspec/core/rake_task"
33

44
RSpec::Core::RakeTask.new(:spec)
55

6-
begin
7-
require "chefstyle"
6+
desc "Check Linting and code style."
7+
task :style do
88
require "rubocop/rake_task"
9-
desc "Run Chefstyle tests"
10-
RuboCop::RakeTask.new(:style) do |task|
11-
task.options += %w{ --display-cop-names --no-color }
9+
require "cookstyle/chefstyle"
10+
11+
if RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
12+
# Windows-specific command, rubocop erroneously reports the CRLF in each file which is removed when your PR is uploaeded to GitHub.
13+
# This is a workaround to ignore the CRLF from the files before running cookstyle.
14+
sh "cookstyle --chefstyle -c .rubocop.yml --except Layout/EndOfLine"
15+
else
16+
sh "cookstyle --chefstyle -c .rubocop.yml"
1217
end
1318
rescue LoadError
14-
puts "chefstyle gem is not installed. bundle install first to make sure all dependencies are installed."
19+
puts "Rubocop or Cookstyle gems are not installed. bundle install first to make sure all dependencies are installed."
1520
end
1621

1722
task default: :spec

components/ruby/bin/test-app

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ ChefLicensing::LicenseKeyFetcher.fetch_and_persist(logger: logger).each do |lice
1616
puts "License Key: #{license_key}"
1717
end
1818

19-
puts "Airgap is " + (ChefLicensing.air_gap_detected? ? true : false)
19+
puts "Airgap is " + (ChefLicensing.air_gap_detected? || false)

components/ruby/chef-licensing.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
1919

2020
# Specify which files should be added to the gem when it is released.
2121
spec.files =
22-
Dir.glob("{{lib,etc}/**/*,LICENSE,chef-licensing.gemspec}")
23-
.reject { |f| File.directory?(f) }
22+
Dir.glob("{{lib,etc}/**/*,LICENSE,chef-licensing.gemspec}")
23+
.reject { |f| File.directory?(f) }
2424

2525
spec.bindir = "exe"
2626
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }

components/ruby/lib/chef-licensing.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def check_software_entitlement!
4141
unless ChefLicensing::Config.make_licensing_optional
4242
if license_keys.empty?
4343
raise ChefLicensing::LicenseKeyFetcher::LicenseKeyNotFetchedError,
44-
"Unable to obtain a License Key."
44+
"Unable to obtain a License Key."
4545
end
4646

4747
client(license_keys: license_keys)

components/ruby/lib/chef-licensing/api/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ def info
3636
attr_reader :restful_client
3737
end
3838
end
39-
end
39+
end

components/ruby/lib/chef-licensing/api/describe.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ def get_describe_api_response_data
5959
end
6060
end
6161
end
62-
end
62+
end

components/ruby/lib/chef-licensing/api/license_feature_entitlement.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ def build_payload
5252
end
5353
end
5454
end
55-
end
55+
end

0 commit comments

Comments
 (0)