Trust-Code/odoo-brasil

View on GitHub
br_account/models/account_tax.py

Summary

Maintainability
F
5 days
Test Coverage

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

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

        def _compute_icms_st(self, price_base, ipi_value, icms_value):
            icmsst_tax = self.filtered(lambda x: x.domain == 'icmsst')
            if not icmsst_tax:
                return []
            vals = self._tax_vals(icmsst_tax)
    Severity: Minor
    Found in br_account/models/account_tax.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 _compute_pis_cofins has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def _compute_pis_cofins(self, price_base):
            pis_cofins_tax = self.filtered(lambda x: x.domain in ('pis', 'cofins'))
            if not pis_cofins_tax:
                return []
            taxes = []
    Severity: Minor
    Found in br_account/models/account_tax.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 _compute_difal has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def _compute_difal(self, price_base, ipi_value):
            icms_inter = self.filtered(lambda x: x.domain == 'icms_inter')
            icms_intra = self.filtered(lambda x: x.domain == 'icms_intra')
            icms_fcp = self.filtered(lambda x: x.domain == 'fcp')
            if not icms_inter or not icms_intra:
    Severity: Minor
    Found in br_account/models/account_tax.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 _compute_difal has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def _compute_difal(self, price_base, ipi_value):
            icms_inter = self.filtered(lambda x: x.domain == 'icms_inter')
            icms_intra = self.filtered(lambda x: x.domain == 'icms_intra')
            icms_fcp = self.filtered(lambda x: x.domain == 'fcp')
            if not icms_inter or not icms_intra:
    Severity: Minor
    Found in br_account/models/account_tax.py - About 1 hr to fix

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

          def _compute_icms(self, price_base, ipi_value):
              icms_tax = self.filtered(lambda x: x.domain == 'icms')
              if not icms_tax:
                  return []
              vals = self._tax_vals(icms_tax)
      Severity: Minor
      Found in br_account/models/account_tax.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 _compute_ipi has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _compute_ipi(self, price_base):
              ipi_tax = self.filtered(lambda x: x.domain == 'ipi')
              if not ipi_tax:
                  return []
              vals = self._tax_vals(ipi_tax)
      Severity: Minor
      Found in br_account/models/account_tax.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 compute_all has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def compute_all(self, price_unit, currency=None, quantity=1.0,
                          product=None, partner=None):
      
              exists_br_tax = len(self.filtered(lambda x: x.domain)) > 0
              if not exists_br_tax:
      Severity: Minor
      Found in br_account/models/account_tax.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 compute_all has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def compute_all(self, price_unit, currency=None, quantity=1.0,
      Severity: Minor
      Found in br_account/models/account_tax.py - About 35 mins to fix

        Function _load_template has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _load_template(self, company, code_digits=None,
        Severity: Minor
        Found in br_account/models/account_tax.py - About 35 mins to fix

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

                      if tax.domain == 'pis':
                          if 'pis_base_calculo_manual' in self.env.context and\
                                  self.env.context['pis_base_calculo_manual'] > 0:
                              vals['amount'] = tax._compute_amount(
                                  self.env.context['pis_base_calculo_manual'], 1.0)
          Severity: Major
          Found in br_account/models/account_tax.py and 1 other location - About 1 day to fix
          br_account/models/account_tax.py on lines 305..314

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

          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 tax.domain == 'cofins':
                          if 'cofins_base_calculo_manual' in self.env.context and\
                                  self.env.context['cofins_base_calculo_manual'] > 0:
                              vals['amount'] = tax._compute_amount(
                                  self.env.context['cofins_base_calculo_manual'], 1.0)
          Severity: Major
          Found in br_account/models/account_tax.py and 1 other location - About 1 day to fix
          br_account/models/account_tax.py on lines 296..304

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

          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

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

              domain = fields.Selection([('icms', 'ICMS'),
                                         ('icmsst', 'ICMS ST'),
                                         ('simples', 'Simples Nacional'),
                                         ('pis', 'PIS'),
                                         ('cofins', 'COFINS'),
          Severity: Major
          Found in br_account/models/account_tax.py and 1 other location - About 4 hrs to fix
          br_account/models/account_tax.py on lines 70..84

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

          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

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

              domain = fields.Selection([('icms', 'ICMS'),
                                         ('icmsst', 'ICMS ST'),
                                         ('simples', 'Simples Nacional'),
                                         ('pis', 'PIS'),
                                         ('cofins', 'COFINS'),
          Severity: Major
          Found in br_account/models/account_tax.py and 1 other location - About 4 hrs to fix
          br_account/models/account_tax.py on lines 39..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 76.

          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

                  for tax in simples_tax:
                      vals = self._tax_vals(tax)
                      vals['amount'] = tax._compute_amount(price_base, 1.0)
                      vals['base'] = price_base
                      taxes.append(vals)
          Severity: Major
          Found in br_account/models/account_tax.py and 1 other location - About 2 hrs to fix
          br_account/models/account_tax.py on lines 344..348

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

          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

                  for tax in retention_tax:
                      vals = self._tax_vals(tax)
                      vals['amount'] = tax._compute_amount(price_base, 1.0)
                      vals['base'] = price_base
                      taxes.append(vals)
          Severity: Major
          Found in br_account/models/account_tax.py and 1 other location - About 2 hrs to fix
          br_account/models/account_tax.py on lines 282..286

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

          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