lnagel/event-sourced-accounting

View on GitHub

Showing 55 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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    create_table :esa_contexts do |t|
      t.string     :type
      t.string     :name
      t.references :chart
      t.references :parent
lib/generators/event_sourced_accounting/templates/migration.rb on lines 99..121

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 99.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    create_table :esa_contexts do |t|
      t.string     :type
      t.string     :name
      t.references :chart
      t.references :parent
fixture_rails_root/db/migrate/20140404075330_create_esa_tables.rb on lines 110..132

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 99.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

  def self.down
    remove_foreign_key :esa_accounts, name: "esa_accounts_chart_id_fk"
    remove_foreign_key :esa_amounts, name: "esa_amounts_account_id_fk"
    remove_foreign_key :esa_amounts, name: "esa_amounts_transaction_id_fk"
    remove_foreign_key :esa_contexts, name: "esa_contexts_account_id_fk"
lib/generators/event_sourced_accounting/templates/migration.rb on lines 145..166

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 74.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

  def self.down
    remove_foreign_key :esa_accounts, name: "esa_accounts_chart_id_fk"
    remove_foreign_key :esa_amounts, name: "esa_amounts_account_id_fk"
    remove_foreign_key :esa_amounts, name: "esa_amounts_transaction_id_fk"
    remove_foreign_key :esa_contexts, name: "esa_contexts_account_id_fk"
fixture_rails_root/db/migrate/20140404075330_create_esa_tables.rb on lines 156..177

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 74.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    create_table :esa_flags, :force => true do |t|
      t.string     :type
      t.datetime   :time
      t.string     :nature
      t.boolean    :state
lib/generators/event_sourced_accounting/templates/migration.rb on lines 41..54

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    create_table :esa_flags, :force => true do |t|
      t.string     :type
      t.datetime   :time
      t.string     :nature
      t.boolean    :state
fixture_rails_root/db/migrate/20140404075330_create_esa_tables.rb on lines 41..54

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

Severity
Category
Status
Source
Language