Faidon Liambotis has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/403378 )
Change subject: wmflib: fix two RuboCop cops in require_package ...................................................................... wmflib: fix two RuboCop cops in require_package Fix begin/rescue statements in require_package to remove the two sole exceptions: Lint/HandleExceptions and Style/RescueModifier. Change-Id: I36a9348876747c6dec35b67c43fd587471a15538 --- M .rubocop_todo.yml M modules/wmflib/lib/puppet/parser/functions/require_package.rb 2 files changed, 11 insertions(+), 13 deletions(-) Approvals: Faidon Liambotis: Looks good to me, approved jenkins-bot: Verified diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 07ab05f..292a1b9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,7 +1,3 @@ -Lint/HandleExceptions: - Exclude: - - 'modules/wmflib/lib/puppet/parser/functions/require_package.rb' - Metrics/LineLength: Max: 159 @@ -25,10 +21,6 @@ Layout/IndentationWidth: Enabled: false - -Style/RescueModifier: - Exclude: - - 'modules/wmflib/lib/puppet/parser/functions/require_package.rb' Layout/SpaceInsideHashLiteralBraces: Enabled: false diff --git a/modules/wmflib/lib/puppet/parser/functions/require_package.rb b/modules/wmflib/lib/puppet/parser/functions/require_package.rb index 4e01e28..6512603 100644 --- a/modules/wmflib/lib/puppet/parser/functions/require_package.rb +++ b/modules/wmflib/lib/puppet/parser/functions/require_package.rb @@ -26,7 +26,6 @@ class_name = 'packages::' + package_name.tr('-+', '_') # Create host class - host = compiler.topscope.find_hostclass(class_name) unless host host = Puppet::Resource::Type.new(:hostclass, class_name) @@ -34,19 +33,26 @@ end # Create class scope - cls = Puppet::Parser::Resource.new( 'class', class_name, :scope => compiler.topscope) - catalog.add_resource(cls) rescue nil - host.evaluate_code(cls) rescue nil + begin + catalog.add_resource(cls) + rescue + nil + end + begin + host.evaluate_code(cls) + rescue + nil + end # Create package resource - begin host_scope = compiler.topscope.class_scope(host) host_scope.call_function(:create_resources, ['package', { package_name => { :ensure => 'present' } }]) rescue Puppet::Resource::Catalog::DuplicateResourceError + nil end # Declare dependency -- To view, visit https://gerrit.wikimedia.org/r/403378 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I36a9348876747c6dec35b67c43fd587471a15538 Gerrit-PatchSet: 3 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Faidon Liambotis <fai...@wikimedia.org> Gerrit-Reviewer: Faidon Liambotis <fai...@wikimedia.org> Gerrit-Reviewer: Giuseppe Lavagetto <glavage...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits