OCA/l10n-italy

View on GitHub
l10n_it_fiscalcode/wizard/compute_fc.py

Summary

Maintainability
D
2 days
Test Coverage

Function _check_national_codes has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    def _check_national_codes(
            self, birth_city, birth_prov, birth_date, cities):
        nc = ''
        dtcostvar = None
        for ct in cities:
Severity: Minor
Found in l10n_it_fiscalcode/wizard/compute_fc.py - About 5 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 not ct.notes:
                nc = ct.national_code
            elif (ct.notes == 'ORA' and
                    (not dtcostvar or not ct.var_date or
                        dtcostvar < ct.var_date)):
Severity: Critical
Found in l10n_it_fiscalcode/wizard/compute_fc.py - About 3 hrs to fix

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

        def compute_fc(self):
            active_id = self._context.get('active_id')
            partner = self.env['res.partner'].browse(active_id)
            for f in self:
                if (not f.fiscalcode_surname or not f.fiscalcode_firstname or
    Severity: Minor
    Found in l10n_it_fiscalcode/wizard/compute_fc.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 _get_national_code has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_national_code(self, birth_city, birth_prov, birth_date):
            """
            notes fields contains variation data while var_date may contain the
            eventual date of the variation. notes may be:
            - ORA: city changed name, name_var contains new name, national_code_var
    Severity: Minor
    Found in l10n_it_fiscalcode/wizard/compute_fc.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

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

                elif (ct.notes == 'AGG' and
                        (not dtcostvar or not ct.var_date or
                            dtcostvar < ct.var_date)):
                    if (not ct.var_date or ct.var_date <= birth_date):
                        nc = ct.national_code_var
    Severity: Major
    Found in l10n_it_fiscalcode/wizard/compute_fc.py and 1 other location - About 2 hrs to fix
    l10n_it_fiscalcode/wizard/compute_fc.py on lines 120..128

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

    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

                elif (ct.notes == 'ORA' and
                        (not dtcostvar or not ct.var_date or
                            dtcostvar < ct.var_date)):
                    if (not ct.var_date or ct.var_date <= birth_date):
                        nc = ct.national_code_var
    Severity: Major
    Found in l10n_it_fiscalcode/wizard/compute_fc.py and 1 other location - About 2 hrs to fix
    l10n_it_fiscalcode/wizard/compute_fc.py on lines 129..137

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

    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

                elif (ct.notes == 'AGP' and
                        (not dtcostvar or not ct.var_date or
                            dtcostvar < ct.var_date)):
    Severity: Major
    Found in l10n_it_fiscalcode/wizard/compute_fc.py and 3 other locations - About 1 hr to fix
    l10n_it_fiscalcode/wizard/compute_fc.py on lines 120..122
    l10n_it_fiscalcode/wizard/compute_fc.py on lines 129..131
    l10n_it_fiscalcode/wizard/compute_fc.py on lines 144..146

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

    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

                elif (ct.notes == 'AGP' and
                        (not dtcostvar or not ct.var_date or
                            dtcostvar < ct.var_date)):
    Severity: Major
    Found in l10n_it_fiscalcode/wizard/compute_fc.py and 3 other locations - About 1 hr to fix
    l10n_it_fiscalcode/wizard/compute_fc.py on lines 120..122
    l10n_it_fiscalcode/wizard/compute_fc.py on lines 129..131
    l10n_it_fiscalcode/wizard/compute_fc.py on lines 138..140

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

    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