CloudHealth/amazon-pricing

View on GitHub

Showing 77 of 77 total issues

File instance-type.rb has 656 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module AwsPricing

  class UnknownTypeError < NameError
  end

Severity: Major
Found in lib/amazon-pricing/definitions/instance-type.rb - About 1 day to fix

    Method get_rds_on_demand_instance_pricing has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_rds_on_demand_instance_pricing
          @@DB_TYPE.each do |db|
            @@OD_DB_DEPLOY_TYPE[db].each {|db_type, db_instances|
              db_instances.each do |dp_type|
                #
    Severity: Minor
    Found in lib/amazon-pricing/rds-price-list.rb - About 5 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method get_rds_reserved_instance_pricing has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_rds_reserved_instance_pricing
          @@DB_TYPE.each do |db|
            next if @@NO_LEGACY_RI_PRICING_AVAILABLE.include? db
            if [:mysql, :postgresql].include? db
              @@RES_TYPES.each do |res_type|
    Severity: Minor
    Found in lib/amazon-pricing/rds-price-list.rb - About 4 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method fetch_ec2_instance_pricing_ri_v2 has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def fetch_ec2_instance_pricing_ri_v2(url, operating_system)
          res = PriceList.fetch_url(url)
          res['config']['regions'].each do |reg|
            region_name = reg['region']
            region = get_region(region_name)
    Severity: Minor
    Found in lib/amazon-pricing/common/ec2_common.rb - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method update_pricing_new has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_pricing_new(database_type, type_of_instance, prices, term = nil, is_multi_az, is_byol)
          db = get_category_type(database_type, is_multi_az, is_byol)
          if db.nil?
            db = DatabaseType.new(self, database_type)
    
    
    Severity: Minor
    Found in lib/amazon-pricing/definitions/rds-instance-type.rb - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method update_pricing has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_pricing(database_type, type_of_instance, json, is_multi_az, is_byol)
          db = get_category_type(database_type, is_multi_az, is_byol)
          if db.nil?
            db = DatabaseType.new(self, database_type)        
    
    
    Severity: Minor
    Found in lib/amazon-pricing/definitions/rds-instance-type.rb - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method set_prepay has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_prepay(type_of_instance, term, price)
          case type_of_instance
          when :light
            if term == :year1
              @light_prepay_1_year = price
    Severity: Minor
    Found in lib/amazon-pricing/definitions/category-type.rb - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method set_price_per_hour has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_price_per_hour(type_of_instance, term, price_per_hour)
          case type_of_instance
          when :ondemand
            @ondemand_price_per_hour = price_per_hour
          when :light
    Severity: Minor
    Found in lib/amazon-pricing/definitions/category-type.rb - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method price_per_hour has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def price_per_hour(type_of_instance = :ondemand, term = nil)
          case type_of_instance
          when :ondemand
            @ondemand_price_per_hour
          when :light
    Severity: Minor
    Found in lib/amazon-pricing/definitions/category-type.rb - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method prepay has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def prepay(type_of_instance = :ondemand, term = nil)
          case type_of_instance
          when :ondemand
            0
          when :light
    Severity: Minor
    Found in lib/amazon-pricing/definitions/category-type.rb - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    File database-type.rb has 264 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'amazon-pricing/definitions/category-type'
    
    module AwsPricing
      class DatabaseType < CategoryType
    
    
    Severity: Minor
    Found in lib/amazon-pricing/definitions/database-type.rb - About 2 hrs to fix

      Class InstanceType has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class InstanceType
          attr_accessor :name, :api_name, :memory_in_mb, :platform, :compute_units, :virtual_cores, :disk_type, :disk_in_gb
      
          def initialize(region, api_name, name)
            @category_types = {}
      Severity: Minor
      Found in lib/amazon-pricing/definitions/instance-type.rb - About 2 hrs to fix

        Method update_pricing2 has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_pricing2(database_type, type_of_instance, is_multi_az, is_byol, ondemand_pph = nil, year1_prepay = nil, year3_prepay = nil, year1_pph = nil, year3_pph = nil)
              db = get_category_type(database_type, is_multi_az, is_byol)
              if db.nil?
                db = DatabaseType.new(self, database_type)        
                
        Severity: Minor
        Found in lib/amazon-pricing/definitions/rds-instance-type.rb - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method update_pricing has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def update_pricing(database_type, type_of_instance, json, is_multi_az, is_byol)
              db = get_category_type(database_type, is_multi_az, is_byol)
              if db.nil?
                db = DatabaseType.new(self, database_type)        
        
        
        Severity: Minor
        Found in lib/amazon-pricing/definitions/rds-instance-type.rb - About 2 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              def fetch_on_demand_elasticache_node_pricing(url, cache_type)
                res = PriceList.fetch_url(url)
                res['config']['regions'].each do |reg|
                  region_name = reg['region']
                  region = get_region(region_name)
          Severity: Major
          Found in lib/amazon-pricing/elasticache-price-list.rb and 1 other location - About 1 hr to fix
          lib/amazon-pricing/elasticache-price-list.rb on lines 63..81

          Duplicated Code

          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).

          Tuning

          This issue has a mass of 74.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              def fetch_reserved_elasticache_node_pricing(url, cache_type)
                res = PriceList.fetch_url(url)
                res['config']['regions'].each do |reg|
                  region_name = reg['region']
                  region = get_region(region_name)
          Severity: Major
          Found in lib/amazon-pricing/elasticache-price-list.rb and 1 other location - About 1 hr to fix
          lib/amazon-pricing/elasticache-price-list.rb on lines 37..56

          Duplicated Code

          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).

          Tuning

          This issue has a mass of 74.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Method price_per_hour has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def price_per_hour(type_of_instance = :ondemand, term = nil)
                case type_of_instance
                when :ondemand
                  @ondemand_price_per_hour
                when :light
          Severity: Minor
          Found in lib/amazon-pricing/definitions/category-type.rb - About 1 hr to fix

            Method prepay has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def prepay(type_of_instance = :ondemand, term = nil)
                  case type_of_instance
                  when :ondemand
                    0
                  when :light
            Severity: Minor
            Found in lib/amazon-pricing/definitions/category-type.rb - About 1 hr to fix

              Method set_prepay has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def set_prepay(type_of_instance, term, price)
                    case type_of_instance
                    when :light
                      if term == :year1
                        @light_prepay_1_year = price
              Severity: Minor
              Found in lib/amazon-pricing/definitions/category-type.rb - About 1 hr to fix

                Method set_price_per_hour has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def set_price_per_hour(type_of_instance, term, price_per_hour)
                      case type_of_instance
                      when :ondemand
                        @ondemand_price_per_hour = price_per_hour
                      when :light
                Severity: Minor
                Found in lib/amazon-pricing/definitions/category-type.rb - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language