shopinvader/odoo-shopinvader

View on GitHub
partner_contact_company/models/partner.py

Summary

Maintainability
B
4 hrs
Test Coverage

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

    def name_get(self):
        res = []
        for partner in self:
            name = partner.name or ""

Severity: Minor
Found in partner_contact_company/models/partner.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 _inverse_name has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def _inverse_name(self):
        """Try to revert the effect of :meth:`._compute_name`."""
        for record in self:
            names = record.name.split(", ", 1)
            if record.is_company:
Severity: Minor
Found in partner_contact_company/models/partner.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

Consider simplifying this complex logical expression.
Open

            if record.is_company:
                company = names[0]
                contact_name = len(names) > 1 and names[1] or ""
            else:
                company = len(names) > 1 and names[0] or ""
Severity: Major
Found in partner_contact_company/models/partner.py - About 1 hr to fix

    There are no issues that match your filters.

    Category
    Status