OCA/l10n-italy

View on GitHub
l10n_it_account/models/account_tax.py

Summary

Maintainability
D
2 days
Test Coverage

Function check_tax has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def check_tax(self, cr, uid, tax, context=None):
        """
        This is used to check that every (purchase) tax code is linked to
        only one (main) tax.
        This allows to print a VAT register summary where
Severity: Minor
Found in l10n_it_account/models/account_tax.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

Function get_tax_by_tax_code has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def get_tax_by_tax_code(self):
        """
        Get account.tax linked to current tax code.
        If the account.tax has a parent, the parent account.tax is returned.
        """
Severity: Minor
Found in l10n_it_account/models/account_tax.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

Function _build_codes_dict has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def _build_codes_dict(self, tax_code, res=None):
        # TODO context
        if res is None:
            res = {}
        tax_model = self.env['account.tax']
Severity: Minor
Found in l10n_it_account/models/account_tax.py - About 2 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 taxes:
            tax = taxes[0]
            # search for the related base code
            base_code = (
                tax.base_code_id or tax.parent_id and
Severity: Major
Found in l10n_it_account/models/account_tax.py - About 1 hr to fix

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

        def _compute_tax_amount(self, tax, tax_code, base_code):
            '''
            The Tax is child of another main tax.
            The main tax has more childs:
            - Child with tax_code_id are deductible
    Severity: Minor
    Found in l10n_it_account/models/account_tax.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 exist has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def exist(self, cr, uid, field, value, id_doc, context=None):
    Severity: Minor
    Found in l10n_it_account/models/account_tax.py - About 45 mins to fix

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

          def write(self, cr, uid, ids, vals, context=None):
      Severity: Minor
      Found in l10n_it_account/models/account_tax.py - About 35 mins to fix

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

            def copy_data(self, cr, uid, id, default=None, context=None):
        Severity: Minor
        Found in l10n_it_account/models/account_tax.py - About 35 mins to fix

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

                      if tax.ref_base_code_id:
                          if self.exist(
                              cr, uid, 'ref_base_code_id', tax.ref_base_code_id.id,
                              tax.id, context=context
                          ):
          Severity: Major
          Found in l10n_it_account/models/account_tax.py and 3 other locations - About 2 hrs to fix
          l10n_it_account/models/account_tax.py on lines 235..243
          l10n_it_account/models/account_tax.py on lines 244..252
          l10n_it_account/models/account_tax.py on lines 262..270

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

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

                      if tax.tax_code_id:
                          if self.exist(
                              cr, uid, 'tax_code_id', tax.tax_code_id.id, tax.id,
                              context=context
                          ):
          Severity: Major
          Found in l10n_it_account/models/account_tax.py and 3 other locations - About 2 hrs to fix
          l10n_it_account/models/account_tax.py on lines 235..243
          l10n_it_account/models/account_tax.py on lines 253..261
          l10n_it_account/models/account_tax.py on lines 262..270

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

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

                      if tax.base_code_id:
                          if self.exist(
                              cr, uid, 'base_code_id', tax.base_code_id.id, tax.id,
                              context=context
                          ):
          Severity: Major
          Found in l10n_it_account/models/account_tax.py and 3 other locations - About 2 hrs to fix
          l10n_it_account/models/account_tax.py on lines 244..252
          l10n_it_account/models/account_tax.py on lines 253..261
          l10n_it_account/models/account_tax.py on lines 262..270

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

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

                      if tax.ref_tax_code_id:
                          if self.exist(
                              cr, uid, 'ref_tax_code_id', tax.ref_tax_code_id.id,
                              tax.id, context=context
                          ):
          Severity: Major
          Found in l10n_it_account/models/account_tax.py and 3 other locations - About 2 hrs to fix
          l10n_it_account/models/account_tax.py on lines 235..243
          l10n_it_account/models/account_tax.py on lines 244..252
          l10n_it_account/models/account_tax.py on lines 253..261

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

          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