Trust-Code/odoo-brasil

View on GitHub
br_account_einvoice/models/invoice_eletronic.py

Summary

Maintainability
F
6 days
Test Coverage

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

    InvoiceEletronic has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class InvoiceEletronic(models.Model):
        _name = 'invoice.eletronic'
    
        _inherit = ['mail.thread']
    
    
    Severity: Minor
    Found in br_account_einvoice/models/invoice_eletronic.py - About 2 hrs to fix

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

              if partner.country_id.id == company.partner_id.country_id.id:
                  if not partner.city_id:
                      errors.append(u'Destinatário / Endereço - Município')
                  else:
                      if not partner.city_id.name:
      Severity: Major
      Found in br_account_einvoice/models/invoice_eletronic.py and 1 other location - About 4 hrs to fix
      br_account_einvoice/models/invoice_eletronic.py on lines 277..285

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

      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

              if partner.country_id.id == company.partner_id.country_id.id:
                  if not partner.state_id:
                      errors.append(u'Destinatário / Endereço - Estado')
                  else:
                      if not partner.state_id.ibge_code:
      Severity: Major
      Found in br_account_einvoice/models/invoice_eletronic.py and 1 other location - About 4 hrs to fix
      br_account_einvoice/models/invoice_eletronic.py on lines 287..295

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

      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 3 locations. Consider refactoring.
      Open

              if not self.company_id.partner_id.city_id:
                  errors.append(u'Emitente / Endereço - município')
              else:
                  if not self.company_id.partner_id.city_id.name:
                      errors.append(u'Emitente / Endereço - Nome do município')
      Severity: Major
      Found in br_account_einvoice/models/invoice_eletronic.py and 2 other locations - About 4 hrs to fix
      br_account_einvoice/models/invoice_eletronic.py on lines 232..238
      br_account_einvoice/models/invoice_eletronic.py on lines 248..254

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

      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 3 locations. Consider refactoring.
      Open

              if not self.company_id.partner_id.country_id:
                  errors.append(u'Emitente / Endereço - país')
              else:
                  if not self.company_id.partner_id.country_id.name:
                      errors.append(u'Emitente / Endereço - Nome do país')
      Severity: Major
      Found in br_account_einvoice/models/invoice_eletronic.py and 2 other locations - About 4 hrs to fix
      br_account_einvoice/models/invoice_eletronic.py on lines 232..238
      br_account_einvoice/models/invoice_eletronic.py on lines 240..246

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

      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 3 locations. Consider refactoring.
      Open

              if not self.company_id.partner_id.state_id:
                  errors.append(u'Emitente / Endereço - Estado')
              else:
                  if not self.company_id.partner_id.state_id.ibge_code:
                      errors.append(u'Emitente / Endereço - Cód. do IBGE do estado')
      Severity: Major
      Found in br_account_einvoice/models/invoice_eletronic.py and 2 other locations - About 4 hrs to fix
      br_account_einvoice/models/invoice_eletronic.py on lines 240..246
      br_account_einvoice/models/invoice_eletronic.py on lines 248..254

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

      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 _create_attachment(self, prefix, event, data):
              file_name = '%s-%s.xml' % (
                  prefix, datetime.now().strftime('%Y-%m-%d-%H-%M'))
              self.env['ir.attachment'].create(
                  {
      Severity: Major
      Found in br_account_einvoice/models/invoice_eletronic.py and 1 other location - About 3 hrs to fix
      br_nfe/models/inutilized_nfe.py on lines 149..159

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

      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

          state = fields.Selection(
              [('draft', u'Provisório'),
               ('edit', 'Editar'),
               ('error', 'Erro'),
               ('done', 'Enviado'),
      Severity: Major
      Found in br_account_einvoice/models/invoice_eletronic.py and 1 other location - About 1 hr to fix
      br_boleto/models/payment_order.py on lines 49..53

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

      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

          finalidade_emissao = fields.Selection(
              [('1', u'1 - Normal'),
               ('2', u'2 - Complementar'),
               ('3', u'3 - Ajuste'),
               ('4', u'4 - Devolução')],
      Severity: Major
      Found in br_account_einvoice/models/invoice_eletronic.py and 1 other location - About 1 hr to fix
      br_nfe/models/inutilized_nfe.py on lines 35..39

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

      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