Trust-Code/odoo-brasil

View on GitHub

Showing 165 of 421 total issues

File invoice_eletronic.py has 951 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
# © 2016 Danimar Ribeiro <danimaribeiro@gmail.com>, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import re
Severity: Major
Found in br_nfe/models/invoice_eletronic.py - About 2 days to fix

    File invoice_eletronic.py has 662 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    # © 2016 Danimar Ribeiro <danimaribeiro@gmail.com>, Trustcode
    # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
    
    import re
    Severity: Major
    Found in br_account_einvoice/models/invoice_eletronic.py - About 1 day to fix

      Function _hook_validation has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
      Open

          def _hook_validation(self):
              """
                  Override this method to implement the validations specific
                  for the city you need
                  @returns list<string> errors
      Severity: Minor
      Found in br_account_einvoice/models/invoice_eletronic.py - About 1 day 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

      Function invoice_validate has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
      Open

          def invoice_validate(self):
              res = super(AccountInvoice, self).invoice_validate()
              error = ''
              for item in self:
                  if item.payment_mode_id and item.payment_mode_id.boleto_type != '':
      Severity: Minor
      Found in br_boleto/models/account_invoice.py - About 1 day 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 account_invoice_line.py has 555 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      # © 2009 Renato Lima - Akretion
      # © 2016 Danimar Ribeiro, Trustcode
      # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
      
      
      Severity: Major
      Found in br_account/models/account_invoice_line.py - About 1 day to fix

        Function _prepare_eletronic_invoice_values has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
        Open

            def _prepare_eletronic_invoice_values(self):
                res = super(InvoiceEletronic, self)._prepare_eletronic_invoice_values()
                if self.model not in ('55', '65'):
                    return res
        
        
        Severity: Minor
        Found in br_nfe/models/invoice_eletronic.py - About 7 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

        Consider simplifying this complex logical expression.
        Open

                if self.model == '001':
                    tz = pytz.timezone(self.env.user.partner_id.tz) or pytz.utc
                    dt_emissao = datetime.strptime(self.data_emissao, DTFT)
                    dt_emissao = pytz.utc.localize(dt_emissao).astimezone(tz)
                    dt_emissao = dt_emissao.strftime('%Y-%m-%d')
        Severity: Critical
        Found in br_nfse/models/invoice_eletronic.py - About 5 hrs to fix

          Function _hook_validation has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

              def _hook_validation(self):
                  errors = super(InvoiceEletronic, self)._hook_validation()
                  if self.model == '55':
                      if not self.company_id.partner_id.inscr_est:
                          errors.append(u'Emitente / Inscrição Estadual')
          Severity: Minor
          Found in br_nfe/models/invoice_eletronic.py - 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 account_invoice.py has 394 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          # © 2009 Renato Lima - Akretion
          # © 2016 Danimar Ribeiro, Trustcode
          # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
          
          
          Severity: Minor
          Found in br_account/models/account_invoice.py - About 5 hrs to fix

            Function action_check_sefaz has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
            Open

                def action_check_sefaz(self):
                    if self.cnpj_cpf and self.state_id:
                        NAO_CONSULTA_CADASTRO = ['AL', 'RJ', 'PA', 'MA']
                        if self.state_id.code in NAO_CONSULTA_CADASTRO:
                            raise UserError(u'{} não possui consulta de cadastro'.format(
            Severity: Minor
            Found in br_base/models/res_partner.py - 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

            Consider simplifying this complex logical expression.
            Open

                    if self.model == '010':
                        tz = pytz.timezone(self.env.user.partner_id.tz) or pytz.utc
                        dt_emissao = datetime.strptime(self.data_emissao, DTFT)
                        dt_emissao = pytz.utc.localize(dt_emissao).astimezone(tz)
            
            
            Severity: Critical
            Found in br_nfse/models/nfse_imperial.py - About 5 hrs to fix

              Function _hook_validation has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _hook_validation(self):
                      errors = super(InvoiceEletronic, self)._hook_validation()
                      if self.model == '001':
                          issqn_codigo = ''
                          if not self.company_id.inscr_mun:
              Severity: Minor
              Found in br_nfse/models/invoice_eletronic.py - About 4 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

              Consider simplifying this complex logical expression.
              Open

                      if address.country_id and address.country_id.code != 'BR':
                          # this ensure other localizations could do what they want
                          return super(ResPartner, self)._display_address(
                              without_company=False)
                      else:
              Severity: Critical
              Found in br_base/models/res_partner.py - About 4 hrs to fix

                File account_tax.py has 338 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                # -*- coding: utf-8 -*-
                # © 2016 Danimar Ribeiro, Trustcode
                # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
                
                
                
                Severity: Minor
                Found in br_account/models/account_tax.py - About 4 hrs to fix

                  Consider simplifying this complex logical expression.
                  Open

                          if self.model == '008':
                              tz = pytz.timezone(self.env.user.partner_id.tz) or pytz.utc
                              dt_emissao = datetime.strptime(self.data_emissao, DTFT)
                              dt_emissao = pytz.utc.localize(dt_emissao).astimezone(tz)
                              dt_emissao = dt_emissao.strftime('%Y-%m-%dT%H:%M:%S')
                  Severity: Critical
                  Found in br_nfse/models/nfse_simpliss.py - About 4 hrs to fix

                    Function _prepare_invoice_line_from_po_line has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _prepare_invoice_line_from_po_line(self, line):
                            res = super(AccountInvoice, self)._prepare_invoice_line_from_po_line(
                                line)
                    
                            res['valor_bruto'] = line.valor_bruto
                    Severity: Minor
                    Found in br_purchase/models/account_invoice.py - 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

                    File fiscal.py has 323 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    # -*- coding: utf-8 -*-
                    # © 2013  Renato Lima - Akretion
                    # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
                    
                    import re
                    Severity: Minor
                    Found in br_base/tools/fiscal.py - About 3 hrs to fix

                      Function _prepare_invoice_line has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def _prepare_invoice_line(self, qty):
                              res = super(SaleOrderLine, self)._prepare_invoice_line(qty)
                      
                              res['valor_desconto'] = self.valor_desconto
                              res['valor_bruto'] = self.valor_bruto
                      Severity: Minor
                      Found in br_sale/models/sale.py - 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

                      Consider simplifying this complex logical expression.
                      Open

                              if self.model == '002':
                                  tz = pytz.timezone(self.env.user.partner_id.tz) or pytz.utc
                                  dt_emissao = datetime.strptime(self.data_emissao, DTFT)
                                  dt_emissao = pytz.utc.localize(dt_emissao).astimezone(tz)
                                  dt_emissao = dt_emissao.strftime('%Y-%m-%dT%H:%M:%S')
                      Severity: Critical
                      Found in br_nfse/models/nfse_ginfes.py - About 3 hrs to fix

                        Function _compute_price has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def _compute_price(self):
                                currency = self.invoice_id and self.invoice_id.currency_id or None
                                price = self.price_unit * (1 - (self.discount or 0.0) / 100.0)
                        
                                valor_bruto = self.price_unit * self.quantity
                        Severity: Minor
                        Found in br_account/models/account_invoice_line.py - 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

                        Severity
                        Category
                        Status
                        Source
                        Language