Browse Source

cleanup with rubocop

Chris Mague 7 years ago
parent
commit
44a96f6c56
4 changed files with 34 additions and 16 deletions
  1. 17 0
      .rubocop.yml
  2. 4 6
      lib/neoinfra/nodes.rb
  3. 6 10
      lib/neoinfra/vpcs.rb
  4. 7 0
      models/nodes.rb

+ 17 - 0
.rubocop.yml

@@ -0,0 +1,17 @@
+Metrics/LineLength:
+  Max: 120
+
+Metrics/MethodLength:
+  Max: 200
+
+Metrics/AbcSize:
+  Max: 100
+
+Metrics/PerceivedComplexity:
+  Max: 20
+
+Metrics/BlockLength:
+  Max: 60
+
+Metrics/CyclomaticComplexity:
+  Max: 9

+ 4 - 6
lib/neoinfra/nodes.rb

@@ -38,13 +38,11 @@ module NeoInfra
             next unless Node.where(node_id: ec2.id).empty?
             node_name = if ec2.tags.empty?
                           ec2.id
+                        elsif ec2.tags.key? 'Name'
+                          ec2.tags['Name']
                         else
-                          if ec2.tags.key? 'Name'
-                            ec2.tags['Name']
-                          else
-                            ec2.id
-                          end
-                       end
+                          ec2.id
+                        end
             n = Node.new(
               name: node_name,
               node_id: ec2.id,

+ 6 - 10
lib/neoinfra/vpcs.rb

@@ -32,12 +32,10 @@ module NeoInfra
             next unless Vpc.where(vpc_id: vpc.id).empty?
             vpc_name = if vpc.tags.empty?
                          vpc.id
+                       elsif vpc.tags.key? 'Name'
+                         vpc.tags['Name']
                        else
-                         if vpc.tags.key? 'Name'
-                           vpc.tags['Name']
-                         else
-                           vpc.id
-                         end
+                         vpc.id
                        end
             vpc_id = Vpc.new(
               vpc_id: vpc.id,
@@ -55,12 +53,10 @@ module NeoInfra
             next unless Subnet.where(subnet_id: subnet.subnet_id).empty?
             subnet_name = if subnet.tag_set.empty?
                             subnet.subnet_id
+                          elsif subnet.tag_set.key? 'Name'
+                            subnet.tag_set['Name']
                           else
-                            if subnet.tag_set.key? 'Name'
-                              subnet.tag_set['Name']
-                            else
-                              subnet.subnet_id
-                            end
+                            subnet.subnet_id
                           end
             sn = Subnet.new(
               subnet_id: subnet.subnet_id,

+ 7 - 0
models/nodes.rb

@@ -2,6 +2,7 @@
 
 require 'neo4j'
 
+# Node setup
 class Node
   include Neo4j::ActiveNode
   property :node_id, constraint: :unique
@@ -17,12 +18,14 @@ class Node
   has_one :out, :account, rel_class: :NodeAccount
 end
 
+# SSH key class
 class SshKey
   include Neo4j::ActiveNode
   property :name
   property :account
 end
 
+# Relationship with subnet
 class NodeSubnet
   include Neo4j::ActiveRel
   from_class :Node
@@ -30,6 +33,7 @@ class NodeSubnet
   type :subnet
 end
 
+# Relationship with az
 class NodeAz
   include Neo4j::ActiveRel
   from_class :Node
@@ -37,6 +41,7 @@ class NodeAz
   type :az
 end
 
+# Relationship with key
 class NodeSshKey
   include Neo4j::ActiveRel
   from_class :Node
@@ -44,6 +49,7 @@ class NodeSshKey
   type :sshkey
 end
 
+# Relationship with account
 class NodeAccount
   include Neo4j::ActiveRel
   from_class :Node
@@ -51,6 +57,7 @@ class NodeAccount
   type :owner
 end
 
+# Relationship with account
 class SshKeyAccount
   include Neo4j::ActiveRel
   from_class :SshKey