Trust-Code/odoo-brasil

View on GitHub
br_cnab/wizard/wizard_import_cnab.py

Summary

Maintainability
D
1 day
Test Coverage

File wizard_import_cnab.py has 310 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
# © 2017 Danimar Ribeiro, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import base64
Severity: Minor
Found in br_cnab/wizard/wizard_import_cnab.py - About 3 hrs to fix

    Function _parse_cnab has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def _parse_cnab(self, cnab_file):
            arquivo = self._create_arquivo_cnab(cnab_file)
            transactions = []
            move_lines = []
            payment_line_ids = []
    Severity: Minor
    Found in br_cnab/wizard/wizard_import_cnab.py - 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

    Function _preview_cnab has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def _preview_cnab(self):
            codigos_movimentacao = {
                0: u'Evento Desconhecido',
                2: u'Entrada Confirmada',
                3: u'Entrada Rejeitada',
    Severity: Minor
    Found in br_cnab/wizard/wizard_import_cnab.py - 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

    Function _change_boleto_state has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _change_boleto_state(self, evento):
            nosso_numero = self._get_nosso_numero(evento.nosso_numero)
    
            payment_order_lines = self._get_order_line(
                nosso_numero, 'payment.order.line')
    Severity: Minor
    Found in br_cnab/wizard/wizard_import_cnab.py - 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

    Function _create_statement has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def _create_statement(self, stmt_values, account_number):
            BankStatement = self.env['account.bank.statement']
            BankStatementLine = self.env['account.bank.statement.line']
            filtered_values = []
            for transaction in stmt_values['transactions']:
    Severity: Minor
    Found in br_cnab/wizard/wizard_import_cnab.py - 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

    Function _check_cnab has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def _check_cnab(self, cnab_file):
            if int(base64.b64decode(cnab_file)[0:3]) != int(
                    self.journal_id.bank_id.bic):
                raise UserError(u"O banco do arquivo não corresponde ao\
                    banco do Diário Contábil!")
    Severity: Minor
    Found in br_cnab/wizard/wizard_import_cnab.py - About 55 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

    Function get_bank has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_bank(self):
            bank = self.journal_id.bank_id.bic
    
            if bank == '237':
                from cnab240.bancos import bradesco
    Severity: Minor
    Found in br_cnab/wizard/wizard_import_cnab.py - About 45 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

    Function _prepare_statement_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def _prepare_statement_data(self, arquivo,
                                    transactions, move_lines):
            inicio = final = datetime.now()
            valor_total = Decimal('0.0')
            if len(transactions):
    Severity: Minor
    Found in br_cnab/wizard/wizard_import_cnab.py - 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

    Avoid too many return statements within this function.
    Open

                return sicredi
    Severity: Major
    Found in br_cnab/wizard/wizard_import_cnab.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return int(nosso_numero[10:])
      Severity: Major
      Found in br_cnab/wizard/wizard_import_cnab.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return nosso_numero
        Severity: Major
        Found in br_cnab/wizard/wizard_import_cnab.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return santander
          Severity: Major
          Found in br_cnab/wizard/wizard_import_cnab.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return itau
            Severity: Major
            Found in br_cnab/wizard/wizard_import_cnab.py - About 30 mins to fix

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

                          last_bank_stmt = self.env['account.bank.statement'].search(
                              [('journal_id', '=', self.journal_id.id)],
              Severity: Minor
              Found in br_cnab/wizard/wizard_import_cnab.py and 1 other location - About 50 mins to fix
              br_nfe/models/inutilized_nfe.py on lines 168..169

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

              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