OCA/l10n-italy

View on GitHub
l10n_it_fatturapa/models/company.py

Summary

Maintainability
C
1 day
Test Coverage

Consider simplifying this complex logical expression.
Open

        if company_id:
            company = self.pool.get('res.company').browse(
                cr, uid, company_id, context=context)
            default_sequence = self.pool.get('ir.sequence').search(cr, uid, [
                ('code', '=', 'account.invoice.fatturapa')
Severity: Critical
Found in l10n_it_fatturapa/models/company.py - About 5 hrs to fix

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

        def onchange_company_id(self, cr, uid, ids, company_id, context=None):
            res = super(AccountConfigSettings, self).onchange_company_id(
                cr, uid, ids, company_id, context=context)
            if company_id:
                company = self.pool.get('res.company').browse(
    Severity: Minor
    Found in l10n_it_fatturapa/models/company.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 onchange_company_id has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def onchange_company_id(self, cr, uid, ids, company_id, context=None):
    Severity: Minor
    Found in l10n_it_fatturapa/models/company.py - About 35 mins to fix

      Function _check_fatturapa_sequence_id has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _check_fatturapa_sequence_id(self):
              for company in self:
                  if company.fatturapa_sequence_id:
                      journal = self.env['account.journal'].search([
                          ('sequence_id', '=', company.fatturapa_sequence_id.id)
      Severity: Minor
      Found in l10n_it_fatturapa/models/company.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

      There are no issues that match your filters.

      Category
      Status