CloudHealth/amazon-pricing

View on GitHub
lib/amazon-pricing/definitions/instance-type.rb

Summary

Maintainability
D
2 days
Test Coverage

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

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

          def self.populate_lookups
            # We use Linux on-demand to populate the lookup tables with the basic lookup information
            ["http://a0.awsstatic.com/pricing/1/ec2/linux-od.min.js", "http://a0.awsstatic.com/pricing/1/ec2/previous-generation/linux-od.min.js"].each do |url|
              res = AwsPricing::PriceList.fetch_url(url)
      
      
      Severity: Minor
      Found in lib/amazon-pricing/definitions/instance-type.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 price_per_hour has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def price_per_hour(category_type, type_of_instance, term = nil, is_multi_az = false, isByol = false)
      Severity: Minor
      Found in lib/amazon-pricing/definitions/instance-type.rb - About 35 mins to fix

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

            def get_breakeven_month(category_types, type_of_instance, term, is_multi_az = false, isByol = false)
        Severity: Minor
        Found in lib/amazon-pricing/definitions/instance-type.rb - About 35 mins to fix

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

              def prepay(category_type, type_of_instance, term = nil, is_multi_az = false, isByol = false)
          Severity: Minor
          Found in lib/amazon-pricing/definitions/instance-type.rb - About 35 mins to fix

            Method get_category_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_category_type(name, multi_az = false, byol = false)
                  if multi_az == true and byol == true
                    db = @category_types["#{name}_byol_multiaz"]
                  elsif multi_az == true and byol == false
                    db = @category_types["#{name}_multiaz"]
            Severity: Minor
            Found in lib/amazon-pricing/definitions/instance-type.rb - About 25 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

            There are no issues that match your filters.

            Category
            Status