Skip to content

Commit

Permalink
Layout/EmptyLinesAroundExceptionHandlingKeywords
Browse files Browse the repository at this point in the history
This commit enables the Rubocop
Layout/EmptyLinesAroundExceptionHandlingKeywords cop and addresses all
offenses.
  • Loading branch information
mhashizume committed Dec 19, 2023
1 parent f685157 commit ee29954
Show file tree
Hide file tree
Showing 20 changed files with 0 additions and 32 deletions.
4 changes: 0 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ Layout/EmptyLineAfterGuardClause:
Layout/EmptyLineAfterMagicComment:
Enabled: false

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

# This cop supports safe auto-correction (--auto-correct).
Layout/EmptyLinesAroundMethodBody:
Enabled: false
Expand Down
1 change: 0 additions & 1 deletion ext/windows/service/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def service_main(*argsv)
end
end
@run_thread.join

rescue Exception => e
log_exception(e)
ensure
Expand Down
2 changes: 0 additions & 2 deletions lib/puppet/application/face_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,9 @@ def main
# --kelsey 2012-02-14
rescue SystemExit => detail
status = detail.status

rescue => detail
Puppet.log_exception(detail)
Puppet.err _("Try 'puppet help %{face} %{action}' for usage") % { face: @face.name, action: @action.name }

ensure
exit status
end
Expand Down
2 changes: 0 additions & 2 deletions lib/puppet/application/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ def main
topscope.merge_settings(node.environment.name, false)

compiler.compile()

rescue Puppet::Error
# already logged and handled by the compiler, including Puppet::ParseErrorWithIssue
exit(1)
Expand All @@ -223,7 +222,6 @@ def main
exit(1)
end
end

ensure
if @profiler
Puppet::Util::Profiler.remove_profiler(@profiler)
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/file_serving/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def readconfig(check = true)
rescue => detail
Puppet.log_exception(detail, _("Error parsing fileserver configuration: %{detail}; using old configuration") % { detail: detail })
end

ensure
# Make sure we've got our plugins and modules.
mk_default_mounts
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/indirector/node/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def translate(name, output)

hash
end

rescue => detail
raise Puppet::Error, _("Could not load external node results for %{name}: %{detail}") % { name: name, detail: detail }, detail.backtrace
end
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/interface/face_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def self.safely_require(name, version = nil)
path = @loader.expand(version ? ::File.join(version.to_s, name.to_s) : name)
require path
true

rescue LoadError => e
raise unless e.message =~ %r{-- #{path}$}
# ...guess we didn't find the file; return a much better problem.
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/module_tool/applications/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ def run
results[:result] = :success
results[:installed_modules] = releases
results[:graph] = [ build_install_graph(releases.first, releases) ]

rescue ModuleToolError, ForgeError => err
results[:error] = {
:oneline => err.message,
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/module_tool/applications/upgrader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ def installed_release.priority
results[:base_dir] = releases.first.install_dir
results[:affected_modules] = releases
results[:graph] = [ build_install_graph(releases.first, releases) ]

rescue VersionAlreadyInstalledError => e
results[:result] = (e.newer_versions.empty? ? :noop : :failure)
results[:error] = { :oneline => e.message, :multiline => e.multiline }
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/module_tool/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ def process_source(data)
data['project_page'] ||= @data['project_page'] || source_uri.to_s
data['issues_url'] ||= @data['issues_url'] || source_uri.to_s.sub(/\/*$/, '') + '/issues'
end

rescue URI::Error
return
end
Expand Down
2 changes: 0 additions & 2 deletions lib/puppet/pal/pal_impl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,9 @@ def self.main(
end
end
end

rescue Puppet::Error
# already logged and handled by the compiler, including Puppet::ParseErrorWithIssue
raise

rescue => detail
Puppet.log_exception(detail)
raise
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/parser/catalog_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def compile
Puppet.override(rich_data: true) do
super
end

rescue Puppet::ParseErrorWithIssue => detail
detail.node = node.name
Puppet.log_exception(detail)
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/parser/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ def evaluate_definitions
# needs to be handled specifically as the error has the file/line/position where this
# occurred rather than the resource
fail(Puppet::Pops::Issues::RUNTIME_ERROR, detail, {:detail => detail.message}, detail)

rescue Puppet::Error => e
# PuppetError has the ability to wrap an exception, if so, use the wrapped exception's
# call stack instead
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/parser/script_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def compile
result
end
end

rescue Puppet::ParseErrorWithIssue => detail
detail.node = node_name
Puppet.log_exception(detail)
Expand Down
6 changes: 0 additions & 6 deletions lib/puppet/pops/evaluator/evaluator_impl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,17 @@ def type_calculator
def evaluate(target, scope)
begin
@@eval_visitor.visit_this_1(self, target, scope)

rescue SemanticError => e
# A raised issue may not know the semantic target, use errors call stack, but fill in the
# rest from a supplied semantic object, or the target instruction if there is not semantic
# object.
#
fail(e.issue, e.semantic || target, e.options, e)

rescue Puppet::PreformattedError => e
# Already formatted with location information, and with the wanted call stack.
# Note this is currently a specialized ParseError, so rescue-order is important
#
raise e

rescue Puppet::ParseError => e
# ParseError may be raised in ruby code without knowing the location
# in puppet code.
Expand All @@ -105,16 +102,13 @@ def evaluate(target, scope)
# error. Pass on its call stack.
fail(Issues::RUNTIME_ERROR, target, {:detail => e.message}, e)
end

rescue Puppet::Error => e
# PuppetError has the ability to wrap an exception, if so, use the wrapped exception's
# call stack instead
fail(Issues::RUNTIME_ERROR, target, {:detail => e.message}, e.original || e)

rescue StopIteration => e
# Ensure these are not rescued as StandardError
raise e

rescue StandardError => e
# All other errors, use its message and call stack
fail(Issues::RUNTIME_ERROR, target, {:detail => e.message}, e)
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/pops/evaluator/relationship_operator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def evaluate(left_right_evaluated, relationship_expression, scope)
result = right
end
result

rescue NotCatalogTypeError => e
fail(Issues::NOT_CATALOG_TYPE, relationship_expression, {:type => @type_calculator.string(e.type)})
rescue IllegalRelationshipOperandError => e
Expand Down
2 changes: 0 additions & 2 deletions lib/puppet/pops/types/tree_iterators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def next
redo unless @with_values
end
return [@current_path.dup, value]

rescue StopIteration
# end of current value's range of content
# pop all until out of next values
Expand Down Expand Up @@ -226,7 +225,6 @@ def next
next unless @with_containers
end
return [@current_path.dup, value]

rescue StopIteration
# end of current value's range of content
# shift all until out of next values
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/provider/user/useradd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def password=(value)
:sensitive => has_sensitive_data?
}
output = execute(cmd, execute_options)

rescue => detail
tempfile.close
tempfile.delete
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/util/symbolic_file_mode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ def symbolic_mode_to_int(modification, to_mode = 0, is_a_directory = false)
# Now, assign back the value.
final_mode[who] = value
end

rescue Puppet::Error => e
if part.inspect != modification.inspect
rest = " at #{part.inspect}"
Expand Down
1 change: 0 additions & 1 deletion lib/puppet/util/windows/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def password_is?(name, password, domain = '.')
begin
logon_user(name, password, domain) { |token| }
rescue Puppet::Util::Windows::Error => detail

authenticated_error_codes = Set[
ERROR_ACCOUNT_RESTRICTION,
ERROR_INVALID_LOGON_HOURS,
Expand Down

0 comments on commit ee29954

Please sign in to comment.