OCA/l10n-italy

View on GitHub
l10n_it_fatturapa_in/models/account.py

Summary

Maintainability
F
3 days
Test Coverage

File account.py has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

from openerp import fields, models, api, _
from openerp.exceptions import ValidationError, Warning as UserError
from openerp.tools import float_compare
Severity: Minor
Found in l10n_it_fatturapa_in/models/account.py - About 3 hrs to fix

    Function _compute_e_invoice_validation_error has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def _compute_e_invoice_validation_error(self):
            bills_to_check = self.filtered(
                lambda inv:
                    inv.type in ['in_invoice', 'in_refund'] and
                    inv.state in ['draft', 'open', 'paid'] and
    Severity: Minor
    Found in l10n_it_fatturapa_in/models/account.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 action_move_create has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def action_move_create(self):
            """Append global rounding move lines"""
            res = super(AccountInvoice, self).action_move_create()
            for invoice in self:
                if invoice.efatt_rounding != 0:
    Severity: Minor
    Found in l10n_it_fatturapa_in/models/account.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_amount has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def _compute_amount(self):
            super(AccountInvoice, self)._compute_amount()
            if self.efatt_rounding != 0:
                self.amount_total += self.efatt_rounding
                amount_total_company_signed = self.amount_total
    Severity: Minor
    Found in l10n_it_fatturapa_in/models/account.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

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

        def name_get(self):
            result = super(AccountInvoice, self).name_get()
            res = []
            for tup in result:
                invoice = self.browse(tup[0])
    Severity: Minor
    Found in l10n_it_fatturapa_in/models/account.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

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

        def e_inv_check_amount_tax(self):
            error_message = ''
            if (self.e_invoice_amount_tax and
                    float_compare(self.amount_tax,
                                  abs(self.e_invoice_amount_tax),
    Severity: Major
    Found in l10n_it_fatturapa_in/models/account.py and 2 other locations - About 4 hrs to fix
    l10n_it_fatturapa_in/models/account.py on lines 109..127
    l10n_it_fatturapa_in/models/account.py on lines 146..161

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

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

        def e_inv_check_amount_untaxed(self):
            error_message = ''
            if (self.e_invoice_amount_untaxed and
                    float_compare(self.amount_untaxed,
                                  # Using abs because odoo invoice total can't be negative,
    Severity: Major
    Found in l10n_it_fatturapa_in/models/account.py and 2 other locations - About 4 hrs to fix
    l10n_it_fatturapa_in/models/account.py on lines 129..144
    l10n_it_fatturapa_in/models/account.py on lines 146..161

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

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

        def e_inv_check_amount_total(self):
            error_message = ''
            if (self.e_invoice_amount_total and
                    float_compare(self.amount_total,
                                  abs(self.e_invoice_amount_total),
    Severity: Major
    Found in l10n_it_fatturapa_in/models/account.py and 2 other locations - About 4 hrs to fix
    l10n_it_fatturapa_in/models/account.py on lines 109..127
    l10n_it_fatturapa_in/models/account.py on lines 129..144

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

    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 (bill.e_invoice_reference and
                        bill.reference != bill.e_invoice_reference):
                    error_messages.append(
                        _("Vendor reference ({bill_vendor_ref}) "
                          "does not match with "
    Severity: Major
    Found in l10n_it_fatturapa_in/models/account.py and 1 other location - About 2 hrs to fix
    l10n_it_fatturapa_in/models/account.py on lines 222..230

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

    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 (bill.e_invoice_date_invoice and
                        bill.e_invoice_date_invoice != bill.date_invoice):
                    error_messages.append(
                        _("Invoice date ({bill_date_invoice}) "
                          "does not match with "
    Severity: Major
    Found in l10n_it_fatturapa_in/models/account.py and 1 other location - About 2 hrs to fix
    l10n_it_fatturapa_in/models/account.py on lines 211..219

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

    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