sclinede/blood_contracts-core

View on GitHub

Showing 6 of 6 total issues

File tariff_contract.rb has 266 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "bundler/setup"
require "json"
require "blood_contracts/core"
require "pry"

Severity: Minor
Found in examples/tariff_contract.rb - About 2 hrs to fix

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

        def match
          steps_enumerator.reduce(value) do |next_value, (step, index)|
            match = next_step_value_match!(step, next_value, index)
    
            break match if match.invalid?
    Severity: Minor
    Found in lib/blood_contracts/core/pipe.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 match has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def match
          return failure(key: :undef_weight, field: :weight) unless parcel.weight
          return failure(not_from_ru_error) if parcel_outside_ru?
          return failure(non_international_error) if non_international_parcel?
          nil
    Severity: Minor
    Found in examples/tariff_contract.rb - About 45 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 match_response has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def match_response(response)
      match = Types::Response.match(response)
      case match
      when Types::Tariff
        # работаем с тарифом
    Severity: Minor
    Found in examples/json_response.rb - About 35 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 new has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def new(*args, **kwargs, &block)
            return super(*args, **kwargs) if @finalized
            names = kwargs.delete(:names) unless kwargs.empty?
            names ||= []
    
    
    Severity: Minor
    Found in lib/blood_contracts/core/pipe.rb - About 35 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 match has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def match
          return failure(key: :undef_weight, field: :weight) unless parcel.weight
          return if domestic?
    
          failure(non_domestic_error)
    Severity: Minor
    Found in examples/tariff_contract.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

    Severity
    Category
    Status
    Source
    Language