OCA/l10n-italy

View on GitHub
l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py

Summary

Maintainability
F
1 wk
Test Coverage

File test_import_fatturapa_xml.py has 705 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

from openerp.exceptions import Warning as UserError
from .fatturapa_common import FatturapaCommon

Severity: Major
Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py - About 1 day to fix

    TestFatturaPAXMLValidation has 40 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class TestFatturaPAXMLValidation(FatturapaCommon):
    
        def setUp(self):
            super(TestFatturaPAXMLValidation, self).setUp()
            self.wt = self.create_wt_4q()
    Severity: Minor
    Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py - About 5 hrs to fix

      Function test_16_xml_import has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def test_16_xml_import(self):
              # file B2B downloaded from
              # http://www.fatturapa.gov.it/export/fatturazione/it/a-3.htm
              res = self.run_wizard('test16a', 'IT01234567890_FPR03.xml')
              invoice_ids = res.get('domain')[0][2]
      Severity: Minor
      Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.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

      Function test_01_xml_import has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def test_01_xml_import(self):
              res = self.run_wizard('test1', 'IT02780790107_11004.xml')
              invoice_id = res.get('domain')[0][2][0]
              invoice = self.invoice_model.browse(invoice_id)
              self.assertEqual(invoice.reference, '123')
      Severity: Minor
      Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py - About 1 hr to fix

        Function test_00_xml_import has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def test_00_xml_import(self):
                self.env.user.company_id.cassa_previdenziale_product_id = (
                    self.service.id)
                res = self.run_wizard('test0', 'IT05979361218_001.xml')
                invoice_id = res.get('domain')[0][2][0]
        Severity: Minor
        Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py - About 1 hr to fix

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

              def test_42_xml_import(self):
                  res = self.run_wizard('test42', 'IT01234567890_FPR05.xml')
                  invoice_id = res.get('domain')[0][2][0]
                  invoice = self.invoice_model.browse(invoice_id)
                  self.assertEqual(invoice.invoice_line[1].discount, 100)
          Severity: Major
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 1 other location - About 7 hrs to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 481..487

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

          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 test_31_xml_import(self):
                  res = self.run_wizard('test31', 'IT01234567890_FPR05.xml')
                  invoice_id = res.get('domain')[0][2][0]
                  invoice = self.invoice_model.browse(invoice_id)
                  self.assertEqual(invoice.invoice_line[1].discount, 100)
          Severity: Major
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 1 other location - About 7 hrs to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 672..678

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

          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

                  self.env['withholding.tax'].create({
                      'name': '1040/3',
                      'code': '1040',
                      'account_receivable_id': account_receivable.id,
                      'account_payable_id': account_payable.id,
          Severity: Major
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 3 other locations - About 4 hrs to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 703..716
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 719..732
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 751..764

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

          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

                  self.env['withholding.tax'].create({
                      'name': '1040 R',
                      'code': '1040R',
                      'account_receivable_id': account_receivable.id,
                      'account_payable_id': account_payable.id,
          Severity: Major
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 3 other locations - About 4 hrs to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 703..716
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 719..732
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 735..748

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

          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

                  self.env['withholding.tax'].create({
                      'name': 'Enasarco',
                      'code': 'TC07',
                      'account_receivable_id': account_receivable.id,
                      'account_payable_id': account_payable.id,
          Severity: Major
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 3 other locations - About 4 hrs to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 719..732
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 735..748
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 751..764

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

          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

                  self.env['withholding.tax'].create({
                      'name': 'Enasarco 8,50',
                      'code': 'TC07',
                      'account_receivable_id': account_receivable.id,
                      'account_payable_id': account_payable.id,
          Severity: Major
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 3 other locations - About 4 hrs to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 703..716
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 735..748
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 751..764

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

          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 test_20_xml_import(self):
                  # Testing xml without xml declaration (sent by Amazon)
                  res = self.run_wizard('test20', 'IT05979361218_no_decl.xml')
                  invoice_id = res.get('domain')[0][2][0]
                  invoice = self.invoice_model.browse(invoice_id)
          Severity: Major
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 1 other location - About 4 hrs to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 98..102

          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 test_02_xml_import(self):
                  res = self.run_wizard('test02', 'IT05979361218_011.xml')
                  invoice_id = res.get('domain')[0][2][0]
                  invoice = self.invoice_model.browse(invoice_id)
                  self.assertEqual(invoice.intermediary.vat, 'IT03339130126')
          Severity: Major
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 1 other location - About 4 hrs to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 372..377

          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

                      if invoice.reference == '456':
                          self.assertTrue(len(invoice.invoice_line) == 1)
                          for line in invoice.invoice_line:
                              self.assertFalse(line.product_id)
          Severity: Major
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 1 other location - About 2 hrs to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 307..310

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

          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.reference == '123':
                          self.assertTrue(len(invoice.invoice_line) == 2)
                          for line in invoice.invoice_line:
                              self.assertFalse(line.product_id)
          Severity: Major
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 1 other location - About 2 hrs to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 311..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 52.

          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

                  account_payable = self.env['account.account'].create({
                      'name': 'Test WH tax',
                      'code': 'whtaxpay2',
                      'user_type': self.env.ref(
                          'account.data_account_type_payable').id,
          Severity: Major
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 1 other location - About 1 hr to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 695..700

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

          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

                  account_receivable = self.env['account.account'].create({
                      'name': 'Test WH tax',
                      'code': 'whtaxrec2',
                      'user_type': self.env.ref(
                          'account.data_account_type_receivable').id,
          Severity: Major
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 1 other location - About 1 hr to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 689..694

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

          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

                  self.assertEqual(
                      invoice.fatturapa_payments[0].payment_methods[0].payment_bank.bank.name,
                      'Banca generica')
          Severity: Minor
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 1 other location - About 30 mins to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 552..554

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

          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

                  self.assertEqual(
                      invoice.fatturapa_payments[0].payment_methods[0].payment_bank.bank.bic,
                      'BCITITMM')
          Severity: Minor
          Found in l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py and 1 other location - About 30 mins to fix
          l10n_it_fatturapa_in/tests/test_import_fatturapa_xml.py on lines 555..557

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

          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