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

Change subject: graphite: cleanup configparser_format a little bit
......................................................................


graphite: cleanup configparser_format a little bit

Fix indentation and Rubocop infractions:
- Style/NestedTernaryOperator
- Style/RedundantReturn
- Layout/SpaceAfterComma
- Layout/SpaceInsideParens

Still needs a little bit of cleanup work, though.

Change-Id: Idda59e236e3bbc82bd55cacd03c79f57f47237db
---
M .rubocop_todo.yml
M modules/graphite/lib/puppet/parser/functions/configparser_format.rb
2 files changed, 26 insertions(+), 31 deletions(-)

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



diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 1c50dc5..8fd94f6 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -70,14 +70,6 @@
 Style/NegatedIf:
   Enabled: false
 
-Style/NestedTernaryOperator:
-  Exclude:
-    - 'modules/graphite/lib/puppet/parser/functions/configparser_format.rb'
-
-Style/RedundantReturn:
-  Exclude:
-    - 'modules/graphite/lib/puppet/parser/functions/configparser_format.rb'
-
 Style/RegexpLiteral:
   Exclude:
     - 'modules/bacula/spec/classes/bacula_client_spec.rb'
@@ -102,7 +94,6 @@
 
 Layout/SpaceAfterComma:
   Exclude:
-    - 'modules/graphite/lib/puppet/parser/functions/configparser_format.rb'
     - 'modules/wmflib/lib/puppet/parser/functions/ini.rb'
 
 Layout/SpaceAroundEqualsInParameterDefault:
@@ -120,7 +111,6 @@
 
 Layout/SpaceInsideParens:
   Exclude:
-    - 'modules/graphite/lib/puppet/parser/functions/configparser_format.rb'
     - 'utils/expanderb.rb'
 
 Style/SpecialGlobalVars:
diff --git 
a/modules/graphite/lib/puppet/parser/functions/configparser_format.rb 
b/modules/graphite/lib/puppet/parser/functions/configparser_format.rb
index 32e0bc0..f475277 100644
--- a/modules/graphite/lib/puppet/parser/functions/configparser_format.rb
+++ b/modules/graphite/lib/puppet/parser/functions/configparser_format.rb
@@ -4,31 +4,36 @@
 # See <http://docs.python.org/2/library/configparser.html>
 #
 def rmerge(*args)
-    # Recursively merge hashes.
-    merged = args.shift.clone
-    args.each { |hash|
-        merged.merge!(hash) { |k, old, new|
-            merged[k] = old.is_a?(Hash) && new.is_a?(Hash) ? rmerge(old, new) 
: new
-        }
-    }
-    return merged
+  # Recursively merge hashes.
+  merged = args.shift.clone
+  args.each do |hash|
+    merged.merge!(hash) do |k, old, new|
+      merged[k] = old.is_a?(Hash) && new.is_a?(Hash) ? rmerge(old, new) : new
+    end
+  end
+  merged
 end
 
 def configparser_format(config)
-    # Serialize a hash to Python ConfigParser format.
-    config.sort.map { |section,items|
-            ["[#{section}]"].concat items.sort.map { |k,v|
-                v = v.is_a?(Array) ? v.join(',') : ( v == :undef ? '' : v )
-                "#{k} = #{v}"
-            }.push []
-    }.join("\n")
+  # Serialize a hash to Python ConfigParser format.
+  config.sort.map { |section, items|
+    ["[#{section}]"].concat items.sort.map { |k, v|
+      if v.is_a?(Array)
+        v = v.join(',')
+      else
+        v = v == :undef ? '' : v
+      end
+
+      "#{k} = #{v}"
+    }.push []
+  }.join("\n")
 end
 
 module Puppet::Parser::Functions
-    newfunction(:configparser_format, :type => :rvalue) { |args|
-        unless args.any? && args.all? { |a| a.is_a? Hash }
-            fail 'configparser_format() requires one or more hash arguments'
-        end
-        configparser_format(rmerge(*args))
-    }
+  newfunction(:configparser_format, :type => :rvalue) do |args|
+    unless args.any? && args.all? { |a| a.is_a? Hash }
+      fail 'configparser_format() requires one or more hash arguments'
+    end
+    configparser_format(rmerge(*args))
+  end
 end

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idda59e236e3bbc82bd55cacd03c79f57f47237db
Gerrit-PatchSet: 6
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <[email protected]>
Gerrit-Reviewer: Alexandros Kosiaris <[email protected]>
Gerrit-Reviewer: Filippo Giunchedi <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to