summaryrefslogtreecommitdiff
path: root/lib/chef/provider
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-01-15 13:07:58 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2019-01-15 13:07:58 -0800
commit990974ca5cd44df0c77bb6a12fc57a3c32b92e23 (patch)
tree5779719f58254764e57eb9cacde85837295fd2f6 /lib/chef/provider
parent4be1ebe66460efb0535e500d6ecb52a147346519 (diff)
downloadchef-990974ca5cd44df0c77bb6a12fc57a3c32b92e23.tar.gz
changes for rubocop engine upgrades.lcg/rubocop-upgrades
this is the result of changes to rules we already previously had enabled. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/provider')
-rw-r--r--lib/chef/provider/cron.rb6
-rw-r--r--lib/chef/provider/git.rb36
-rw-r--r--lib/chef/provider/package/apt.rb6
-rw-r--r--lib/chef/provider/package/chocolatey.rb2
-rw-r--r--lib/chef/provider/package/dnf/python_helper.rb4
-rw-r--r--lib/chef/provider/package/dpkg.rb6
-rw-r--r--lib/chef/provider/package/portage.rb2
-rw-r--r--lib/chef/provider/package/rubygems.rb2
-rw-r--r--lib/chef/provider/package/yum/rpm_utils.rb20
-rw-r--r--lib/chef/provider/powershell_script.rb4
-rw-r--r--lib/chef/provider/route.rb66
-rw-r--r--lib/chef/provider/service/aixinit.rb2
-rw-r--r--lib/chef/provider/service/debian.rb4
-rw-r--r--lib/chef/provider/service/redhat.rb4
-rw-r--r--lib/chef/provider/service/upstart.rb2
-rw-r--r--lib/chef/provider/subversion.rb2
-rw-r--r--lib/chef/provider/windows_task.rb30
17 files changed, 94 insertions, 104 deletions
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb
index f25a58a789..79245df475 100644
--- a/lib/chef/provider/cron.rb
+++ b/lib/chef/provider/cron.rb
@@ -29,9 +29,9 @@ class Chef
CRON_ATTRIBUTES = [:minute, :hour, :day, :month, :weekday, :time, :command, :mailto, :path, :shell, :home, :environment].freeze
WEEKDAY_SYMBOLS = [:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday].freeze
- CRON_PATTERN = /\A([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+|[a-zA-Z]{3})\s([-0-9*,\/]+|[a-zA-Z]{3})\s(.*)/
- SPECIAL_PATTERN = /\A(@(#{SPECIAL_TIME_VALUES.join('|')}))\s(.*)/
- ENV_PATTERN = /\A(\S+)=(\S*)/
+ CRON_PATTERN = /\A([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+|[a-zA-Z]{3})\s([-0-9*,\/]+|[a-zA-Z]{3})\s(.*)/.freeze
+ SPECIAL_PATTERN = /\A(@(#{SPECIAL_TIME_VALUES.join('|')}))\s(.*)/.freeze
+ ENV_PATTERN = /\A(\S+)=(\S*)/.freeze
def initialize(new_resource, run_context)
super(new_resource, run_context)
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb
index 5845f869d8..4d27e1a52e 100644
--- a/lib/chef/provider/git.rb
+++ b/lib/chef/provider/git.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@kallistec.com>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -234,13 +234,14 @@ class Chef
end
def target_revision
- @target_revision ||= begin
- if sha_hash?(new_resource.revision)
- @target_revision = new_resource.revision
- else
- @target_revision = remote_resolve_reference
+ @target_revision ||=
+ begin
+ if sha_hash?(new_resource.revision)
+ @target_revision = new_resource.revision
+ else
+ @target_revision = remote_resolve_reference
+ end
end
- end
end
alias :revision_slug :target_revision
@@ -311,17 +312,18 @@ class Chef
# Certain versions of `git` misbehave if git configuration is
# inaccessible in $HOME. We need to ensure $HOME matches the
# user who is executing `git` not the user running Chef.
- env["HOME"] = begin
- require "etc"
- case new_resource.user
- when Integer
- Etc.getpwuid(new_resource.user).dir
- else
- Etc.getpwnam(new_resource.user.to_s).dir
+ env["HOME"] =
+ begin
+ require "etc"
+ case new_resource.user
+ when Integer
+ Etc.getpwuid(new_resource.user).dir
+ else
+ Etc.getpwnam(new_resource.user.to_s).dir
+ end
+ rescue ArgumentError # user not found
+ raise Chef::Exceptions::User, "Could not determine HOME for specified user '#{new_resource.user}' for resource '#{new_resource.name}'"
end
- rescue ArgumentError # user not found
- raise Chef::Exceptions::User, "Could not determine HOME for specified user '#{new_resource.user}' for resource '#{new_resource.name}'"
- end
end
run_opts[:group] = new_resource.group if new_resource.group
env["GIT_SSH"] = new_resource.ssh_wrapper if new_resource.ssh_wrapper
diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb
index de1b106d45..dfc7e602dd 100644
--- a/lib/chef/provider/package/apt.rb
+++ b/lib/chef/provider/package/apt.rb
@@ -237,9 +237,9 @@ class Chef
end
{
- current_version: current_version,
- candidate_version: candidate_version,
- virtual: virtual,
+ current_version: current_version,
+ candidate_version: candidate_version,
+ virtual: virtual,
}
end
diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb
index 4c35d13a07..20831ac891 100644
--- a/lib/chef/provider/package/chocolatey.rb
+++ b/lib/chef/provider/package/chocolatey.rb
@@ -37,7 +37,7 @@ class Chef
If Chocolatey is installed, ensure that the 'ChocolateyInstall' environment
variable is correctly set. You can verify this with the PowerShell command
'#{PATHFINDING_POWERSHELL_COMMAND}'.
-EOS
+ EOS
# Responsible for building the current_resource.
#
diff --git a/lib/chef/provider/package/dnf/python_helper.rb b/lib/chef/provider/package/dnf/python_helper.rb
index 56706764d0..7cb4047f53 100644
--- a/lib/chef/provider/package/dnf/python_helper.rb
+++ b/lib/chef/provider/package/dnf/python_helper.rb
@@ -132,9 +132,7 @@ class Chef
def drain_stderr
output = ""
- until IO.select([stderr], nil, nil, 0).nil?
- output += stderr.sysread(4096).chomp
- end
+ output += stderr.sysread(4096).chomp until IO.select([stderr], nil, nil, 0).nil?
output
rescue
# we must rescue EOFError, and we don't much care about errors on stderr anyway
diff --git a/lib/chef/provider/package/dpkg.rb b/lib/chef/provider/package/dpkg.rb
index de5b2858e7..38129c8931 100644
--- a/lib/chef/provider/package/dpkg.rb
+++ b/lib/chef/provider/package/dpkg.rb
@@ -23,9 +23,9 @@ class Chef
class Provider
class Package
class Dpkg < Chef::Provider::Package
- DPKG_REMOVED = /^Status: deinstall ok config-files/
- DPKG_INSTALLED = /^Status: install ok installed/
- DPKG_VERSION = /^Version: (.+)$/
+ DPKG_REMOVED = /^Status: deinstall ok config-files/.freeze
+ DPKG_INSTALLED = /^Status: install ok installed/.freeze
+ DPKG_VERSION = /^Version: (.+)$/.freeze
provides :dpkg_package
diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb
index 11cbe99d18..d9fc801225 100644
--- a/lib/chef/provider/package/portage.rb
+++ b/lib/chef/provider/package/portage.rb
@@ -28,7 +28,7 @@ class Chef
provides :package, platform: "gentoo"
provides :portage_package
- PACKAGE_NAME_PATTERN = %r{(?:([^/]+)/)?([^/]+)}
+ PACKAGE_NAME_PATTERN = %r{(?:([^/]+)/)?([^/]+)}.freeze
def load_current_resource
@current_resource = Chef::Resource::PortagePackage.new(new_resource.name)
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index cd595e64f4..dc882e426c 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -281,7 +281,7 @@ class Chef
end
class AlternateGemEnvironment < GemEnvironment
- JRUBY_PLATFORM = /(:?universal|x86_64|x86)\-java\-[0-9\.]+/
+ JRUBY_PLATFORM = /(:?universal|x86_64|x86)\-java\-[0-9\.]+/.freeze
def self.gempath_cache
@gempath_cache ||= {}
diff --git a/lib/chef/provider/package/yum/rpm_utils.rb b/lib/chef/provider/package/yum/rpm_utils.rb
index eefc0b95b2..22c0ff807b 100644
--- a/lib/chef/provider/package/yum/rpm_utils.rb
+++ b/lib/chef/provider/package/yum/rpm_utils.rb
@@ -133,9 +133,7 @@ class Chef
while (x_pos <= x_pos_max) && (isalnum(x[x_pos]) == false)
x_pos += 1 # +1 over pos_max if end of string
end
- while (y_pos <= y_pos_max) && (isalnum(y[y_pos]) == false)
- y_pos += 1
- end
+ y_pos += 1 while (y_pos <= y_pos_max) && (isalnum(y[y_pos]) == false)
# if we hit the end of either we are done matching segments
if (x_pos == x_pos_max + 1) || (y_pos == y_pos_max + 1)
@@ -154,29 +152,21 @@ class Chef
x_seg_pos += 1
# gather up our digits
- while (x_seg_pos <= x_pos_max) && isdigit(x[x_seg_pos])
- x_seg_pos += 1
- end
+ x_seg_pos += 1 while (x_seg_pos <= x_pos_max) && isdigit(x[x_seg_pos])
# copy the segment but not the unmatched character that x_seg_pos will
# refer to
x_comp = x[x_pos, x_seg_pos - x_pos]
- while (y_seg_pos <= y_pos_max) && isdigit(y[y_seg_pos])
- y_seg_pos += 1
- end
+ y_seg_pos += 1 while (y_seg_pos <= y_pos_max) && isdigit(y[y_seg_pos])
y_comp = y[y_pos, y_seg_pos - y_pos]
else
# we are comparing strings
x_seg_is_num = false
- while (x_seg_pos <= x_pos_max) && isalpha(x[x_seg_pos])
- x_seg_pos += 1
- end
+ x_seg_pos += 1 while (x_seg_pos <= x_pos_max) && isalpha(x[x_seg_pos])
x_comp = x[x_pos, x_seg_pos - x_pos]
- while (y_seg_pos <= y_pos_max) && isalpha(y[y_seg_pos])
- y_seg_pos += 1
- end
+ y_seg_pos += 1 while (y_seg_pos <= y_pos_max) && isalpha(y[y_seg_pos])
y_comp = y[y_pos, y_seg_pos - y_pos]
end
diff --git a/lib/chef/provider/powershell_script.rb b/lib/chef/provider/powershell_script.rb
index 529ae409d8..a903f83107 100644
--- a/lib/chef/provider/powershell_script.rb
+++ b/lib/chef/provider/powershell_script.rb
@@ -89,7 +89,7 @@ class Chef
{
#{new_resource.code}
}
-EOH
+ EOH
user_script_file.puts user_code_wrapped_in_powershell_script_block
# A .close or explicit .flush required to ensure the file is
@@ -215,7 +215,7 @@ EOH
# launched with -Command, it will be 0 if $exitstatus was 0,
# 1 (i.e. failed) otherwise.
exit $exitstatus
-EOH
+ EOH
end
end
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb
index b8af9e55b8..e20102e2f3 100644
--- a/lib/chef/provider/route.rb
+++ b/lib/chef/provider/route.rb
@@ -28,39 +28,39 @@ class Chef
attr_accessor :is_running
- MASK = { "0.0.0.0" => "0",
- "128.0.0.0" => "1",
- "192.0.0.0" => "2",
- "224.0.0.0" => "3",
- "240.0.0.0" => "4",
- "248.0.0.0" => "5",
- "252.0.0.0" => "6",
- "254.0.0.0" => "7",
- "255.0.0.0" => "8",
- "255.128.0.0" => "9",
- "255.192.0.0" => "10",
- "255.224.0.0" => "11",
- "255.240.0.0" => "12",
- "255.248.0.0" => "13",
- "255.252.0.0" => "14",
- "255.254.0.0" => "15",
- "255.255.0.0" => "16",
- "255.255.128.0" => "17",
- "255.255.192.0" => "18",
- "255.255.224.0" => "19",
- "255.255.240.0" => "20",
- "255.255.248.0" => "21",
- "255.255.252.0" => "22",
- "255.255.254.0" => "23",
- "255.255.255.0" => "24",
- "255.255.255.128" => "25",
- "255.255.255.192" => "26",
- "255.255.255.224" => "27",
- "255.255.255.240" => "28",
- "255.255.255.248" => "29",
- "255.255.255.252" => "30",
- "255.255.255.254" => "31",
- "255.255.255.255" => "32" }.freeze
+ MASK = { "0.0.0.0" => "0",
+ "128.0.0.0" => "1",
+ "192.0.0.0" => "2",
+ "224.0.0.0" => "3",
+ "240.0.0.0" => "4",
+ "248.0.0.0" => "5",
+ "252.0.0.0" => "6",
+ "254.0.0.0" => "7",
+ "255.0.0.0" => "8",
+ "255.128.0.0" => "9",
+ "255.192.0.0" => "10",
+ "255.224.0.0" => "11",
+ "255.240.0.0" => "12",
+ "255.248.0.0" => "13",
+ "255.252.0.0" => "14",
+ "255.254.0.0" => "15",
+ "255.255.0.0" => "16",
+ "255.255.128.0" => "17",
+ "255.255.192.0" => "18",
+ "255.255.224.0" => "19",
+ "255.255.240.0" => "20",
+ "255.255.248.0" => "21",
+ "255.255.252.0" => "22",
+ "255.255.254.0" => "23",
+ "255.255.255.0" => "24",
+ "255.255.255.128" => "25",
+ "255.255.255.192" => "26",
+ "255.255.255.224" => "27",
+ "255.255.255.240" => "28",
+ "255.255.255.248" => "29",
+ "255.255.255.252" => "30",
+ "255.255.255.254" => "31",
+ "255.255.255.255" => "32" }.freeze
def hex2ip(hex_data)
# Cleanup hex data
diff --git a/lib/chef/provider/service/aixinit.rb b/lib/chef/provider/service/aixinit.rb
index dd8514cf20..43e6b3ac1b 100644
--- a/lib/chef/provider/service/aixinit.rb
+++ b/lib/chef/provider/service/aixinit.rb
@@ -22,7 +22,7 @@ class Chef
class Provider
class Service
class AixInit < Chef::Provider::Service::Init
- RC_D_SCRIPT_NAME = /\/etc\/rc.d\/rc2.d\/([SK])(\d\d|)/i
+ RC_D_SCRIPT_NAME = /\/etc\/rc.d\/rc2.d\/([SK])(\d\d|)/i.freeze
def initialize(new_resource, run_context)
super
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb
index 351075111b..b6a938a7e8 100644
--- a/lib/chef/provider/service/debian.rb
+++ b/lib/chef/provider/service/debian.rb
@@ -26,8 +26,8 @@ class Chef
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:debian)
end
- UPDATE_RC_D_ENABLED_MATCHES = /\/rc[\dS].d\/S|not installed/i
- UPDATE_RC_D_PRIORITIES = /\/rc([\dS]).d\/([SK])(\d\d)/i
+ UPDATE_RC_D_ENABLED_MATCHES = /\/rc[\dS].d\/S|not installed/i.freeze
+ UPDATE_RC_D_PRIORITIES = /\/rc([\dS]).d\/([SK])(\d\d)/i.freeze
def self.supports?(resource, action)
Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:initd)
diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb
index 18ef245083..9e8ff30216 100644
--- a/lib/chef/provider/service/redhat.rb
+++ b/lib/chef/provider/service/redhat.rb
@@ -32,8 +32,8 @@ class Chef
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:redhat)
end
- CHKCONFIG_ON = /\d:on/
- CHKCONFIG_MISSING = /No such/
+ CHKCONFIG_ON = /\d:on/.freeze
+ CHKCONFIG_MISSING = /No such/.freeze
def self.supports?(resource, action)
Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:initd)
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb
index 68f97d1ff2..96ed16dc8f 100644
--- a/lib/chef/provider/service/upstart.rb
+++ b/lib/chef/provider/service/upstart.rb
@@ -32,7 +32,7 @@ class Chef
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:upstart)
end
- UPSTART_STATE_FORMAT = /\S+ \(?(start|stop)?\)? ?[\/ ](\w+)/
+ UPSTART_STATE_FORMAT = /\S+ \(?(start|stop)?\)? ?[\/ ](\w+)/.freeze
# Returns true if the configs for the service name has upstart variable
def self.supports?(resource, action)
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb
index dec9e06f87..adea6a6428 100644
--- a/lib/chef/provider/subversion.rb
+++ b/lib/chef/provider/subversion.rb
@@ -29,7 +29,7 @@ class Chef
provides :subversion
- SVN_INFO_PATTERN = /^([\w\s]+): (.+)$/
+ SVN_INFO_PATTERN = /^([\w\s]+): (.+)$/.freeze
include ChefConfig::Mixin::FuzzyHostnameMatcher
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb
index 1d77c6867b..c656506138 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -347,21 +347,21 @@ class Chef
flag = true
else
flag = true if start_day_updated?(current_task_trigger, new_task_trigger) == true ||
- start_time_updated?(current_task_trigger, new_task_trigger) == true ||
- current_task_trigger[:trigger_type] != new_task_trigger[:trigger_type] ||
- current_task_trigger[:type] != new_task_trigger[:type] ||
- current_task_trigger[:random_minutes_interval].to_i != new_task_trigger[:random_minutes_interval].to_i ||
- current_task_trigger[:minutes_interval].to_i != new_task_trigger[:minutes_interval].to_i ||
- task.account_information.to_s.casecmp(new_resource.user.to_s) != 0 ||
- task.application_name != new_resource.command ||
- description_needs_update?(task) ||
- task.parameters != new_resource.command_arguments.to_s ||
- task.working_directory != new_resource.cwd.to_s ||
- task.principals[:logon_type] != logon_type ||
- task.principals[:run_level] != run_level ||
- PRIORITY[task.priority] != new_resource.priority ||
- task.settings[:disallow_start_if_on_batteries] != new_resource.disallow_start_if_on_batteries ||
- task.settings[:stop_if_going_on_batteries] != new_resource.stop_if_going_on_batteries
+ start_time_updated?(current_task_trigger, new_task_trigger) == true ||
+ current_task_trigger[:trigger_type] != new_task_trigger[:trigger_type] ||
+ current_task_trigger[:type] != new_task_trigger[:type] ||
+ current_task_trigger[:random_minutes_interval].to_i != new_task_trigger[:random_minutes_interval].to_i ||
+ current_task_trigger[:minutes_interval].to_i != new_task_trigger[:minutes_interval].to_i ||
+ task.account_information.to_s.casecmp(new_resource.user.to_s) != 0 ||
+ task.application_name != new_resource.command ||
+ description_needs_update?(task) ||
+ task.parameters != new_resource.command_arguments.to_s ||
+ task.working_directory != new_resource.cwd.to_s ||
+ task.principals[:logon_type] != logon_type ||
+ task.principals[:run_level] != run_level ||
+ PRIORITY[task.priority] != new_resource.priority ||
+ task.settings[:disallow_start_if_on_batteries] != new_resource.disallow_start_if_on_batteries ||
+ task.settings[:stop_if_going_on_batteries] != new_resource.stop_if_going_on_batteries
if trigger_type == TaskScheduler::MONTHLYDATE
flag = true if current_task_trigger[:run_on_last_day_of_month] != new_task_trigger[:run_on_last_day_of_month]
end