OCA/server-tools

View on GitHub
base_mixin_restrict_field_access/models/restrict_field_access_mixin.py

Summary

Maintainability
C
1 day
Test Coverage

File restrict_field_access_mixin.py has 266 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
# © 2016 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import json
from lxml import etree

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

        def _BaseModel__export_rows(self, fields):
            """Null inaccessible fields"""
            result = []
            for this in self:
                rows = super(RestrictFieldAccessMixin, this)\

    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 _restrict_field_access_adjust_field_modifiers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def _restrict_field_access_adjust_field_modifiers(self, field_node,
                                                          modifiers):
            """inject a readonly modifier to make non-writable fields in a form
            readonly"""
            # TODO: this can be fooled by embedded views

    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 read has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def read(self, fields=None, load='_classic_read'):
            result = super(RestrictFieldAccessMixin, self).read(
                fields=fields, load=load)
            for record in result:
                this = self.browse(record['id'])

    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 _search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def _search(self, args, offset=0, limit=None, order=None, count=False,
                    access_rights_uid=None):
            if not args:
                return super(RestrictFieldAccessMixin, self)._search(
                    args, offset=offset, limit=limit, order=order, count=count,
    Severity: Minor
    Found in base_mixin_restrict_field_access/models/restrict_field_access_mixin.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 fields_view_get has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def fields_view_get(self, cr, uid, view_id=None, view_type='form',
    Severity: Major
    Found in base_mixin_restrict_field_access/models/restrict_field_access_mixin.py - About 50 mins to fix

      Function read_group has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def read_group(self, domain, fields, groupby, offset=0, limit=None,
      Severity: Major
      Found in base_mixin_restrict_field_access/models/restrict_field_access_mixin.py - About 50 mins to fix

        Function _search has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _search(self, args, offset=0, limit=None, order=None, count=False,
        Severity: Minor
        Found in base_mixin_restrict_field_access/models/restrict_field_access_mixin.py - About 45 mins to fix

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

              def read_group(self, domain, fields, groupby, offset=0, limit=None,
                             orderby=False, lazy=True):
                  """Restrict reading if we read an inaccessible field"""
                  has_inaccessible_field = False
                  has_inaccessible_field |= any(
          Severity: Minor
          Found in base_mixin_restrict_field_access/models/restrict_field_access_mixin.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