dtan4/terraforming

Similar code found in 1 other location

module Terraforming
  module Resource
    class IAMRolePolicy
      include Terraforming::Util

Found in Terraforming::Resource::IAMRolePolicy and 1 other location - About 1 day to fix
lib/terraforming/resource/iam_user_policy.rb on lines 2..66

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Refactorings

Further Reading

Similar code found in 1 other location

module Terraforming
  module Resource
    class IAMUserPolicy
      include Terraforming::Util

Found in Terraforming::Resource::IAMUserPolicy and 1 other location - About 1 day to fix
lib/terraforming/resource/iam_role_policy.rb on lines 2..66

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Refactorings

Further Reading

High overall complexity: 209

module Terraforming
  module Resource
    class ELB
      include Terraforming::Util

Found in Terraforming::Resource::ELB - About 9 hrs to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

High overall complexity: 207

module Terraforming
  module Resource
    class SecurityGroup
      include Terraforming::Util

Found in Terraforming::Resource::SecurityGroup - About 8 hrs to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Very complex method in #tfstate

      def tfstate
        load_balancers.inject({}) do |resources, load_balancer|
          load_balancer_attributes = load_balancer_attributes_of(load_balancer)
          attributes = {
            "availability_zones.#" => load_balancer.availability_zones.length.to_s,
Found in Terraforming::Resource::ELB - About 7 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Very complex method in #tfstate

      def tfstate
        records.inject({}) do |resources, r|
          record, zone_id = r[:record], r[:zone_id]
          counter = r[:counter]
          record_id = record_id_of(record, zone_id)
Found in Terraforming::Resource::Route53Record - About 7 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #tfstate

      def tfstate
        db_instances.inject({}) do |resources, instance|
          attributes = {
            "address" => instance.endpoint.address,
            "allocated_storage" => instance.allocated_storage.to_s,
Found in Terraforming::Resource::RDS - About 7 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #tfstate

      def tfstate
        instances.inject({}) do |resources, instance|
          in_vpc = in_vpc?(instance)
          block_devices = block_devices_of(instance)

Found in Terraforming::Resource::EC2 - About 6 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Similar code found in 1 other location

module Terraforming
  module Resource
    class DBParameterGroup
      include Terraforming::Util

lib/terraforming/resource/iam_instance_profile.rb on lines 22..39

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Refactorings

Further Reading

Similar code found in 1 other location

module Terraforming
  module Resource
    class IAMInstanceProfile
      include Terraforming::Util

lib/terraforming/resource/db_parameter_group.rb on lines 22..39

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Refactorings

Further Reading

Similar code found in 1 other location

module Terraforming
  module Resource
    class DBSubnetGroup
      include Terraforming::Util

Found in Terraforming::Resource::DBSubnetGroup and 1 other location - About 5 hrs to fix
lib/terraforming/resource/elasti_cache_subnet_group.rb on lines 22..37

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Refactorings

Further Reading

Similar code found in 1 other location

module Terraforming
  module Resource
    class ElastiCacheSubnetGroup
      include Terraforming::Util

lib/terraforming/resource/db_subnet_group.rb on lines 22..37

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Refactorings

Further Reading

Complex class definition

module Terraforming
  class CLI < Thor
    class_option :merge, type: :string, desc: "tfstate file to merge"
    class_option :overwrite, type: :boolean, desc: "Overwrite existng tfstate"
    class_option :tfstate, type: :boolean, desc: "Generate tfstate"
Found in Terraforming::CLI - About 5 hrs to fix

    Complex method in #tfstate

          def tfstate
            auto_scaling_groups.inject({}) do |resources, group|
              vpc_zone_specified = vpc_zone_specified?(group)
    
              attributes = {
    Found in Terraforming::Resource::AutoScalingGroup - About 5 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Complex method in #tfstate

          def tfstate
            launch_configurations.inject({}) do |resources, lc|
              attributes = {
                "name" => lc.launch_configuration_name,
                "image_id" => lc.image_id,
    Found in Terraforming::Resource::LaunchConfiguration - About 5 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Complex method in #tfstate

          def tfstate
            cache_clusters.inject({}) do |resources, cache_cluster|
              attributes = {
                "cache_nodes.#" => cache_cluster.cache_nodes.length.to_s,
                "cluster_id" => cache_cluster.cache_cluster_id,
    Found in Terraforming::Resource::ElastiCacheCluster - About 4 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Complex method in #tfstate

          def tfstate
            clusters.inject({}) do |resources, cluster|
              attributes = {
                "cluster_identifier"                  => cluster.cluster_identifier,
                "cluster_type"                        => cluster.number_of_nodes == 1 ? "single-node" : "multi-node",
    Found in Terraforming::Resource::Redshift - About 4 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Similar code found in 1 other location

    module Terraforming
      module Resource
        class SecurityGroup
          include Terraforming::Util
    
    
    Found in Terraforming::Resource::SecurityGroup and 1 other location - About 3 hrs to fix
    lib/terraforming/resource/security_group.rb on lines 61..69

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Refactorings

    Further Reading

    Similar code found in 1 other location

    module Terraforming
      module Resource
        class SecurityGroup
          include Terraforming::Util
    
    
    Found in Terraforming::Resource::SecurityGroup and 1 other location - About 3 hrs to fix
    lib/terraforming/resource/security_group.rb on lines 50..58

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Refactorings

    Further Reading

    Complex method in #records

          def records
            to_return = hosted_zones.map do |hosted_zone|
              record_sets_of(hosted_zone).map { |record| { record: record, zone_id: zone_id_of(hosted_zone) } }
            end.flatten
            count = {}
    Found in Terraforming::Resource::Route53Record - About 3 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Complex method in #dedup_permissions

          def dedup_permissions(permissions, group_id)
            group_permissions(permissions).inject([]) do |result, (_, perms)|
              group_ids = perms.map(&:user_id_group_pairs).flatten.map(&:group_id)
    
              if group_ids.length == 1 && group_ids.first == group_id
    Found in Terraforming::Resource::SecurityGroup - About 3 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Similar code found in 2 other locations

    module Terraforming
      module Resource
        class ALB
          include Terraforming::Util
    
    
    Found in Terraforming::Resource::ALB and 2 other locations - About 3 hrs to fix
    lib/terraforming/resource/route_table.rb on lines 114..118
    lib/terraforming/resource/security_group.rb on lines 175..179

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Refactorings

    Further Reading

    Similar code found in 2 other locations

    module Terraforming
      module Resource
        class RouteTable
          include Terraforming::Util
    
    
    Found in Terraforming::Resource::RouteTable and 2 other locations - About 3 hrs to fix
    lib/terraforming/resource/alb.rb on lines 82..90
    lib/terraforming/resource/security_group.rb on lines 175..179

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Refactorings

    Further Reading

    Similar code found in 2 other locations

    module Terraforming
      module Resource
        class SecurityGroup
          include Terraforming::Util
    
    
    Found in Terraforming::Resource::SecurityGroup and 2 other locations - About 3 hrs to fix
    lib/terraforming/resource/alb.rb on lines 82..90
    lib/terraforming/resource/route_table.rb on lines 114..118

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Refactorings

    Further Reading

    Similar code found in 1 other location

    module Terraforming
      module Resource
        class ELB
          include Terraforming::Util
    
    
    Found in Terraforming::Resource::ELB and 1 other location - About 3 hrs to fix
    lib/terraforming/resource/elb.rb on lines 137..144

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Refactorings

    Further Reading

    Similar code found in 1 other location

    module Terraforming
      module Resource
        class ELB
          include Terraforming::Util
    
    
    Found in Terraforming::Resource::ELB and 1 other location - About 3 hrs to fix
    lib/terraforming/resource/elb.rb on lines 127..134

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Refactorings

    Further Reading

    Complex method in #instances

          def instances
            @client.describe_instances.map(&:reservations).flatten.map(&:instances).flatten.reject do |instance|
              instance.state.name == "terminated"
            end
    Found in Terraforming::Resource::EC2 - About 3 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Complex method in #tfstate

          def tfstate
            load_balancers.inject({}) do |resources, load_balancer|
              load_balancer_attributes = load_balancer_attributes_of(load_balancer)
              attributes = {
                "dns_name" => load_balancer.dns_name,
    Found in Terraforming::Resource::ALB - About 3 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Similar code found in 1 other location

    module Terraforming
      module Resource
        class AutoScalingGroup
          include Terraforming::Util
    
    
    lib/terraforming/resource/ec2.rb on lines 53..62

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Refactorings

    Further Reading

    Similar code found in 1 other location

    module Terraforming
      module Resource
        class EC2
          include Terraforming::Util
    
    
    Found in Terraforming::Resource::EC2 and 1 other location - About 2 hrs to fix
    lib/terraforming/resource/auto_scaling_group.rb on lines 52..61

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Refactorings

    Further Reading

    Complex method in #tfstate

          def tfstate
            nat_gateways.inject({}) do |resources, nat_gateway|
              next resources if nat_gateway.nat_gateway_addresses.empty?
    
              attributes = {
    Found in Terraforming::Resource::NATGateway - About 2 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Complex method in #tfstate

          def tfstate
            iam_policy_attachments.inject({}) do |resources, policy_attachment|
              attributes = {
                "id" => policy_attachment[:name],
                "name" => policy_attachment[:name],
    Found in Terraforming::Resource::IAMPolicyAttachment - About 2 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Complex method in #permission_attributes_of

          def permission_attributes_of(security_group, permission, type)
            hashcode = permission_hashcode_of(security_group, permission)
            security_groups = security_groups_in(permission, security_group).reject do |identifier|
              [security_group.group_name, security_group.group_id].include?(identifier)
            end
    Found in Terraforming::Resource::SecurityGroup - About 1 hr to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More