lokalebasen/rconomic

View on GitHub

Showing 9 of 15 total issues

Class Entity has 33 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Entity
    # Internal accessors
    attr_accessor :persisted, :session, :partial

    class << self
Severity: Minor
Found in lib/economic/entity.rb - About 4 hrs to fix

    Method fields has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def fields
          to_hash = Proc.new { |handle| handle.to_hash }
          [
            ["Handle", :handle, Proc.new { |v| v.to_hash }],
            ["Id1", :id1],
    Severity: Minor
    Found in lib/economic/cash_book_entry.rb - About 1 hr to fix

      Method fields has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def fields
            date_formatter = Proc.new { |date| date.respond_to?(:iso8601) ? date.iso8601 : nil }
            to_hash = Proc.new { |handle| handle.to_hash }
            [
              ["Id", :id, nil, :required],
      Severity: Minor
      Found in lib/economic/current_invoice.rb - About 1 hr to fix

        Method fields has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def fields
              to_hash = Proc.new { |handle| handle.to_hash }
              [
                ["Handle", :handle, to_hash, :required],
                ["Number", :handle, Proc.new { |h| h.number }, :required],
        Severity: Minor
        Found in lib/economic/debtor.rb - About 1 hr to fix

          Method initialize_properties_with_values_from_owner has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize_properties_with_values_from_owner(invoice)
                if owner.is_a?(Debtor)
                  invoice.debtor = owner
          
                  invoice.debtor_name        ||= owner.name
          Severity: Minor
          Found in lib/economic/proxies/current_invoice_proxy.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 verify_sanity_of_arguments! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def verify_sanity_of_arguments!(hash)
                return if hash.is_a?(self.class)
          
                if hash.nil? || (!hash.respond_to?(:to_i) && (!hash.respond_to?(:keys) && !hash.respond_to?(:values)))
                  raise ArgumentError.new("Expected Number, Hash or Economic::Entity::Handle - got #{hash.inspect}")
          Severity: Minor
          Found in lib/economic/entity/handle.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 == has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def ==(other)
                return true if self.object_id == other.object_id
                return false if other.nil?
                return false if empty? || (other.respond_to?(:empty?) && other.empty?)
                return false unless other.respond_to?(:id) && other.respond_to?(:number)
          Severity: Minor
          Found in lib/economic/entity/handle.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 to_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_hash
                data = {}
          
                fields.each do |field, method, formatter, required|
                  value = entity.send(method)
          Severity: Minor
          Found in lib/economic/entity/mapper.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(hash)
                verify_sanity_of_arguments!(hash)
                hash = prepare_hash_argument(hash) unless hash.is_a?(self.class)
          
                [:code, :name, :vat_code].each do |key|
          Severity: Minor
          Found in lib/economic/entity/handle.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