code-mancers/invoicing

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

Summary

Maintainability
F
3 days
Test Coverage

Class HTMLOutputBuilder has 64 methods (exceeds 20 allowed). Consider refactoring.
Open

      class HTMLOutputBuilder #:nodoc:

        HTML_ESCAPE = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;' }

        attr_reader :ledger_item, :current_line_item, :options, :custom_fragments, :factor
Severity: Major
Found in lib/invoicing/ledger_item/render_html.rb - About 1 day to fix

    File render_html.rb has 410 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "active_support/concern"
    require 'builder'
    
    module Invoicing
      module LedgerItem
    Severity: Minor
    Found in lib/invoicing/ledger_item/render_html.rb - About 5 hrs to fix

      Method build has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def build
                addresses_table_deps = [:sender_label, :recipient_label, :sender_address, :recipient_address, {
                  :sender_tax_number    => :tax_number_label,
                  :recipient_tax_number => :tax_number_label
                }]
      Severity: Minor
      Found in lib/invoicing/ledger_item/render_html.rb - About 1 hr to fix

        Method method_missing has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def method_missing(method_id, *args, &block)
                  method_id = method_id.to_sym
                  if method_id.to_s =~ /^invoke_(.*)$/
                    method_id = $1.to_sym
                    if custom_fragments[method_id]
        Severity: Minor
        Found in lib/invoicing/ledger_item/render_html.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 default_address has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def default_address(details)
                  details = details.symbolize_keys
                  html =  "#{indent*3}<div class=\"fn org\">#{       h(details[:name])        }</div>\n"
                  html << "#{indent*3}<div class=\"contact\">#{      h(details[:contact_name])}</div>\n"        unless details[:contact_name].blank?
                  html << "#{indent*3}<div class=\"adr\">\n"
        Severity: Minor
        Found in lib/invoicing/ledger_item/render_html.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 default_line_items_header has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def default_line_items_header(params)
                  html =  "#{indent*1}<tr>\n"
                  html << "#{indent*2}<th class=\"tax-point\">#{   params[:line_tax_point_label]   }</th>\n" if options[:tax_point_column]
                  html << "#{indent*2}<th class=\"quantity\">#{    params[:line_quantity_label]    }</th>\n" if options[:quantity_column]
                  html << "#{indent*2}<th class=\"description\">#{ params[:line_description_label] }</th>\n" if options[:description_column]
        Severity: Minor
        Found in lib/invoicing/ledger_item/render_html.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 default_line_items_subtotal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def default_line_items_subtotal(params)
                  colspan = 0
                  colspan += 1 if options[:tax_point_column]
                  colspan += 1 if options[:quantity_column]
                  colspan += 1 if options[:description_column]
        Severity: Minor
        Found in lib/invoicing/ledger_item/render_html.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 default_line_items_total has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def default_line_items_total(params)
                  colspan = -1
                  colspan += 1 if options[:tax_point_column]
                  colspan += 1 if options[:quantity_column]
                  colspan += 1 if options[:description_column]
        Severity: Minor
        Found in lib/invoicing/ledger_item/render_html.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 default_line_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def default_line_item(params)
                  html =  "#{indent*1}<tr>\n"
                  html << "#{indent*2}<td class=\"tax-point\">#{   params[:line_tax_point]   }</td>\n" if options[:tax_point_column]
                  html << "#{indent*2}<td class=\"quantity\">#{    params[:line_quantity]    }</td>\n" if options[:quantity_column]
                  html << "#{indent*2}<td class=\"description\">#{ params[:line_description] }</td>\n" if options[:description_column]
        Severity: Minor
        Found in lib/invoicing/ledger_item/render_html.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

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

                def default_line_item(params)
                  html =  "#{indent*1}<tr>\n"
                  html << "#{indent*2}<td class=\"tax-point\">#{   params[:line_tax_point]   }</td>\n" if options[:tax_point_column]
                  html << "#{indent*2}<td class=\"quantity\">#{    params[:line_quantity]    }</td>\n" if options[:quantity_column]
                  html << "#{indent*2}<td class=\"description\">#{ params[:line_description] }</td>\n" if options[:description_column]
        Severity: Major
        Found in lib/invoicing/ledger_item/render_html.rb and 1 other location - About 3 hrs to fix
        lib/invoicing/ledger_item/render_html.rb on lines 379..387

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

        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 default_line_items_header(params)
                  html =  "#{indent*1}<tr>\n"
                  html << "#{indent*2}<th class=\"tax-point\">#{   params[:line_tax_point_label]   }</th>\n" if options[:tax_point_column]
                  html << "#{indent*2}<th class=\"quantity\">#{    params[:line_quantity_label]    }</th>\n" if options[:quantity_column]
                  html << "#{indent*2}<th class=\"description\">#{ params[:line_description_label] }</th>\n" if options[:description_column]
        Severity: Major
        Found in lib/invoicing/ledger_item/render_html.rb and 1 other location - About 3 hrs to fix
        lib/invoicing/ledger_item/render_html.rb on lines 454..462

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

        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

        There are no issues that match your filters.

        Category
        Status