code-mancers/invoicing

View on GitHub
lib/invoicing/ledger_item/render_ubl.rb

Summary

Maintainability
D
1 day
Test Coverage

Method build_party has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

        def build_party(xml, details)
          details = details.symbolize_keys
          xml.cac :Party do |party|
            party.cac :PartyName do |party_name|
              party_name.cbc :Name, details[:name]
Severity: Minor
Found in lib/invoicing/ledger_item/render_ubl.rb - About 5 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 build has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

        def build
          ubl = Builder::XmlMarkup.new :indent => 4
          ubl.instruct! :xml

          ubl.ubl doc_type, UBL_NAMESPACES.clone.update({'xmlns:ubl' => UBL_DOC_NAMESPACES[doc_type]}) do |invoice|
Severity: Minor
Found in lib/invoicing/ledger_item/render_ubl.rb - About 3 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 build has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def build
          ubl = Builder::XmlMarkup.new :indent => 4
          ubl.instruct! :xml

          ubl.ubl doc_type, UBL_NAMESPACES.clone.update({'xmlns:ubl' => UBL_DOC_NAMESPACES[doc_type]}) do |invoice|
Severity: Major
Found in lib/invoicing/ledger_item/render_ubl.rb - About 2 hrs to fix

    Method initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

            def initialize(ledger_item, options)
              @ledger_item = ledger_item
              @options = options
              @cached_values = {}
              subtype = ledger_item.send(:ledger_item_class_info).subtype
    Severity: Minor
    Found in lib/invoicing/ledger_item/render_ubl.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 build_party has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def build_party(xml, details)
              details = details.symbolize_keys
              xml.cac :Party do |party|
                party.cac :PartyName do |party_name|
                  party_name.cbc :Name, details[:name]
    Severity: Minor
    Found in lib/invoicing/ledger_item/render_ubl.rb - About 1 hr to fix

      Method build_line_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def build_line_item(invoice_line, line_item)
                invoice_line.cbc :ID, id_of(line_item)
                invoice_line.cbc :UUID, uuid_of(line_item) if uuid_of(line_item)
                quantity_tag = [:Invoice, :SelfBilledInvoice].include?(doc_type) ? :InvoicedQuantity : :CreditedQuantity
                invoice_line.cbc quantity_tag, quantity_of(line_item) if quantity_of(line_item)
      Severity: Minor
      Found in lib/invoicing/ledger_item/render_ubl.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

      There are no issues that match your filters.

      Category
      Status