code-mancers/invoicing

View on GitHub

Showing 48 of 48 total issues

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

      File ledger_item.rb has 331 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "active_support/concern"
      require "invoicing/ledger_item/render_html"
      require "invoicing/ledger_item/render_ubl"
      
      module Invoicing
      Severity: Minor
      Found in lib/invoicing/ledger_item.rb - About 3 hrs to fix

        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

        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

        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

        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 format_value has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

                  def format_value(currency_code, value, options={})
                    info = currency_info(currency_code, options)
          
                    negative = false
                    if value < 0
          Severity: Minor
          Found in lib/invoicing/currency_value.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 generate_attrs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def generate_attrs(attr)
                  model_class.class_eval do
                    define_method(attr) do
                      currency_info = currency_value_class_info.currency_info_for(self)
                      return read_attribute(attr) if currency_info.nil?
          Severity: Minor
          Found in lib/invoicing/currency_value.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 account_summaries has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def account_summaries(self_id, options={})
                  info = ledger_item_class_info
                  ext = Invoicing::ConnectionAdapterExt
          
                  debit_classes  = select_matching_subclasses(:debit_when_sent_by_self, true,  self.table_name, self.inheritance_column).map{|c| c.name}
          Severity: Minor
          Found in lib/invoicing/ledger_item.rb - About 1 hr 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 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 generate_attr_taxable_methods has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                    def generate_attr_taxable_methods(method_name) #:nodoc:
              
                      define_method("#{method_name}_tax_rounding_error") do
                        original_value = read_attribute("#{method_name}_taxed")
                        return nil if original_value.nil? # Can only have a rounding error if the taxed attr was assigned
              Severity: Minor
              Found in lib/invoicing/taxable.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 generate_attr_taxable_methods has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def generate_attr_taxable_methods(method_name) #:nodoc:
              
                      define_method("#{method_name}_tax_rounding_error") do
                        original_value = read_attribute("#{method_name}_taxed")
                        return nil if original_value.nil? # Can only have a rounding error if the taxed attr was assigned
              Severity: Minor
              Found in lib/invoicing/taxable.rb - About 1 hr to fix

                Method render_summary has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def render_summary(pdf)
                        pdf.move_down 25
                        pdf.text 'Invoice Summary', size: 12, style: :bold
                        pdf.stroke_horizontal_rule
                
                
                Severity: Minor
                Found in lib/invoicing/ledger_item/pdf_generator.rb - About 1 hr to fix

                  Method acts_as has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def self.acts_as(source_module, calling_class, args)
                        # The name by which the particular module using ClassInfo is known
                        module_name = source_module.name.split('::').last.underscore
                        class_info_method = "#{module_name}_class_info"
                  
                  
                  Severity: Minor
                  Found in lib/invoicing/class_info.rb - About 1 hr to fix

                    Method sender_recipient_name_map has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def sender_recipient_name_map(*sender_recipient_ids)
                            sender_recipient_ids = sender_recipient_ids.flatten.map &:to_i
                            sender_recipient_to_ledger_item_ids = {}
                            result_map = {}
                            info = ledger_item_class_info
                    Severity: Minor
                    Found in lib/invoicing/ledger_item.rb - About 1 hr to fix

                      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 account_summary has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def account_summary(self_id, other_id=nil, options={})
                              info = ledger_item_class_info
                              self_id = self_id.to_i
                              other_id = [nil, ''].include?(other_id) ? nil : other_id.to_i
                      
                      
                      Severity: Minor
                      Found in lib/invoicing/ledger_item.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

                      Severity
                      Category
                      Status
                      Source
                      Language