lnagel/event-sourced-accounting

View on GitHub

Showing 29 of 55 total issues

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

      def maybe(attrs)
        events = proxy_association.owner.esa_events
        last_event = events.order('time DESC, created_at DESC').first

        # make sure that the previous event was not of the same event type
Severity: Minor
Found in app/models/esa/associations/events_extension.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 iterated_balance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def iterated_balance
        amounts = map do |a|
          if a.is_debit?
            a.amount
          elsif a.is_credit? and not a.amount.nil?
Severity: Minor
Found in app/models/esa/associations/amounts_extension.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 contained_ids has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def self.contained_ids(context, options = {})
        if options[:all].present? and options[:all] == true and
            context.effective_start_date.present? and
            context.effective_end_date.present?
          dates = context.effective_start_date..context.effective_end_date
Severity: Minor
Found in lib/esa/context_providers/date_context_provider.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

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

    def initialize_defaults
      self.time ||= Time.zone.now if self.time.nil?
      self.ruleset ||= Ruleset.extension_instance(self.accountable) if self.ruleset_id.nil? and not self.accountable_id.nil?
      self.processed ||= false
    end
Severity: Minor
Found in app/models/esa/event.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

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

      def balance
        sums = group('esa_amounts.amount is null').
               group('esa_amounts.type').
               sum(:amount)

Severity: Minor
Found in app/models/esa/associations/amounts_extension.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

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

    def flag_transactions_spec(accountable, flag_nature)
      function_name = "flag_#{flag_nature}_transactions"

      if self.respond_to? function_name
        transactions = self.send(function_name, accountable)
Severity: Minor
Found in app/models/esa/ruleset.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

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

        def self.registered_keys_for(extension=self)
          if extension.is_a? Class
            self.esa_extensions.select{|k,v| v == extension.name}.keys
          elsif extension.is_a? Object and not extension.is_a? String
            registered_keys_for(extension.class)
Severity: Minor
Found in app/models/esa/traits/extendable.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

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

      def self.make_fragments(type, accountable)
        if accountable.is_a? ActiveRecord::Relation
          [accountable.select("`#{accountable.table_name}`.`#{accountable.primary_key}` AS id, '#{type}' AS type").to_sql.squish]
        elsif accountable.is_a? ActiveRecord::Base
          ["SELECT #{accountable.id} AS id, '#{type}' AS type"]
Severity: Minor
Found in lib/esa/filters/accountable_filter.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

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

    def self.create_transactions(flag)
      if not flag.processed and not flag.processed_was
        if flag.transition.present? and flag.transition.in? [-1, 0, 1]
          produce_transactions(flag).map(&:save).all?
        else
Severity: Minor
Found in lib/esa/blocking_processor.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