CloudHealth/amazon-pricing

View on GitHub

Showing 77 of 77 total issues

Method fetch_url has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def self.fetch_url(url)
      # AWS appears to have started throttling URL accesses, so we now have to retry
      begin
        retry_count ||= 0
        #$stdout.puts "[#{__method__}] url:#{url}"
Severity: Minor
Found in lib/amazon-pricing/aws-price-list.rb - About 1 hr 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 38 lines of code (exceeds 25 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 1 hr to fix

    Method fetch_ec2_instance_pricing_ri_v2 has 37 lines of code (exceeds 25 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 1 hr to fix

      Method get_ec2_legacy_reserved_instance_pricing has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_ec2_legacy_reserved_instance_pricing
            @@OS_TYPES.each do |os|
              @@LEGACY_RES_TYPES.each do |res_type|
                fetch_ec2_instance_pricing(EC2_BASE_URL + "#{os}-ri-#{res_type}.min.js", res_type, os)
                # Rinse & repeat for legacy instances (note: amazon changed URLs for legacy reserved instances)
      Severity: Minor
      Found in lib/amazon-pricing/ec2-price-list.rb - About 1 hr 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_reserved_rds_instance_pricing2 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def fetch_reserved_rds_instance_pricing2(url, dbs, is_multi_az, is_byol)
            #logger.debug "[#{__method__}] fetched #{url}"
            res = PriceList.fetch_url(url)
            res['config']['regions'].each do |reg|
              region_name = reg['region']
      Severity: Minor
      Found in lib/amazon-pricing/rds-price-list.rb - About 1 hr 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 35 lines of code (exceeds 25 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 1 hr to fix

        Method fetch_reserved_rds_instance_pricing2 has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def fetch_reserved_rds_instance_pricing2(url, dbs, is_multi_az, is_byol)
              #logger.debug "[#{__method__}] fetched #{url}"
              res = PriceList.fetch_url(url)
              res['config']['regions'].each do |reg|
                region_name = reg['region']
        Severity: Minor
        Found in lib/amazon-pricing/rds-price-list.rb - About 1 hr to fix

          Identical blocks of code found in 3 locations. Consider refactoring.
          Open

                if db.nil?
                  db = DatabaseType.new(self, database_type)        
          
                  if is_multi_az == true and is_byol == true
                    @category_types["#{database_type}_byol_multiaz"] = db
          Severity: Major
          Found in lib/amazon-pricing/definitions/rds-instance-type.rb and 2 other locations - About 1 hr to fix
          lib/amazon-pricing/definitions/rds-instance-type.rb on lines 100..111
          lib/amazon-pricing/definitions/rds-instance-type.rb on lines 149..160

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

          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

          Identical blocks of code found in 3 locations. Consider refactoring.
          Open

                if db.nil?
                  db = DatabaseType.new(self, database_type)
          
                  if is_multi_az == true and is_byol == true
                    @category_types["#{database_type}_byol_multiaz"] = db
          Severity: Major
          Found in lib/amazon-pricing/definitions/rds-instance-type.rb and 2 other locations - About 1 hr to fix
          lib/amazon-pricing/definitions/rds-instance-type.rb on lines 36..47
          lib/amazon-pricing/definitions/rds-instance-type.rb on lines 149..160

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

          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

          Identical blocks of code found in 3 locations. Consider refactoring.
          Open

                if db.nil?
                  db = DatabaseType.new(self, database_type)        
                  
                  if is_multi_az == true and is_byol == true
                    @category_types["#{database_type}_byol_multiaz"] = db
          Severity: Major
          Found in lib/amazon-pricing/definitions/rds-instance-type.rb and 2 other locations - About 1 hr to fix
          lib/amazon-pricing/definitions/rds-instance-type.rb on lines 36..47
          lib/amazon-pricing/definitions/rds-instance-type.rb on lines 100..111

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

          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 update_pricing2 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def update_pricing2(operating_system, res_type, ondemand_pph = nil, year1_prepay = nil, year3_prepay = nil, year1_pph = nil, year3_pph = nil)
          
                os = get_category_type(operating_system)
                if os.nil?
                  os = OperatingSystem.new(self, operating_system)
          Severity: Minor
          Found in lib/amazon-pricing/definitions/ec2-instance-type.rb - About 1 hr 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 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def update_pricing(cache_type, type_of_instance, json)
                cache = get_category_type(cache_type)
                if cache.nil?
                  cache = Cache.new(self, cache_type)
                  @category_types[cache_type] = cache
          Severity: Minor
          Found in lib/amazon-pricing/definitions/elasticache_node_type.rb - About 1 hr to fix

            Method update_pricing2 has 9 arguments (exceeds 4 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)
            Severity: Major
            Found in lib/amazon-pricing/definitions/rds-instance-type.rb - About 1 hr to fix

              Method get_rds_on_demand_instance_pricing has 28 lines of code (exceeds 25 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 1 hr to fix

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

                    def update_pricing(operating_system, type_of_instance, json)
                      os = get_category_type(operating_system)
                      if os.nil?
                        os = OperatingSystem.new(self, operating_system)
                        @category_types[operating_system] = os
                Severity: Minor
                Found in lib/amazon-pricing/definitions/ec2-instance-type.rb - About 1 hr to fix

                  Method fetch_ec2_instance_pricing has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def fetch_ec2_instance_pricing(url, type_of_instance, 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 1 hr 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 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def update_pricing(cache_type, type_of_instance, json)
                        cache = get_category_type(cache_type)
                        if cache.nil?
                          cache = Cache.new(self, cache_type)
                          @category_types[cache_type] = cache
                  Severity: Minor
                  Found in lib/amazon-pricing/definitions/elasticache_node_type.rb - About 1 hr 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 api_name_to_nf has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def self.api_name_to_nf(name)
                          type = name.split('.').last
                          if (type == METAL)
                            # See if our metal instance has a hard-coded nf value
                            if !metal_to_nf[name].nil?
                  Severity: Minor
                  Found in lib/amazon-pricing/helpers/instance-type.rb - About 1 hr 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 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def update_pricing_new(operating_system, type_of_instance, price, term = nil, is_prepay = false)
                        os = get_category_type(operating_system)
                        if os.nil?
                          os = OperatingSystem.new(self, operating_system)
                          @category_types[operating_system] = os
                  Severity: Minor
                  Found in lib/amazon-pricing/definitions/ec2-instance-type.rb - About 1 hr to fix

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

                              case val["name"]
                              when "yrTerm1", "yrTerm1Standard"
                                os.set_prepay(type_of_instance, :year1, price)
                              when "yrTerm3", "yrTerm3Standard"
                                os.set_prepay(type_of_instance, :year3, price)
                    Severity: Major
                    Found in lib/amazon-pricing/definitions/ec2-instance-type.rb and 1 other location - About 1 hr to fix
                    lib/amazon-pricing/definitions/elasticache_node_type.rb on lines 45..55

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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language