lokalebasen/rconomic

View on GitHub

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

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

              def get_invoices(debtor_handle)
                response = request :get_invoices, {
                  'debtorHandle' => { 'Number' => debtor_handle.number }
                }
                if response.empty?
          Severity: Major
          Found in lib/economic/proxies/debtor_proxy.rb and 1 other location - About 1 hr to fix
          lib/economic/proxies/debtor_proxy.rb on lines 40..56

          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 53.

          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

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

              def get_orders(debtor_handle)
                response = request :get_orders, {
                  'debtorHandle' => { 'Number' => debtor_handle.number }
                }
                if response.empty?
          Severity: Major
          Found in lib/economic/proxies/debtor_proxy.rb and 1 other location - About 1 hr to fix
          lib/economic/proxies/debtor_proxy.rb on lines 19..35

          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 53.

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

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

                    def build_partial_contact_entities(handles)
                      handles.collect do |handle|
                        contact = build
                        contact.partial = true
                        contact.persisted = true
          Severity: Minor
          Found in lib/economic/proxies/actions/debtor_contact/all.rb and 1 other location - About 25 mins to fix
          lib/economic/proxies/actions/find_by_name.rb on lines 24..32

          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 29.

          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 build_partial_contact_entities(handles)
                    handles.collect do |handle|
                      contact = build
                      contact.partial = true
                      contact.persisted = true
          Severity: Minor
          Found in lib/economic/proxies/actions/find_by_name.rb and 1 other location - About 25 mins to fix
          lib/economic/proxies/actions/debtor_contact/all.rb on lines 22..30

          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 29.

          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

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

              has_properties :id,
                :debtor_handle,
                :debtor_name,
                :debtor_address,
                :debtor_postal_code,
          Severity: Minor
          Found in lib/economic/current_invoice.rb and 1 other location - About 20 mins to fix
          lib/economic/debtor.rb on lines 28..55

          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 27.

          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

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

              has_properties :number,
                :debtor_group_handle,
                :name,
                :vat_zone,
                :currency_handle,
          Severity: Minor
          Found in lib/economic/debtor.rb and 1 other location - About 20 mins to fix
          lib/economic/current_invoice.rb on lines 30..57

          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 27.

          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

          Severity
          Category
          Status
          Source
          Language