Rubocop cleanups
authorTom Hughes <tom@compton.nu>
Sat, 14 Feb 2015 13:07:17 +0000 (13:07 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 14 Feb 2015 14:33:57 +0000 (14:33 +0000)
15 files changed:
.rubocop_todo.yml
cookbooks/hardware/libraries/sensors.rb
cookbooks/mysql/libraries/mysql.rb
cookbooks/mysql/providers/database.rb
cookbooks/mysql/providers/user.rb
cookbooks/nodejs/providers/package.rb
cookbooks/openvpn/recipes/default.rb
cookbooks/postgresql/libraries/postgresql.rb
cookbooks/postgresql/providers/database.rb
cookbooks/postgresql/providers/table.rb
cookbooks/postgresql/providers/user.rb
cookbooks/tile/files/default/ruby/expire.rb
cookbooks/wordpress/definitions/wordpress_plugin.rb
cookbooks/wordpress/definitions/wordpress_theme.rb
cookbooks/wordpress/libraries/wordpress.rb

index 155b7d1356752efabf9c104fb59dfc60be0e3de4..07185ec2ccc9e53c8dbd84c9fcb14fd8b7262fdb 100644 (file)
@@ -5,11 +5,6 @@
 # Note that changes in the inspected code, or installation of new
 # versions of RuboCop, may require this file to be generated again.
 
-# Offense count: 15
-# Configuration parameters: AllowSafeAssignment.
-Lint/AssignmentInCondition:
-  Enabled: false
-
 # Offense count: 2
 Lint/HandleExceptions:
   Enabled: false
@@ -36,12 +31,6 @@ Metrics/MethodLength:
 Metrics/PerceivedComplexity:
   Max: 9
 
-# Offense count: 2
-# Cop supports --auto-correct.
-# Configuration parameters: SupportedStyles.
-Style/AccessModifierIndentation:
-  EnforcedStyle: outdent
-
 # Offense count: 14
 Style/Documentation:
   Enabled: false
index 0a55eae39342d7cbca4f249e666e5900aa6127f4..6508ffb7d8872b8c0c8069333a268269dca2f7c0 100644 (file)
@@ -8,18 +8,11 @@ class Chef
         if attributes[:ignore]
           results << "ignore #{sensor}"
         else
-          if label = attributes[:label]
-            resuls << "label #{sensor} \"#{label}\""
-          end
-
-          if compute = attributes[:compute]
-            resuls << "compute #{sensor} #{compute}"
-          end
+          results << "label #{sensor} \"#{attributes[:label]}\"" if attributes[:label]
+          results << "compute #{sensor} #{attributes[:compute]}" if attributes[:compute]
 
           attribute_names.each do |name|
-            if value = attributes[name]
-              results << "set #{sensor}_#{name} #{value}"
-            end
+            results << "set #{sensor}_#{name} #{attributes[name]}" if attributes[name]
           end
         end
       end
index 769df807e0eda0c37c6c71c60ad90cbd595df34b..91eb6f9d1c5527f2c4a36e17505e2ff8ab15a72e 100644 (file)
@@ -104,7 +104,9 @@ class Chef
       end
 
       query("SELECT * FROM db").each do |record|
-        next unless database = @databases[record[:db]]
+        database = @databases[record[:db]]
+
+        next unless database
 
         user = "'#{record[:user]}'@'#{record[:host]}'"
 
index 647925f263be839ff3b1c47fa359d5e9816cd63e..6e488ce476c6ee774b311beb8a520c1175b4b7a6 100644 (file)
@@ -22,7 +22,7 @@ def load_current_resource
 
   @current_resource = Chef::Resource::MysqlDatabase.new(new_resource.name)
   @current_resource.database(new_resource.database)
-  if mysql_database = @mysql.databases[@current_resource.database]
+  if (mysql_database = @mysql.databases[@current_resource.database])
     @current_resource.permissions(mysql_database[:permissions])
   end
   @current_resource
index 05fd01eb85caf8cad5ec4973826a463814a8faf1..a966679af3be913ee8dcc1ad298db95635c2a850 100644 (file)
@@ -22,7 +22,7 @@ def load_current_resource
 
   @current_resource = Chef::Resource::MysqlUser.new(new_resource.name)
   @current_resource.user(new_resource.user)
-  if mysql_user = @mysql.users[@current_resource.user]
+  if (mysql_user = @mysql.users[@current_resource.user])
     Chef::MySQL::USER_PRIVILEGES.each do |privilege|
       @current_resource.send(privilege, mysql_user[privilege])
     end
index 5e3ca068468a9377f44ca1a0d464b8354cb45edd..3a33040635c06b8cc0dcd642cd4b8bdd16a4bdae 100644 (file)
@@ -27,7 +27,7 @@ def load_current_resource
 
   @current_resource = Chef::Resource::NodejsPackage.new(new_resource.name)
   @current_resource.package_name(new_resource.package_name)
-  if package = @packages[@current_resource.package_name]
+  if (package = @packages[@current_resource.package_name])
     @current_resource.version(package["version"])
   end
   @current_resource
index 9b01bfdb938049159705a477c4d2141751b0ca8d..9b96183eec2a0452acc920c24159f91d20318e72 100644 (file)
@@ -26,7 +26,9 @@ service "openvpn" do
 end
 
 node[:openvpn][:tunnels].each do |name, details|
-  if peer = search(:node, "fqdn:#{details[:peer][:host]}").first
+  peer = search(:node, "fqdn:#{details[:peer][:host]}").first
+
+  if peer
     if peer[:openvpn] && !details[:peer][:address]
       node.default[:openvpn][:tunnels][name][:peer][:address] = peer[:openvpn][:address]
     end
index 05bf158f2500413c1146c1a315c9f912d3855a26..0b405e89bc609eaabebd317f75b53d85f1b763dd 100644 (file)
@@ -105,7 +105,7 @@ class Chef
       end
     end
 
-  private
+    private
 
     def parse_acl(acl)
       acl.sub(/^\{(.*)\}$/, "\\1").split(",").each_with_object({}) do |entry, permissions|
index c2b000d13d86b54f6e5412c90645b3d49eef69d8..31704314be414ecd1f12e77a7ce27e97a6221e60 100644 (file)
@@ -23,7 +23,7 @@ def load_current_resource
   @current_resource = Chef::Resource::PostgresqlDatabase.new(new_resource.name)
   @current_resource.database(new_resource.database)
   @current_resource.cluster(new_resource.cluster)
-  if pg_database = @pg.databases[@current_resource.database]
+  if (pg_database = @pg.databases[@current_resource.database])
     @current_resource.owner(pg_database[:owner])
     @current_resource.encoding(pg_database[:encoding])
     @current_resource.encoding(pg_database[:collate])
index b1dc85f7b43d760f2d509bb1a365527fab481003..f162347ddab5fcec9e88bbde57372dc75145c120 100644 (file)
@@ -26,7 +26,7 @@ def load_current_resource
   @current_resource.cluster(new_resource.cluster)
   @current_resource.database(new_resource.database)
   @current_resource.schema(new_resource.schema)
-  if pg_table = @tables[@name]
+  if (pg_table = @tables[@name])
     @current_resource.owner(pg_table[:owner])
     @current_resource.permissions(pg_table[:permissions])
   end
index 79136825528c9617fdd6732c15e9046475c5419b..4f21b4d291487d6fd4113fefd113f9c94f2a6df5 100644 (file)
@@ -23,7 +23,7 @@ def load_current_resource
   @current_resource = Chef::Resource::PostgresqlUser.new(new_resource.name)
   @current_resource.user(new_resource.user)
   @current_resource.cluster(new_resource.cluster)
-  if pg_user = @pg.users[@current_resource.user]
+  if (pg_user = @pg.users[@current_resource.user])
     @current_resource.superuser(pg_user[:superuser])
     @current_resource.createdb(pg_user[:createdb])
     @current_resource.createrole(pg_user[:createrole])
index 7757386c5902272475f387fc1149d1a16279e72c..f99d646e0397974bca51b5a0a3345fe5dcc69fc0 100755 (executable)
@@ -131,7 +131,7 @@ module Expire
 
       # this is a node referenced but not added, modified or deleted, so it should
       # still be in the node cache.
-      if entry = node_cache[node_id]
+      if (entry = node_cache[node_id])
         point = Proj4::Point.new(entry.lon, entry.lat)
         nodes[node_id] = tile_from_merc(point, max_zoom)
       end
index b165eb2ba294b515f0e202988f81f451ee00f013..7be7a003866c5368ee6007c6a72ffd1db87dcf16 100644 (file)
@@ -36,7 +36,9 @@ define :wordpress_plugin, :action => [:enable] do
       files_mode 0755
     end
   else
-    unless repository = params[:repository]
+    repository = params[:repository]
+
+    unless params
       version = params[:version] || Chef::Wordpress.current_plugin_version(name)
 
       if version =~ /trunk/
index 91ca9de3d00979ce06c62e49f84b933b25972e6d..0720a8f1f71272494ca389c8adcede7557173cd7 100644 (file)
@@ -36,7 +36,9 @@ define :wordpress_theme, :action => [:enable] do
       files_mode 0644
     end
   else
-    unless repository = params[:repository]
+    repository = params[:repository]
+
+    unless repository
       version = params[:version] || node[:wordpress][:plugins][name][:version]
       repository = "http://themes.svn.wordpress.org/#{name}/#{version}"
     end
index f8046aaaa5786aa3b71d49054c90863b18c96757..06a375fe931935f726dc5f336da44878abbbb537 100644 (file)
@@ -19,7 +19,7 @@ class Chef
       end
     end
 
-  private
+    private
 
     def self.core_version_check
       api_get("http://api.wordpress.org/core/version-check/1.6")