diogonoda/baa_chan

View on GitHub

Showing 4 of 4 total issues

Method to_builder has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def to_builder
      Jbuilder.encode do |json|
        json.call(
          self,
          :broker,
Severity: Minor
Found in lib/baa_chan/trade_confirmation.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(broker, trade_confirmation_number, trade_date, trades, costs)
Severity: Minor
Found in lib/baa_chan/trade_confirmation.rb - About 35 mins to fix

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

        def initialize(brokerage, clearing_fee, registration_fee, emoluments, options)
    Severity: Minor
    Found in lib/baa_chan/costs.rb - About 35 mins to fix

      Method parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse
            @lines.each_with_object([]) do |line, trades|
              next unless line.include? @layout.trade_prefix
      
              @asset = line.include?('OPCAO') ? 'option' : 'stock'
      Severity: Minor
      Found in lib/baa_chan/parser.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

      Severity
      Category
      Status
      Source
      Language