OCA/server-tools

View on GitHub

Showing 207 of 317 total issues

File field_rrule.js has 303 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).

openerp.field_rrule = function(instance)
Severity: Minor
Found in field_rrule/static/src/js/field_rrule.js - About 3 hrs to fix

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

        def _get_data(self):
            ram = 0
            cpu = 0
            if psutil:
                process = psutil.Process(os.getpid())
    Severity: Minor
    Found in dead_mans_switch_client/models/dead_mans_switch_client.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 action_populate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def action_populate(self, cr, uid, ids, context=None):
            """
            Prepopulate the user table from one or more LDAP resources.
    
            Obviously, the option to create users must be toggled in
    Severity: Minor
    Found in users_ldap_populate/models/users_ldap.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 imgs_from_html has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def imgs_from_html(self, html_content, limit=None, fail=False):
            """Extract all images in order from an HTML field in a generator.
    
            :param str html_content:
                HTML contents from where to extract the images.
    Severity: Minor
    Found in html_image_url_extractor/models/ir_fields_converter.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 _run_import has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def _run_import(self, commit=True, commit_threshold=100):
            """Run the import as cronjob, commit often"""
            self.ensure_one()
            if not self.password:
                return
    Severity: Minor
    Found in base_import_odoo/models/import_odoo_database.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 _walk has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def _walk(top, exclude_patterns, keep_langs):
        keep_langs = {l.split('_')[0] for l in keep_langs}
        for dirpath, dirnames, filenames in os.walk(top):
            dirnames.sort()
            reldir = os.path.relpath(dirpath, top)
    Severity: Minor
    Found in module_auto_update/addon_hash.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 _run_import_create_dummy has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def _run_import_create_dummy(
            self, context, model, record, forcecreate=False,
        ):
            """Either misuse some existing record or create an empty one to satisfy
            required links"""
    Severity: Minor
    Found in base_import_odoo/models/import_odoo_database.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 _revert_methods has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def _revert_methods(self):
            """Restore original ORM methods of models defined in rules."""
            updated = False
            for rule in self:
                model_model = self.env[rule.model_id.model or rule.model_model]
    Severity: Minor
    Found in auditlog/models/rule.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

    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

      AuditlogRule has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class AuditlogRule(models.Model):
          _name = 'auditlog.rule'
          _description = "Auditlog - Rule"
      
          name = fields.Char(u"Name", size=32, required=True)
      Severity: Minor
      Found in auditlog/models/rule.py - About 2 hrs to fix

        Function attach_mail has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def attach_mail(self, connection, object_id, folder, mail_message, msgid):
                '''Return ids of messages created'''
        
                mail_message_ids = []
        
        
        Severity: Minor
        Found in fetchmail_attach_from_folder/model/fetchmail_server.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 fields_view_get has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def fields_view_get(
                    self, cr, uid, view_id=None, view_type='form', context=None,
                    toolbar=False, submenu=False):
                s_set = _("Set")
                s_add = _("Add")
        Severity: Minor
        Found in mass_editing/wizard/mass_editing_wizard.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

        File db_backup.py has 260 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        # © 2004-2009 Tiny SPRL (<http://tiny.be>).
        # © 2015 Agile Business Group <http://www.agilebg.com>
        # © 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
        # License AGPL-3.0 or later (http://www.gnu.org/licenses/gpl.html).
        Severity: Minor
        Found in auto_backup/models/db_backup.py - About 2 hrs to fix

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

              def __iter__(self):
                  for rule in self._rrule:
                      yield dict(type='rrule', **{
                          key[1:]:
                          fields.Datetime.to_string(
          Severity: Minor
          Found in field_rrule/field_rrule.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_backup has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def action_backup(self):
                  """Run selected backups."""
                  backup = None
                  filename = self.filename(datetime.now())
                  successful = self.browse()
          Severity: Minor
          Found in auto_backup/models/db_backup.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 push_to_ldap has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def push_to_ldap(self, values):
                  for this in self:
                      if not values.get('is_ldap_user') and not this.is_ldap_user:
                          continue
                      if not this._push_to_ldap_possible(values):
          Severity: Minor
          Found in users_ldap_push/models/res_users.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 fixup_arch has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def fixup_arch(cls, archstr):
                  doc = lxml.etree.fromstring(archstr)
                  for elem in doc.xpath("//*[@name]"):
                      elem.attrib["name"] = cls.unprefix(elem.attrib["name"])
          
          
          Severity: Minor
          Found in module_prototyper/models/module_prototyper.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 _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 _execute_sql_request has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def _execute_sql_request(
                      self, params=None, mode='fetchall', rollback=True,
                      view_name=False, copy_options="CSV HEADER DELIMITER ';'"):
                  """Execute a SQL request on the current database.
          
          
          Severity: Minor
          Found in sql_request_abstract/models/sql_request_mixin.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 profiler has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          openerp.profiler = function(instance) {
              instance.profiler.Player = instance.web.Widget.extend({
                  template: 'profiler.player',
                  events: {
                      "click .profiler_enable": "enable",
          Severity: Minor
          Found in profiler/static/src/js/player.js - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language