Giuseppe Lavagetto has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/359449 )

Change subject: wmflib: cleanup secret.rb a little bit
......................................................................


wmflib: cleanup secret.rb a little bit

These are really minor fixes for Lint/AssignmentInCondition,
Style/MethodCallWithoutArgsParentheses and Style/NegatedIf, but given
the prevalence and importance of secret.rb, this needs a separate and
very careful review.

Change-Id: Ib5a1f0629766d1dd33bea2be383ee802e190adb7
---
M .rubocop_todo.yml
M modules/wmflib/lib/puppet/parser/functions/secret.rb
2 files changed, 6 insertions(+), 12 deletions(-)

Approvals:
  Giuseppe Lavagetto: Looks good to me, approved
  BBlack: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 636bb27..1c50dc5 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1,7 +1,3 @@
-Lint/AssignmentInCondition:
-  Exclude:
-    - 'modules/wmflib/lib/puppet/parser/functions/secret.rb'
-
 Lint/HandleExceptions:
   Exclude:
     - 'modules/wmflib/lib/puppet/parser/functions/require_package.rb'
@@ -70,7 +66,6 @@
     - 'modules/base/spec/defines/service_unit_spec.rb'
     - 
'modules/install_server/spec/classes/install_server_preseed_server_spec.rb'
     - 'modules/squid3/spec/classes/squid3_spec.rb'
-    - 'modules/wmflib/lib/puppet/parser/functions/secret.rb'
 
 Style/NegatedIf:
   Enabled: false
diff --git a/modules/wmflib/lib/puppet/parser/functions/secret.rb 
b/modules/wmflib/lib/puppet/parser/functions/secret.rb
index fc66a02..06970d0 100644
--- a/modules/wmflib/lib/puppet/parser/functions/secret.rb
+++ b/modules/wmflib/lib/puppet/parser/functions/secret.rb
@@ -10,20 +10,19 @@
     end
     in_path = args.first
 
-    if mod = Puppet::Module.find(mod_name)
-       mod_path = mod.path()
-    else
+    mod = Puppet::Module.find(mod_name)
+    unless mod
       fail("secret(): Module #{mod_name} not found")
     end
 
-    sec_path = mod_path + secs_subdir + in_path
-    final_path = Pathname.new(sec_path).cleanpath()
+    sec_path = mod.path + secs_subdir + in_path
+    final_path = Pathname.new(sec_path).cleanpath
 
     # Bail early if it's not a regular, readable file
-    if !final_path.file? || !final_path.readable?
+    unless final_path.file? && final_path.readable?
       fail(ArgumentError, "secret(): invalid secret #{in_path}")
     end
 
-    return final_path.read()
+    final_path.read
   end
 end

-- 
To view, visit https://gerrit.wikimedia.org/r/359449
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib5a1f0629766d1dd33bea2be383ee802e190adb7
Gerrit-PatchSet: 7
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <fai...@wikimedia.org>
Gerrit-Reviewer: Alexandros Kosiaris <akosia...@wikimedia.org>
Gerrit-Reviewer: BBlack <bbl...@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

Reply via email to