lnagel/event-sourced-accounting

View on GitHub
app/models/esa/ruleset.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Class Ruleset has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Ruleset < ActiveRecord::Base
    include ESA::Traits::Extendable

    attr_accessible :name, :type, :chart
    attr_readonly   :name, :type, :chart
Severity: Minor
Found in app/models/esa/ruleset.rb - About 2 hrs to fix

Method stateful_events has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def stateful_events(accountable)
      self.event_times(accountable).map do |nature,times|
        if times.present? and times.is_a? Time
          {nature: nature, time: times}
        elsif times.present? and times.respond_to? :each
Severity: Minor
Found in app/models/esa/ruleset.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 flag_transactions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def flag_transactions(flag)
      if flag.adjusted?
        flag_transactions_when_adjusted(flag)
      elsif flag.is_set? and (flag.became_set? or (flag.event.present? and flag.event.nature.adjustment?))
        flag_transactions_when_set(flag)
Severity: Minor
Found in app/models/esa/ruleset.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 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

There are no issues that match your filters.

Category
Status