Skip to content

Commit

Permalink
Layout/SpaceAfterComma
Browse files Browse the repository at this point in the history
This commit enables the Rubocop Layout/SpaceAfterComma cop and addresses
all offenses.
  • Loading branch information
mhashizume committed Jan 8, 2024
1 parent 2d3512a commit 729e89b
Show file tree
Hide file tree
Showing 168 changed files with 367 additions and 371 deletions.
4 changes: 0 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ I18n/GetText/DecorateStringFormattingUsingPercent:
I18n/RailsI18n/DecorateString:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
Layout/SpaceAfterComma:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
Layout/SpaceAfterNot:
Enabled: false
Expand Down
8 changes: 4 additions & 4 deletions ext/windows/service/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def service_main(*argsv)

if (@LOG_TO_FILE)
FileUtils.mkdir_p(File.dirname(LOG_FILE))
args = args.gsub("--logtofile","")
args = args.gsub("--logtofile", "")
end

base_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
Expand Down Expand Up @@ -141,7 +141,7 @@ def log(msg, level)
end
end

def report_windows_event(type,id,message)
def report_windows_event(type, id, message)
begin
eventlog = nil
eventlog = Puppet::Util::Windows::EventLog.open("Puppet")
Expand Down Expand Up @@ -174,7 +174,7 @@ def parse_runinterval(puppet_path)
runinterval
end

def parse_log_level(puppet_path,cmdline_debug)
def parse_log_level(puppet_path, cmdline_debug)
begin
loglevel = %x{ #{puppet_path} config --section agent --log_level notice print log_level }.chomp
unless loglevel && respond_to?("log_#{loglevel}")
Expand Down Expand Up @@ -206,7 +206,7 @@ def load_env(base_dir)
].join(';').tr('/', '\\') + ';' + ENV['Path']

# ENV that uses forward slashes
ENV['RUBYLIB'] = "#{File.join(base_dir, 'puppet','lib')};#{ENV['RUBYLIB']}"
ENV['RUBYLIB'] = "#{File.join(base_dir, 'puppet', 'lib')};#{ENV['RUBYLIB']}"
rescue => e
log_exception(e)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/hiera/puppet_function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def self.init_dispatch

dispatch :hiera_no_default do
scope_param
param 'String',:key
param 'String', :key
end

dispatch :hiera_with_default do
scope_param
param 'String',:key
param 'String', :key
param 'Any', :default
optional_param 'Any', :override
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def self.[](param)
require_relative 'puppet/feature/base'

# setting access and stuff
def self.[]=(param,value)
def self.[]=(param, value)
@@settings[param] = value
end

Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def controlled_run(&block)

# used to declare code that handle an option
def option(*options, &block)
long = options.find { |opt| opt =~ /^--/ }.gsub(/^--(?:\[no-\])?([^ =]+).*$/, '\1' ).tr('-','_')
long = options.find { |opt| opt =~ /^--/ }.gsub(/^--(?:\[no-\])?([^ =]+).*$/, '\1' ).tr('-', '_')
fname = "handle_#{long}".intern
if (block_given?)
define_method(fname, &block)
Expand Down Expand Up @@ -514,7 +514,7 @@ def log_runtime_environment(extra_info=nil)
runtime_info['default_encoding'] = Encoding.default_external
runtime_info.merge!(extra_info) unless extra_info.nil?

Puppet.debug 'Runtime environment: ' + runtime_info.map{|k,v| k + '=' + v.to_s}.join(', ')
Puppet.debug 'Runtime environment: ' + runtime_info.map{|k, v| k + '=' + v.to_s}.join(', ')
end

# Options defined with the `option` method are parsed from settings and the command line.
Expand Down Expand Up @@ -576,7 +576,7 @@ def self.exit(code)
end

def name
self.class.to_s.sub(/.*::/,"").downcase.to_sym
self.class.to_s.sub(/.*::/, "").downcase.to_sym
end

# Return the text to display when running `puppet help`.
Expand Down
12 changes: 6 additions & 6 deletions lib/puppet/application/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def preinit
:fingerprint => false,
:sourceaddress => nil,
:start_time => Time.now,
}.each do |opt,val|
}.each do |opt, val|
options[opt] = val
end

Expand All @@ -54,10 +54,10 @@ def preinit
end

option("--enable")
option("--debug","-d")
option("--fqdn FQDN","-f")
option("--test","-t")
option("--verbose","-v")
option("--debug", "-d")
option("--fqdn FQDN", "-f")
option("--test", "-t")
option("--verbose", "-v")

option("--fingerprint")
option("--digest DIGEST")
Expand Down Expand Up @@ -403,7 +403,7 @@ def log_config
# skip also config reading and parsing if debug is not enabled
return unless Puppet::Util::Log.sendlevel?(:debug)

Puppet.settings.stringify_settings(:agent, :all).each_pair do |k,v|
Puppet.settings.stringify_settings(:agent, :all).each_pair do |k, v|
next if k.include?("password") || v.to_s.empty?

Puppet.debug("Using setting: #{k}=#{v}")
Expand Down
10 changes: 5 additions & 5 deletions lib/puppet/application/apply.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ class Puppet::Application::Apply < Puppet::Application
require_relative '../../puppet/util/splayer'
include Puppet::Util::Splayer

option("--debug","-d")
option("--execute EXECUTE","-e") do |arg|
option("--debug", "-d")
option("--execute EXECUTE", "-e") do |arg|
options[:code] = arg
end
option("--loadclasses","-L")
option("--test","-t")
option("--verbose","-v")
option("--loadclasses", "-L")
option("--test", "-t")
option("--verbose", "-v")
option("--use-nodes")
option("--detailed-exitcodes")

Expand Down
8 changes: 4 additions & 4 deletions lib/puppet/application/describe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def scrub(text)
# indent from every line.
if text =~ /^(\s+)/
indent = $1
return text.gsub(/^#{indent}/,'')
return text.gsub(/^#{indent}/, '')
else
return text
end
Expand Down Expand Up @@ -126,7 +126,7 @@ def format_attrs(type, attrs)
docs[name] = type.attrclass(name).doc if attrs.include?(kind) && name != :provider
end

docs.sort { |a,b|
docs.sort { |a, b|
a[0].to_s <=> b[0].to_s
}.each { |name, doc|
print "\n- **#{name}**"
Expand Down Expand Up @@ -169,9 +169,9 @@ class Puppet::Application::Describe < Puppet::Application
options[:parameters] = false
end

option("--providers","-p")
option("--providers", "-p")
option("--list", "-l")
option("--meta","-m")
option("--meta", "-m")

def summary
_("Display help about resource types")
Expand Down
16 changes: 8 additions & 8 deletions lib/puppet/application/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ def preinit
:facts => false,
:target => nil,
:to_yaml => false,
}.each do |opt,val|
}.each do |opt, val|
options[opt] = val
end

@args = {}
end

option("--centrallogging")
option("--debug","-d")
option("--resource","-r")
option("--facts","-f")
option("--to_yaml","-y")
option("--verbose","-v")
option("--debug", "-d")
option("--resource", "-r")
option("--facts", "-f")
option("--to_yaml", "-y")
option("--verbose", "-v")

option("--detailed-exitcodes") do |_arg|
options[:detailed_exitcodes] = true
Expand All @@ -72,7 +72,7 @@ def preinit
options[:waitforcert] = arg.to_i
end

option("--port PORT","-p") do |arg|
option("--port PORT", "-p") do |arg|
@args[:Port] = arg
end

Expand Down Expand Up @@ -261,7 +261,7 @@ def main
exit(1)
end
end
devices.collect do |_devicename,device|
devices.collect do |_devicename, device|
# TODO when we drop support for ruby < 2.5 we can remove the extra block here
begin
device_url = URI.parse(device.url)
Expand Down
10 changes: 5 additions & 5 deletions lib/puppet/application/doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ class Puppet::Application::Doc < Puppet::Application
attr_accessor :unknown_args, :manifest

def preinit
{:references => [], :mode => :text, :format => :to_markdown }.each do |name,value|
{:references => [], :mode => :text, :format => :to_markdown }.each do |name, value|
options[name] = value
end
@unknown_args = []
@manifest = false
end

option("--all","-a")
option("--outputdir OUTPUTDIR","-o")
option("--verbose","-v")
option("--debug","-d")
option("--all", "-a")
option("--outputdir OUTPUTDIR", "-o")
option("--verbose", "-v")
option("--debug", "-d")
option("--charset CHARSET")

option("--format FORMAT", "-f") do |arg|
Expand Down
14 changes: 7 additions & 7 deletions lib/puppet/application/filebucket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
class Puppet::Application::Filebucket < Puppet::Application
environment_mode :not_required

option("--bucket BUCKET","-b")
option("--debug","-d")
option("--fromdate FROMDATE","-f")
option("--todate TODATE","-t")
option("--local","-l")
option("--remote","-r")
option("--verbose","-v")
option("--bucket BUCKET", "-b")
option("--debug", "-d")
option("--fromdate FROMDATE", "-f")
option("--todate TODATE", "-t")
option("--local", "-l")
option("--remote", "-r")
option("--verbose", "-v")

attr :args

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/application/lookup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def generate_scope
if TRUSTED_INFORMATION_FACTS.any? { |key| given_facts.key? key }
unless TRUSTED_INFORMATION_FACTS.all? { |key| given_facts.key? key }
raise _("When overriding any of the %{trusted_facts_list} facts with %{fact_file} "\
"given via the --facts flag, they must all be overridden.") % { fact_file: fact_file ,trusted_facts_list: TRUSTED_INFORMATION_FACTS.join(',')}
"given via the --facts flag, they must all be overridden.") % { fact_file: fact_file , trusted_facts_list: TRUSTED_INFORMATION_FACTS.join(',')}
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/puppet/application/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def preinit
@extra_params = [:provider]
end

option("--debug","-d")
option("--verbose","-v")
option("--edit","-e")
option("--to_yaml","-y")
option("--debug", "-d")
option("--verbose", "-v")
option("--edit", "-e")
option("--to_yaml", "-y")

option("--types", "-t") do |_arg|
env = Puppet.lookup(:environments).get(Puppet[:environment]) || create_default_environment
Expand Down
8 changes: 4 additions & 4 deletions lib/puppet/application/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
require_relative '../../puppet/parser/script_compiler'

class Puppet::Application::Script < Puppet::Application
option("--debug","-d")
option("--execute EXECUTE","-e") do |arg|
option("--debug", "-d")
option("--execute EXECUTE", "-e") do |arg|
options[:code] = arg
end
option("--test","-t")
option("--verbose","-v")
option("--test", "-t")
option("--verbose", "-v")

option("--logdest LOGDEST", "-l") do |arg|
handle_logdest_arg(arg)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/configurer/fact_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def find_facts
facts.name = Puppet[:node_name_value]
end
facts
rescue SystemExit,NoMemoryError
rescue SystemExit, NoMemoryError
raise
rescue Exception => detail
message = _("Could not retrieve local facts: %{detail}") % { detail: detail }
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/face/epp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
raise Puppet::Error, _("No input to parse given on command line or stdin")
end
else
templates, missing_files = args.reduce([[],[]]) do |memo, file|
templates, missing_files = args.reduce([[], []]) do |memo, file|
template_file = effective_template(file, compiler.environment)
if template_file.nil?
memo[1] << file
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/face/module/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def unmet_dependencies(environment)

# Prepare the unmet dependencies for display on the console.
environment.modules.sort_by {|mod| mod.name}.each do |mod|
unmet_grouped = Hash.new { |h,k| h[k] = [] }
unmet_grouped = Hash.new { |h, k| h[k] = [] }
unmet_grouped = mod.unmet_dependencies.inject(unmet_grouped) do |acc, dep|
acc[dep[:reason]] << dep
acc
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/feature/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# We can use Microsoft Windows functions
Puppet.features.add(:microsoft_windows) { Puppet::Util::Platform.windows? }

raise Puppet::Error,_("Cannot determine basic system flavour") unless Puppet.features.posix? or Puppet.features.microsoft_windows?
raise Puppet::Error, _("Cannot determine basic system flavour") unless Puppet.features.posix? or Puppet.features.microsoft_windows?

# We've got LDAP available.
Puppet.features.add(:ldap, :libs => ["ldap"])
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/file_serving/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def collect(source_permissions = nil)
end
end

def initialize(path,data={})
def initialize(path, data={})
@owner = data.delete('owner')
@group = data.delete('group')
@mode = data.delete('mode')
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/file_serving/terminus_selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def select(request)
else
Puppet[:default_file_terminus]
end
when "http","https"
when "http", "https"
:http
when nil
if Puppet::Util.absolute_path?(request.key)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/functions/all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def all_Hash_1(hash)
end

def all_Hash_2(hash)
hash.each_pair.all? { |x,y| yield(x,y) }
hash.each_pair.all? { |x, y| yield(x, y) }
end

def all_Enumerable_1(enumerable)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/functions/any.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def any_Hash_1(hash)
end

def any_Hash_2(hash)
hash.each_pair.any? { |x,y| yield(x, y) }
hash.each_pair.any? { |x, y| yield(x, y) }
end

def any_Enumerable_1(enumerable)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/functions/assert_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
# @param value [Object] the value to assert
#
def assert_type(type, value)
unless Puppet::Pops::Types::TypeCalculator.instance?(type,value)
unless Puppet::Pops::Types::TypeCalculator.instance?(type, value)
inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value)
if block_given?
# Give the inferred type to allow richer comparison in the given block (if generalized
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/functions/downcase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def on_array(a)

def on_hash(h)
result = {}
h.each_pair {|k,v| result[do_downcase(k)] = do_downcase(v) }
h.each_pair {|k, v| result[do_downcase(k)] = do_downcase(v) }
result
end

Expand Down
Loading

0 comments on commit 729e89b

Please sign in to comment.