CloudHealth/amazon-pricing

View on GitHub
lib/amazon-pricing/common/ec2_common.rb

Summary

Maintainability
C
1 day
Test Coverage

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

        def set_od_price_if_missing(region, region_name, api_name, operating_system, instance_type, type_json)
          type_json["terms"].each do |term|
            # handle case of ondemand pricing missing;  turns out od-pricing is also in ri-pricing
            # (assumes od pricing has been set, iff both api_name+os are available)
            if not region.instance_type_available?(api_name, :ondemand, operating_system)
    Severity: Minor
    Found in lib/amazon-pricing/common/ec2_common.rb - About 55 mins 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_od_price_if_missing has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def set_od_price_if_missing(region, region_name, api_name, operating_system, instance_type, type_json)
    Severity: Minor
    Found in lib/amazon-pricing/common/ec2_common.rb - About 45 mins to fix

      Method ensure_existence_of_instance_type has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def ensure_existence_of_instance_type(region, region_name, api_name, operating_system, type_json)
      Severity: Minor
      Found in lib/amazon-pricing/common/ec2_common.rb - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status