lnagel/event-sourced-accounting

View on GitHub

Showing 29 of 55 total issues

Method up has 132 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.up
    create_table :esa_charts do |t|
      t.string :name

      t.timestamps
Severity: Major
Found in fixture_rails_root/db/migrate/20140404075330_create_esa_tables.rb - About 5 hrs to fix

Method up has 123 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.up
    create_table :esa_charts do |t|
      t.string :name

      t.timestamps
Severity: Major
Found in lib/generators/event_sourced_accounting/templates/migration.rb - About 4 hrs to fix

Class Context has 35 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Context < ActiveRecord::Base
    attr_accessible :chart, :chart_id, :parent, :parent_id, :type, :name, :namespace, :position
    attr_accessible :chart, :chart_id, :parent, :parent_id, :type, :name, :namespace, :position, :start_date, :end_date, :as => :admin
    attr_readonly   :chart, :parent

Severity: Minor
Found in app/models/esa/context.rb - About 4 hrs to fix

Function generateTOC has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function generateTOC() {
  if ($('#filecontents').length === 0) return;
  var _toc = $('<ol class="top"></ol>');
  var show = false;
  var toc = _toc;
Severity: Major
Found in doc/js/app.js - About 2 hrs to fix

Function searchItem has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

function searchItem() {
  for (var i = 0; i < searchCache.length / 50; i++) {
    var item = searchCache[searchIndex];
    var searchName = (searchString.indexOf('::') != -1 ? item.fullName : item.name);
    var matchString = regexSearchString;
Severity: Minor
Found in doc/js/full_list.js - About 2 hrs 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

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

        def self.lookup_extension(name)
          if self.esa_extensions.present?
            matches = self.esa_extensions.map do |expr,extension|
              if expr.is_a? Regexp and expr.match(name).present?
                extension
Severity: Minor
Found in app/models/esa/traits/extendable.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

Function fullListSearch has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function fullListSearch() {
  // generate cache
  searchCache = [];
  $('#full_list li').each(function() {
    var link = $(this).find('.object_link a');
Severity: Minor
Found in doc/js/full_list.js - About 1 hr to fix

Method initialize has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def initialize
      @base_classes = [ESA::Ruleset, ESA::Event, ESA::Flag, ESA::Transaction].freeze

      @extension_namespace = "Accounting"

Severity: Minor
Found in lib/esa/configuration.rb - About 1 hr to fix

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

    def initialize_defaults
      if not self.event_id.nil?
        self.time ||= self.event.time if self.time.nil?
        self.accountable ||= self.event.accountable if self.accountable_id.nil?
        self.ruleset ||= self.event.ruleset if self.ruleset_id.nil?
Severity: Minor
Found in app/models/esa/flag.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 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

Function summaryToggle has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function summaryToggle() {
  $('.summary_toggle').click(function() {
    if (localStorage) {
      localStorage.summaryCollapsed = $(this).text();
    }
Severity: Minor
Found in doc/js/app.js - About 1 hr to fix

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

        def self.extension_name(accountable)
          if accountable.is_a? Class
            if accountable.respond_to? :accountable_name
              lookup_extension(accountable.accountable_name)
            else
Severity: Minor
Found in app/models/esa/traits/extendable.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 check_freshness has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def check_freshness(depth=0, options = {})
      if self.is_update_needed? or not has_subcontext_namespaces?(options[:namespace])
        self.update!(options)
      else
        self.update_freshness_timestamp!
Severity: Minor
Found in app/models/esa/context.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 accounts_of_the_same_chart? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def accounts_of_the_same_chart?
      if self.new_record?
        chart_ids = self.amounts.map{|a| if a.account.present? then a.account.chart_id else nil end}
      else
        chart_ids = self.accounts.pluck(:chart_id)
Severity: Minor
Found in app/models/esa/transaction.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 create_and_process_events has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.create_and_process_events(accountable)
      events_created = create_events(accountable)

      if events_created
        unprocessed_events(accountable).each do |event|
Severity: Minor
Found in lib/esa/blocking_processor.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 default_namespace has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def default_namespace
        if self.start_date.present? and self.end_date.present?
          if self.start_date == self.end_date
            "date"
          elsif self.start_date == self.start_date.beginning_of_month and
Severity: Minor
Found in app/models/esa/contexts/date_context.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 process_event has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.process_event(event)
      flags_created = create_flags(event)

      if flags_created
        unprocessed_flags(event).map do |flag|
Severity: Minor
Found in lib/esa/blocking_processor.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 default_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def default_name
        if self.start_date.present? and self.end_date.present?
          if self.start_date == self.end_date
            "#{self.start_date.to_s}"
          else
Severity: Minor
Found in app/models/esa/contexts/date_context.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 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

Severity
Category
Status
Source
Language