ledermann/keepr

View on GitHub

Showing 7 of 7 total issues

Method to_datev has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def to_datev(journal)
    main_posting = journal.keepr_postings.find { |p| p.keepr_account.debtor? || p.keepr_account.creditor? }
    main_posting ||= journal.keepr_postings.max_by(&:amount)

    journal.keepr_postings.sort_by { |p| [p.side == main_posting.side ? 1 : 0, -p.amount] }.map do |posting|
Severity: Minor
Found in lib/keepr/journal_export.rb - 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

Method group_validation has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def group_validation
    return unless keepr_group.present?

    if asset?
      errors.add(:kind, :group_mismatch) unless keepr_group.asset?
Severity: Minor
Found in lib/keepr/account.rb - 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

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

  def self.up
    create_table Keepr::Group, force: true do |t|
      t.integer    :target, null: false
      t.string     :number
      t.string     :name, null: false
Severity: Minor
Found in lib/generators/keepr/migration/templates/migration.rb - About 1 hr to fix

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

      def load(filename, options)
        full_filename = File.join(File.dirname(__FILE__), "groups_creator/#{@language.to_s}/#{filename}".downcase)
        lines = File.readlines(full_filename)
        last_depth = 0
        parents = []
    Severity: Minor
    Found in lib/keepr/groups_creator.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 merged_with_sums has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.merged_with_sums(options = {})
        accounts = with_sums(options).to_a
    
        # Sum up child accounts to parent
        position = 0
    Severity: Minor
    Found in lib/keepr/account.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 amount= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def amount=(value)
        @side ||= SIDE_DEBIT
    
        unless value
          self.raw_amount = nil
    Severity: Minor
    Found in lib/keepr/posting.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 side= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def side=(value)
        raise ArgumentError unless [SIDE_DEBIT, SIDE_CREDIT].include?(value)
    
        @side = value
        return unless amount
    Severity: Minor
    Found in lib/keepr/posting.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