Skip to content

Commit

Permalink
Layout/LeadingCommentSpace
Browse files Browse the repository at this point in the history
This commit enables the Rubocop Layout/LeadingCommentSpace cop and
addresses all offenses.
  • Loading branch information
mhashizume committed Dec 20, 2023
1 parent d181f5f commit 19bdb37
Show file tree
Hide file tree
Showing 140 changed files with 319 additions and 324 deletions.
5 changes: 0 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ I18n/GetText/DecorateStringFormattingUsingPercent:
I18n/RailsI18n/DecorateString:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment.
Layout/LeadingCommentSpace:
Enabled: false

# This cop supports safe auto-correction (--auto-correct).
Layout/LeadingEmptyLines:
Exclude:
Expand Down
2 changes: 1 addition & 1 deletion lib/hiera/puppet_function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def hiera_block2(scope, key, override, &default_block)

def lookup(scope, key, default, has_default, override, &default_block)
unless Puppet[:strict] == :off
#TRANSLATORS 'lookup' is a puppet function and should not be translated
# TRANSLATORS 'lookup' is a puppet function and should not be translated
message = _("The function '%{class_name}' is deprecated in favor of using 'lookup'.") % { class_name: self.class.name }
message += ' '+ _("See https://puppet.com/docs/puppet/%{minor_version}/deprecated_language.html") %
{ minor_version: Puppet.minor_version }
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/application/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def run_command
end

def log_config
#skip also config reading and parsing if debug is not enabled
# 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|
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/configurer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'timeout'
require_relative '../puppet/util'
require 'securerandom'
#require 'puppet/parser/script_compiler'
# require 'puppet/parser/script_compiler'
require_relative '../puppet/pops/evaluator/deferred_resolver'

class Puppet::Configurer
Expand Down Expand Up @@ -330,7 +330,7 @@ def run(options = {})
raise Puppet::Error, detail
end
else
#TRANSLATORS 'server_list' is the name of a setting and should not be translated
# TRANSLATORS 'server_list' is the name of a setting and should not be translated
Puppet.debug _("Selected puppet server from the `server_list` setting: %{server}:%{port}") % { server: server, port: port }
report.server_used = "#{server}:#{port}"
end
Expand Down Expand Up @@ -559,7 +559,7 @@ def find_functional_server
Puppet.debug(_("Puppet server %{host}:%{port} is unavailable: %{code} %{reason}") %
{ host: e.response.url.host, port: e.response.url.port, code: e.response.code, reason: e.response.reason })
rescue => detail
#TRANSLATORS 'server_list' is the name of a setting and should not be translated
# TRANSLATORS 'server_list' is the name of a setting and should not be translated
Puppet.debug _("Unable to connect to server from server_list setting: %{detail}") % {detail: detail}
end
[nil, nil]
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 @@ -34,7 +34,7 @@ def facts_for_uploading
end

def encode_facts(facts)
#facts = find_facts
# facts = find_facts

# NOTE: :facts specified as parameters are URI encoded here,
# then encoded for a second time depending on their length:
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def run_event_loop
end

signal_loop = Puppet::Scheduler.create_job(SIGNAL_CHECK_INTERVAL) do
while method = @signals.shift #rubocop:disable Lint/AssignmentInCondition
while method = @signals.shift # rubocop:disable Lint/AssignmentInCondition
Puppet.notice "Processing #{method}"
send(method)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/etc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def endpwent
::Etc.endpwent
end

#effectively equivalent to IO#rewind of /etc/passwd
# effectively equivalent to IO#rewind of /etc/passwd
def setpwent
::Etc.setpwent
end
Expand Down Expand Up @@ -116,7 +116,7 @@ def group

setgrent
begin
while cur_group = getgrent #rubocop:disable Lint/AssignmentInCondition
while cur_group = getgrent # rubocop:disable Lint/AssignmentInCondition
yield cur_group
end
ensure
Expand Down
10 changes: 5 additions & 5 deletions lib/puppet/face/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
DEFAULT_SECTION_MARKER = Object.new
DEFAULT_SECTION = "main"
option "--section " + _("SECTION_NAME") do
default_to { DEFAULT_SECTION_MARKER } #Sentinel object for default detection during commands
default_to { DEFAULT_SECTION_MARKER } # Sentinel object for default detection during commands
summary _("The section of the configuration file to interact with.")
description <<-EOT
The section of the puppet.conf configuration file to interact with.
Expand Down Expand Up @@ -100,9 +100,9 @@ def warn_default_section(section_name)
messages = []
messages << _("No section specified; defaulting to '%{section_name}'.") %
{ section_name: section_name }
#TRANSLATORS '--section' is a command line option and should not be translated
# TRANSLATORS '--section' is a command line option and should not be translated
messages << _("Set the config section by using the `--section` flag.")
#TRANSLATORS `puppet config --section user print foo` is a command line example and should not be translated
# TRANSLATORS `puppet config --section user print foo` is a command line example and should not be translated
messages << _("For example, `puppet config --section user print foo`.")
messages << _("For more information, see https://puppet.com/docs/puppet/latest/configuration.html")

Expand Down Expand Up @@ -201,7 +201,7 @@ def report_section_and_environment(section_name, environment_name)
action(:delete) do
summary _("Delete a Puppet setting.")
arguments _("<setting>")
#TRANSLATORS 'main' is a specific section name and should not be translated
# TRANSLATORS 'main' is a specific section name and should not be translated
description "Deletes a setting from the specified section. (The default is the section 'main')."
notes <<-'EOT'
By default, this action deletes the configuration setting from the 'main'
Expand Down Expand Up @@ -257,7 +257,7 @@ def report_section_and_environment(section_name, environment_name)
end
end
else
#TRANSLATORS the 'puppet.conf' is a specific file and should not be translated
# TRANSLATORS the 'puppet.conf' is a specific file and should not be translated
Puppet.warning(_("The puppet.conf file does not exist %{puppet_conf}") % { puppet_conf: path })
end
nil
Expand Down
12 changes: 6 additions & 6 deletions lib/puppet/face/help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
end

if args.length > 2
#TRANSLATORS 'puppet help' is a command line and should not be translated
# TRANSLATORS 'puppet help' is a command line and should not be translated
raise ArgumentError, _("The 'puppet help' command takes two (optional) arguments: a subcommand and an action")
end

Expand All @@ -52,7 +52,7 @@
version = options[:version]
else
if args.length == 0
#TRANSLATORS '--version' is a command line option and should not be translated
# TRANSLATORS '--version' is a command line option and should not be translated
raise ArgumentError, _("Supplying a '--version' only makes sense when a Faces subcommand is given")
end
end
Expand Down Expand Up @@ -211,7 +211,7 @@ def horribly_extract_summary_from(appname)
# depends on the implementation coincidence of how our pages are
# formatted. If we can't match the pattern we expect we return the empty
# string to ensure we don't blow up in the summary. --daniel 2011-04-11
while line = help.shift do #rubocop:disable Lint/AssignmentInCondition
while line = help.shift do # rubocop:disable Lint/AssignmentInCondition
md = /^puppet-#{appname}\([^\)]+\) -- (.*)$/.match(line)
if md
return md[1]
Expand All @@ -222,15 +222,15 @@ def horribly_extract_summary_from(appname)
# This should absolutely be a private method, but for some reason it appears
# that you can't use the 'private' keyword inside of a Face definition.
# See #14205.
#private :horribly_extract_summary_from
# private :horribly_extract_summary_from

def exclude_from_docs?(appname)
%w{face_base indirection_base report status}.include? appname
end
# This should absolutely be a private method, but for some reason it appears
# that you can't use the 'private' keyword inside of a Face definition.
# See #14205.
#private :exclude_from_docs?
# private :exclude_from_docs?

def is_face_app?(appname)
clazz = Puppet::Application.find(appname)
Expand All @@ -240,5 +240,5 @@ def is_face_app?(appname)
# This should probably be a private method, but for some reason it appears
# that you can't use the 'private' keyword inside of a Face definition.
# See #14205.
#private :is_face_app?
# private :is_face_app?
end
2 changes: 1 addition & 1 deletion lib/puppet/face/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
find = get_action(:find)
find.summary _("Retrieve a node object.")
find.arguments _("<host>")
#TRANSLATORS the following are specific names and should not be translated `classes`, `environment`, `expiration`, `name`, `parameters`, Puppet::Node
# TRANSLATORS the following are specific names and should not be translated `classes`, `environment`, `expiration`, `name`, `parameters`, Puppet::Node
find.returns _(<<-'EOT')
A hash containing the node's `classes`, `environment`, `expiration`, `name`,
`parameters` (its facts, combined with any ENC-set parameters), and `time`.
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/feature/pe_license.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

require_relative '../../puppet/util/feature'

#Is the pe license library installed providing the ability to read licenses.
# Is the pe license library installed providing the ability to read licenses.
Puppet.features.add(:pe_license, :libs => %{pe_license})
2 changes: 1 addition & 1 deletion lib/puppet/ffi/windows/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module Constants
REPLACEFILE_IGNORE_MERGE_ERRORS = 0x2
REPLACEFILE_IGNORE_ACL_ERRORS = 0x3

INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF #define INVALID_FILE_ATTRIBUTES (DWORD (-1))
INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF # define INVALID_FILE_ATTRIBUTES (DWORD (-1))

IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
IO_REPARSE_TAG_HSM = 0xC0000004
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/file_serving/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def initialize(path, links: nil, relative_path: nil, source: nil)
def links=(value)
value = value.to_sym
value = :manage if value == :ignore
#TRANSLATORS ':link', ':manage', ':follow' should not be translated
# TRANSLATORS ':link', ':manage', ':follow' should not be translated
raise(ArgumentError, _(":links can only be set to :manage or :follow")) unless [:manage, :follow].include?(value)

@links = value
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/file_serving/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def self.configuration

attr_reader :mounts

#private :mounts
# private :mounts

# Find the right mount. Does some shenanigans to support old-style module
# mounts.
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/file_serving/fileset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def initialize(path, options = {})
end

raise ArgumentError.new(_("Fileset paths must exist")) unless valid?(path)
#TRANSLATORS "recurse" and "recurselimit" are parameter names and should not be translated
# TRANSLATORS "recurse" and "recurselimit" are parameter names and should not be translated
raise ArgumentError.new(_("Fileset recurse parameter must not be a number anymore, please use recurselimit")) if @recurse.is_a?(Integer)
end

Expand Down Expand Up @@ -90,7 +90,7 @@ def ignore=(values)

def links=(links)
links = links.to_sym
#TRANSLATORS ":links" is a parameter name and should not be translated
# TRANSLATORS ":links" is a parameter name and should not be translated
raise(ArgumentError, _("Invalid :links value '%{links}'") % { links: links }) unless [:manage, :follow].include?(links)

@links = links
Expand Down Expand Up @@ -164,7 +164,7 @@ def perform_recursion

result = []

while entry = current_dirs.shift #rubocop:disable Lint/AssignmentInCondition
while entry = current_dirs.shift # rubocop:disable Lint/AssignmentInCondition
if continue_recursion_at?(entry.depth + 1)
entry.children.each do |child|
result << child.path
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/functions/binary_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
def binary_file(scope, unresolved_path)
path = Puppet::Parser::Files.find_file(unresolved_path, scope.compiler.environment)
unless path && Puppet::FileSystem.exist?(path)
#TRANSLATORS the string "binary_file()" should not be translated
# TRANSLATORS the string "binary_file()" should not be translated
raise Puppet::ParseError, _("binary_file(): The given file '%{unresolved_path}' does not exist") % { unresolved_path: unresolved_path }
end

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/functions/break.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# }
# $data = [1,2,3]
# notice $data.map |$x| { break_if_even($x); $x*10 }
#```
# ```
# Would notice the value `[10]`
#
# * Also see functions `next` and `return`
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/functions/eyaml_lookup_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def eyaml_lookup_key(key, options, context)
# Can't do this with an argument_mismatch dispatcher since there is no way to declare a struct that at least
# contains some keys but may contain other arbitrary keys.
unless options.include?('path')
#TRANSLATORS 'eyaml_lookup_key':, 'path', 'paths' 'glob', 'globs', 'mapped_paths', and lookup_key should not be translated
# TRANSLATORS 'eyaml_lookup_key':, 'path', 'paths' 'glob', 'globs', 'mapped_paths', and lookup_key should not be translated
raise ArgumentError,
_("'eyaml_lookup_key': one of 'path', 'paths' 'glob', 'globs' or 'mapped_paths' must be declared in hiera.yaml"\
" when using this lookup_key function")
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/graph/simple_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def find_cycles_in_graph
# through the graph first, which are more likely to be interesting to the
# user. I think; it would be interesting to verify that. --daniel 2011-01-23
def paths_in_cycle(cycle, max_paths = 1)
#TRANSLATORS "negative or zero" refers to the count of paths
# TRANSLATORS "negative or zero" refers to the count of paths
raise ArgumentError, _("negative or zero max_paths") if max_paths < 1

# Calculate our filtered outbound vertex lists...
Expand All @@ -212,7 +212,7 @@ def paths_in_cycle(cycle, max_paths = 1)

# frame struct is vertex, [path]
stack = [[cycle.first, []]]
while frame = stack.shift do #rubocop:disable Lint/AssignmentInCondition
while frame = stack.shift do # rubocop:disable Lint/AssignmentInCondition
if frame[1].member?(frame[0]) then
found << frame[1] + [frame[0]]
break if found.length >= max_paths
Expand Down Expand Up @@ -243,7 +243,7 @@ def report_cycles_in_graph
filename = write_cycles_to_graph(cycles)
message += _("Cycle graph written to %{filename}.") % { filename: filename }
else
#TRANSLATORS '--graph' refers to a command line option and OmniGraffle and GraphViz are program names and should not be translated
# TRANSLATORS '--graph' refers to a command line option and OmniGraffle and GraphViz are program names and should not be translated
message += _("Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz")
end
Puppet.err(message)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/http/dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def each_srv_record(domain, service_name = :puppet, &block)
each_srv_record(domain, :puppet, &block)
else
each_priority(records) do |recs|
while next_rr = recs.delete(find_weighted_server(recs)) #rubocop:disable Lint/AssignmentInCondition
while next_rr = recs.delete(find_weighted_server(recs)) # rubocop:disable Lint/AssignmentInCondition
Puppet.debug "Yielding next server of #{next_rr.target}:#{next_rr.port}"
yield next_rr.target.to_s, next_rr.port
end
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/http/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def self.no_proxy?(dest)
host, port = d.split(':')
host = Regexp.escape(host).gsub('\*', '.*')

#If this no_proxy entry specifies a port, we want to match it against
#the destination port. Otherwise just match hosts.
# If this no_proxy entry specifies a port, we want to match it against
# the destination port. Otherwise just match hosts.
if port
no_proxy_regex = %r(#{host}:#{port}$)
dest_string = "#{dest.host}:#{dest.port}"
Expand Down
20 changes: 10 additions & 10 deletions lib/puppet/indirector/catalog/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ def get_content_uri(metadata, source, environment_path)
def inlineable?(resource, sources)
case
when resource[:ensure] == 'absent'
#TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
# TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
return Puppet::Util::Profiler.profile(_("Not inlining absent resource"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :absent]) { false }
when sources.empty?
#TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
# TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
return Puppet::Util::Profiler.profile(_("Not inlining resource without sources"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :no_sources]) { false }
when (not (sources.all? {|source| source =~ /^puppet:/}))
#TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
# TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
return Puppet::Util::Profiler.profile(_("Not inlining unsupported source scheme"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :unsupported_scheme]) { false }
else
return true
Expand All @@ -191,13 +191,13 @@ def inlineable_metadata?(metadata, source, environment_path)
# Helper method to log file resources that could not be inlined because they
# fall outside of an environment.
def log_file_outside_environment
#TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
# TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
Puppet::Util::Profiler.profile(_("Not inlining file outside environment"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :file_outside_environment]) { true }
end

# Helper method to log file resources that were successfully inlined.
def log_metadata_inlining
#TRANSLATORS Inlining refers to adding additional metadata
# TRANSLATORS Inlining refers to adding additional metadata
Puppet::Util::Profiler.profile(_("Inlining file metadata"), [:compiler, :static_compile_inlining, :inlined_file_metadata]) { true }
end

Expand Down Expand Up @@ -350,14 +350,14 @@ def compile(node, options)
escaped_node_name = node.name.gsub(/%/, '%%')
if node.environment
escaped_node_environment = node.environment.to_s.gsub(/%/, '%%')
#TRANSLATORS Inlined refers to adding additional metadata
# TRANSLATORS Inlined refers to adding additional metadata
benchmark_str = _("Inlined resource metadata into static catalog for %{node} in environment %{environment} in %%{seconds} seconds") % { node: escaped_node_name, environment: escaped_node_environment }
#TRANSLATORS Inlined refers to adding additional metadata
# TRANSLATORS Inlined refers to adding additional metadata
profile_str = _("Inlined resource metadata into static catalog for %{node} in environment %{environment}") % { node: node.name, environment: node.environment }
else
#TRANSLATORS Inlined refers to adding additional metadata
# TRANSLATORS Inlined refers to adding additional metadata
benchmark_str = _("Inlined resource metadata into static catalog for %{node} in %%{seconds} seconds") % { node: escaped_node_name }
#TRANSLATORS Inlined refers to adding additional metadata
# TRANSLATORS Inlined refers to adding additional metadata
profile_str = _("Inlined resource metadata into static catalog for %{node}") % { node: node.name }
end
benchmark(:notice, benchmark_str) do
Expand Down Expand Up @@ -454,7 +454,7 @@ def set_server_facts
host = Puppet.runtime[:facter].value('networking.hostname')
if host.nil?
Puppet.warning _("Could not retrieve fact servername")
elsif domain = Puppet.runtime[:facter].value('networking.domain') #rubocop:disable Lint/AssignmentInCondition
elsif domain = Puppet.runtime[:facter].value('networking.domain') # rubocop:disable Lint/AssignmentInCondition
@server_facts["servername"] = [host, domain].join(".")
else
@server_facts["servername"] = host
Expand Down
Loading

0 comments on commit 19bdb37

Please sign in to comment.