[MediaWiki-commits] [Gerrit] operations/puppet[production]: graphite: cleanup configparser_format a little bit

2018-01-09 Thread Giuseppe Lavagetto (Code Review)
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 
 #
 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 
Gerrit-Reviewer: Alexandros Kosiaris 
Gerrit-Reviewer: Filippo Giunchedi 
Gerrit-Reviewer: Giuseppe Lavagetto 
Gerrit-Reviewer: Hashar 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] operations/puppet[production]: graphite: cleanup configparser_format a little bit

2017-06-16 Thread Faidon Liambotis (Code Review)
Faidon Liambotis has uploaded a new change for review. ( 
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(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/51/359451/1

diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 1f2fb25..59dec6f 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -75,16 +75,8 @@
 Style/NegatedIf:
   Enabled: false
 
-Style/NestedTernaryOperator:
-  Exclude:
-- 'modules/graphite/lib/puppet/parser/functions/configparser_format.rb'
-
 Style/NumericLiterals:
   MinDigits: 6
-
-Style/RedundantReturn:
-  Exclude:
-- 'modules/graphite/lib/puppet/parser/functions/configparser_format.rb'
 
 Style/RegexpLiteral:
   Exclude:
@@ -112,7 +104,6 @@
 Layout/SpaceAfterComma:
   Exclude:
 - 'modules/base/lib/facter/labsproject.rb'
-- 'modules/graphite/lib/puppet/parser/functions/configparser_format.rb'
 - 'modules/wmflib/lib/puppet/parser/functions/ini.rb'
 
 Layout/SpaceAroundEqualsInParameterDefault:
@@ -130,7 +121,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 
 #
 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: newchange
Gerrit-Change-Id: Idda59e236e3bbc82bd55cacd03c79f57f47237db
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits