OCA/l10n-italy

View on GitHub
l10n_it_partially_deductible_vat/account.py

Summary

Maintainability
F
4 days
Test Coverage

Function compute has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def compute(self, cr, uid, invoice_id, context=None):
        tax_grouped = super(account_invoice_tax, self).compute(cr, uid, invoice_id, context)
        inv_obj = self.pool.get('account.invoice')
        tax_obj = self.pool.get('account.tax')
        tax_code_obj = self.pool.get('account.tax.code')
Severity: Minor
Found in l10n_it_partially_deductible_vat/account.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

Function compute_all has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def compute_all(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None, force_excluded=False):
Severity: Major
Found in l10n_it_partially_deductible_vat/account.py - About 1 hr to fix

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

        def tax_difference(self, cr, uid, cur, tax_grouped):
            real_total = 0
            invoice_total = 0
            cur_obj = self.pool.get('res.currency')
            tax_obj = self.pool.get('account.tax')
    Severity: Minor
    Found in l10n_it_partially_deductible_vat/account.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

    Avoid deeply nested control flow statements.
    Open

                            if main_tax.id == tax.id:
                                # se risulta un'eccedenza, la tolgo dalla parte detraibile
                                if tax_difference < 0:
                                    inv_tax['amount'] = inv_tax['amount'] + tax_difference
                                # se risulta una mancanza, la aggiungo alla parte indetraibile
    Severity: Major
    Found in l10n_it_partially_deductible_vat/account.py - About 45 mins to fix

      Function get_account_tax_by_tax_code has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_account_tax_by_tax_code(self, tax_code):
              if tax_code.tax_ids:
                  if not self._have_same_rate(tax_code.tax_ids):
                      raise osv.except_osv(_('Error'),
                          _('The taxes %s have different rates') % str(tax_code.tax_ids))
      Severity: Minor
      Found in l10n_it_partially_deductible_vat/account.py - 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

      Function get_account_tax_by_base_code has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_account_tax_by_base_code(self, tax_code):
              if tax_code.base_tax_ids:
                  if not self._have_same_rate(tax_code.base_tax_ids):
                      raise osv.except_osv(_('Error'),
                          _('The taxes %s have different rates') % str(tax_code.base_tax_ids))
      Severity: Minor
      Found in l10n_it_partially_deductible_vat/account.py - 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

      Function compute_all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def compute_all(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None, force_excluded=False):
              res = super(account_tax, self).compute_all(cr, uid, taxes, price_unit, quantity, product, partner, force_excluded)
      
              precision = self.pool.get('decimal.precision').precision_get(cr, uid, 'Account')
              tax_list = res['taxes']
      Severity: Minor
      Found in l10n_it_partially_deductible_vat/account.py - 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

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

          def get_account_tax_by_base_code(self, tax_code):
              if tax_code.base_tax_ids:
                  if not self._have_same_rate(tax_code.base_tax_ids):
                      raise osv.except_osv(_('Error'),
                          _('The taxes %s have different rates') % str(tax_code.base_tax_ids))
      Severity: Major
      Found in l10n_it_partially_deductible_vat/account.py and 1 other location - About 1 day to fix
      l10n_it_partially_deductible_vat/account.py on lines 50..62

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

      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 get_account_tax_by_tax_code(self, tax_code):
              if tax_code.tax_ids:
                  if not self._have_same_rate(tax_code.tax_ids):
                      raise osv.except_osv(_('Error'),
                          _('The taxes %s have different rates') % str(tax_code.tax_ids))
      Severity: Major
      Found in l10n_it_partially_deductible_vat/account.py and 1 other location - About 1 day to fix
      l10n_it_partially_deductible_vat/account.py on lines 64..76

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

      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 invoice.type in ('out_invoice','in_invoice'):
                                      inv_tax['tax_amount'] = cur_obj.compute(cr, uid, invoice.currency_id.id, company_currency,
                                          inv_tax['amount'] * main_tax['tax_sign'],
                                          context={'date': invoice.date_invoice or time.strftime('%Y-%m-%d')}, round=False)
      Severity: Major
      Found in l10n_it_partially_deductible_vat/account.py and 1 other location - About 3 hrs to fix
      l10n_it_partially_deductible_vat/account.py on lines 205..212

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

      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