Brunomm/br_nfe

View on GitHub

Showing 28 of 56 total issues

Method find_value_for_keys has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

                    def find_value_for_keys(hash, keys)
                        return if keys.blank?
                        keys = [keys] unless keys.is_a?(Array)
                        
                        result = hash
Severity: Minor
Found in lib/br_nfe/service/response/build/base.rb - About 35 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 get_situation_by_status_code has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

                def get_situation_by_status_code
                    if "#{status_code}".strip.in?(    BrNfe::Constants::NFE_SITUATION_AUTORIZED )
                        :authorized
                    elsif "#{status_code}".strip.in?( BrNfe::Constants::NFE_SITUATION_ADJUSTED )
                        :adjusted
Severity: Minor
Found in lib/br_nfe/product/nota_fiscal.rb - About 35 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 convert_to_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def convert_to_date(value)
            return if value.blank?
            if value.is_a?(Date)
                value
            else
Severity: Minor
Found in lib/br_nfe/active_model_base.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 find_or_create_nfeProc_of_invoice_xml_by_access_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

                    def find_or_create_nfeProc_of_invoice_xml_by_access_key invoice
                        doc_nf = "#{invoice.xml}".strip.present? ? parse_nokogiri_xml("#{invoice.xml}") : parse_nokogiri_xml(original_xml)
                        if node = doc_nf.search("NFe/infNFe[@Id*=\"#{invoice.chave_de_acesso}\"]").first
                            if doc_nf.xpath('/*').first.try(:name) == 'nfeProc'
                                doc_nf
Severity: Minor
Found in lib/br_nfe/product/response/build/base.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 condicao_pagamento= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

            def condicao_pagamento=(value)
                if value.is_a?(BrNfe.condicao_pagamento_class) || value.nil? 
                    @condicao_pagamento = value
                elsif value.is_a?(Hash)
                    condicao_pagamento ? condicao_pagamento.assign_attributes(value) : new_condicao_pagamento(value)
Severity: Minor
Found in lib/br_nfe/association/have_condicao_pagamento.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 get_message_for_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

                    def get_message_for_path(msg_path)
                        messages = []
                        _messages = find_value_for_keys(savon_body, path_with_root(msg_path) )
                        if _messages.is_a?(Hash)
                            messages << get_message_for_hash(_messages)
Severity: Minor
Found in lib/br_nfe/service/response/build/base.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 render_xml has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def render_xml file_name, opts={}
            opts ||= {}
            default_options = opts.extract!(:dir_path, :context)
            default_options[:context] ||= self
            
Severity: Minor
Found in lib/br_nfe/base.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 intermediario= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

                def intermediario=(value)
                    if value.is_a?(BrNfe.intermediario_service_class) || value.nil? 
                        @intermediario = value
                    elsif value.is_a?(Hash)
                        intermediario ? intermediario.assign_attributes(value) : new_intermediario(value)
Severity: Minor
Found in lib/br_nfe/service/association/have_intermediario.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