Skip to content

Commit

Permalink
feat: Target Ruby 3.1 with rubocop
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Webb <dan.webb@damacus.io>
  • Loading branch information
damacus committed Nov 27, 2023
1 parent 746fbe2 commit ae0723b
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 34 deletions.
8 changes: 8 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
default: true

Check warning on line 1 in .markdownlint.yaml

View workflow job for this annotation

GitHub Actions / lint-unit / yamllint

1:1 [document-start] missing document start "---"
MD013: false
MD024: false
MD026: false
MD036: false
MD012: false
MD029: false
MD004: false
14 changes: 8 additions & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
require:

Check warning on line 1 in .rubocop.yml

View workflow job for this annotation

GitHub Actions / lint-unit / yamllint

1:1 [document-start] missing document start "---"
- chefstyle

AllCops:
TargetRubyVersion: 2.7
Naming/FileName:
TargetRubyVersion: 3.1
Include:
- "**/*.rb"
Exclude:
- 'support/**/*'
Layout/EndOfLine:
EnforcedStyle: lf
- "vendor/**/*"
- "spec/**/*"
2 changes: 1 addition & 1 deletion lib/kitchen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def default_file_logger(level = nil, log_overwrite = nil)
stdout: $stdout,
logdev: log_location,
level: Util.to_logger_level(level),
log_overwrite: log_overwrite
log_overwrite:
)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/kitchen/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def perform(task, command, args = nil, additional_options = {})
action: task,
help: -> { help(task) },
config: @config,
shell: shell,
shell:,
}.merge(additional_options)

str_const = Thor::Util.camel_case(command)
Expand Down
2 changes: 1 addition & 1 deletion lib/kitchen/command/diagnose.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def call
loader = record_failure { load_loader }

puts YAML.dump(Kitchen::Diagnostic.new(
loader: loader, instances: instances, plugins: plugins?
loader:, instances:, plugins: plugins?
).read)
end

Expand Down
16 changes: 8 additions & 8 deletions lib/kitchen/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ def kitchen_config
/^win/i.match?(platform) ? "winrm" : Transport::DEFAULT_PLUGIN
end,
},
kitchen_root: kitchen_root,
test_base_path: test_base_path,
log_level: log_level,
log_overwrite: log_overwrite,
debug: debug,
kitchen_root:,
test_base_path:,
log_level:,
log_overwrite:,
debug:,
}
end

Expand Down Expand Up @@ -250,8 +250,8 @@ def new_instance(suite, platform, index)
driver: new_driver(suite, platform),
lifecycle_hooks: new_lifecycle_hooks(suite, platform, sf),
logger: new_instance_logger(suite, platform, index),
suite: suite,
platform: platform,
suite:,
platform:,
provisioner: new_provisioner(suite, platform),
transport: new_transport(suite, platform),
verifier: new_verifier(suite, platform),
Expand All @@ -275,7 +275,7 @@ def new_instance_logger(suite, platform, index)
color: Color::COLORS[index % Color::COLORS.size].to_sym,
logdev: log_location,
level: Util.to_logger_level(log_level),
log_overwrite: log_overwrite,
log_overwrite:,
progname: name,
colorize: @colorize
)
Expand Down
2 changes: 1 addition & 1 deletion lib/kitchen/driver/ssh_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def transfer_path_async(locals, remote, connection)
# @param options [Hash] configuration hash (default: `{}`)
# @api private
def wait_for_sshd(hostname, username = nil, options = {})
pseudo_state = { hostname: hostname }
pseudo_state = { hostname: }
pseudo_state[:username] = username if username
pseudo_state.merge!(options)

Expand Down
2 changes: 1 addition & 1 deletion lib/kitchen/lifecycle_hook/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def run
config[:kitchen_root]
end
# Build the options for mixlib-shellout.
opts = {}.merge(user).merge(cwd: cwd, environment: environment)
opts = {}.merge(user).merge(cwd:, environment:)
run_command(command, opts)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/kitchen/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def windows?(options)
#
# @return [Hash] a diagnostic hash
def diagnose
{ os_type: os_type, shell_type: shell_type }
{ os_type:, shell_type: }
end
end
end
2 changes: 1 addition & 1 deletion lib/kitchen/platform_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module Kitchen
# @author Baptiste Courtois <b.courtois@criteo.com>
class PlatformFilter
# Pattern used to determine whether a filter should be handled as a Regexp
REGEXP_LIKE_PATTERN = %r{^/(?<pattern>.*)/(?<options>[ix]*)$}.freeze
REGEXP_LIKE_PATTERN = %r{^/(?<pattern>.*)/(?<options>[ix]*)$}

# Converts platform filters into an array of PlatformFilter handling both strings and Regexp.
# A string "looks-like" a regexp if it starts by / and end by / + Regexp options i or x
Expand Down
10 changes: 5 additions & 5 deletions lib/kitchen/provisioner/chef/common_sandbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,17 @@ def prepare_json
def update_dna_for_policyfile
policy = Chef::Policyfile.new(
policyfile, sandbox_path,
logger: logger,
logger:,
always_update: config[:always_update_cookbooks],
policy_group: policy_group,
policy_group:,
license: config[:chef_license]
)
Kitchen.mutex.synchronize do
policy.compile
end
policy_name = JSON.parse(IO.read(policy.lockfile))["name"]
policy_group = config[:policy_group] || "local"
config[:attributes].merge(policy_name: policy_name, policy_group: policy_group)
config[:attributes].merge(policy_name:, policy_group:)
end

# Performs a Policyfile cookbook resolution inside a common mutex.
Expand All @@ -307,7 +307,7 @@ def resolve_with_policyfile
Kitchen.mutex.synchronize do
Chef::Policyfile.new(
policyfile, sandbox_path,
logger: logger,
logger:,
always_update: config[:always_update_cookbooks],
policy_group: config[:policy_group],
license: config[:chef_license]
Expand All @@ -321,7 +321,7 @@ def resolve_with_policyfile
def resolve_with_berkshelf
Kitchen.mutex.synchronize do
Chef::Berkshelf.new(berksfile, tmpbooks_dir,
logger: logger,
logger:,
always_update: config[:always_update_cookbooks]).resolve
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/kitchen/provisioner/chef_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def install_options
omnibus_url: config[:chef_omnibus_url],
project: project.nil? ? nil : project[1],
install_flags: config[:chef_omnibus_install_options],
sudo_command: sudo_command,
sudo_command:,
}.tap do |opts|
opts[:root] = config[:chef_omnibus_root] if config.key? :chef_omnibus_root
%i{install_msi_url http_proxy https_proxy}.each do |key|
Expand Down Expand Up @@ -482,10 +482,10 @@ def load_needed_dependencies!
super
if File.exist?(policyfile)
debug("Policyfile found at #{policyfile}, using Policyfile to resolve cookbook dependencies")
Chef::Policyfile.load!(logger: logger)
Chef::Policyfile.load!(logger:)
elsif File.exist?(berksfile)
debug("Berksfile found at #{berksfile}, using Berkshelf to resolve cookbook dependencies")
Chef::Berkshelf.load!(logger: logger)
Chef::Berkshelf.load!(logger:)
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/kitchen/transport/ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def wait_until_ready
delay = 3
session(
retries: max_wait_until_ready / delay,
delay: delay,
delay:,
message: "Waiting for SSH service on #{hostname}:#{port}, " \
"retrying in #{delay} seconds"
)
Expand Down Expand Up @@ -468,7 +468,7 @@ def to_s
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def connection_options(data)
opts = {
logger: logger,
logger:,
user_known_hosts_file: "/dev/null",
hostname: data[:hostname],
port: data[:port],
Expand Down
6 changes: 3 additions & 3 deletions lib/kitchen/transport/winrm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ def connection_options(data)
opts = {
instance_name: instance.name,
kitchen_root: data[:kitchen_root],
logger: logger,
endpoint: endpoint,
logger:,
endpoint:,
user: data[:username],
password: data[:password],
rdp_port: data[:rdp_port],
Expand All @@ -457,7 +457,7 @@ def connection_options(data)
transport: data[:winrm_transport],
elevated: data[:elevated],
elevated_username: data[:elevated_username] || data[:username],
elevated_password: elevated_password,
elevated_password:,
}
opts.merge!(additional_transport_args(data, opts[:transport]))
if opts[:transport].to_sym == :ssl && opts.key?(:client_cert) && opts.key?(:client_key)
Expand Down
8 changes: 8 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended",
":disableDependencyDashboard",
"schedule:automergeEarlyMondays"
]
}

0 comments on commit ae0723b

Please sign in to comment.