OCA/server-tools

View on GitHub

Showing 207 of 317 total issues

Function _compute_label has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _compute_label(self):
        """Column label in a user-friendly format and language."""
        for one in self:
            parts = list()
            for num in range(1, 5):
Severity: Minor
Found in base_export_manager/models/ir_exports_line.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

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

    def execute(self, cr, uid, ids, sqlquery, sqlparams=None, metadata=False,
                context=None):
        """Executes SQL and returns a list of rows.

            "sqlparams" can be a dict of values, that can be referenced in
Severity: Minor
Found in base_external_dbsource/base_external_dbsource.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

Function message_route_verify has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def message_route_verify(
Severity: Major
Found in fetchmail_notify_error_to_sender/mail_thread.py - About 1 hr to fix

    Function convert_to_cache_parse_data_rrule has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def convert_to_cache_parse_data_rrule(self, record, data):
            """parse a data dictionary from the database"""
            return {
                key: fields.Datetime.from_string(value)
                if '_%s' % key in _RRULE_DATETIME_FIELDS
    Severity: Minor
    Found in field_rrule/field_rrule.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

    Function _compute_is_enabled has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _compute_is_enabled(self):
            today = datetime.date.today()
            for role_line in self:
                role_line.is_enabled = True
                if role_line.date_from:
    Severity: Minor
    Found in base_user_role/models/role.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

    Function datetime_formatter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def datetime_formatter(self, value, lang=None, template=MODE_DATETIME,
                               separator=" ", failure_safe=True):
            """Convert a datetime field to lang's default format.
    
            :type value: `str`, `float` or `datetime.datetime`
    Severity: Minor
    Found in datetime_formatter/models.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

    Function default_get has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def default_get(self, cr, uid, fields_list, context=None):
            if context is None:
                context = {}
    
            defaults = super(attach_mail_manually, self).default_get(
    Severity: Minor
    Found in fetchmail_attach_from_folder/wizard/attach_mail_manually.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

    Function reset_fields has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            reset_fields: function(rule, current_item, field)
            {
                // for some fields, we should reset some other fields when they
                // were changed
                if(field == 'freq')
    Severity: Minor
    Found in field_rrule/static/src/js/field_rrule.js - About 1 hr to fix

      Function handle_match has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def handle_match(
      Severity: Major
      Found in fetchmail_attach_from_folder/match_algorithm/openerp_standard.py - About 1 hr to fix

        Function handle_match has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def handle_match(
        Severity: Major
        Found in fetchmail_attach_from_folder/match_algorithm/base.py - About 1 hr to fix

          Function cleanup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def cleanup(self):
                  """Clean up old backups."""
                  for rec in self.filtered("days_to_keep"):
                      with rec.cleanup_log():
                          if rec.method == "local":
          Severity: Minor
          Found in auto_backup/models/db_backup.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

          Function _set_multi_image has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def _set_multi_image(self, image=False, name=False):
                  """Save or delete the main image for this record.
          
                  This is provided as a compatibility layer for submodels that already
                  had one image per record.
          Severity: Minor
          Found in base_multi_image/models/owner.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

          Function export_sql has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def export_sql(self):
                  self.ensure_one()
                  sql_export = self.sql_export_id
          
                  # Manage Params
          Severity: Minor
          Found in sql_export/wizard/wizard_file.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

          Function _send_email_passkey has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def _send_email_passkey(self, user_agent_env):
                  """ Send a email to the admin of the system and / or the user
           to inform passkey use."""
                  mails = []
                  mail_obj = self.env['mail.mail']
          Severity: Minor
          Found in auth_admin_passkey/models/res_users.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

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

              def _get_incom_conf(self, cr, uid, ids, name, args, context=None):
                  """
                  Return configuration
                  """
                  res = {}
          Severity: Minor
          Found in mail_environment/env_mail.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

          Function create_logs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def create_logs(self, uid, res_model, res_ids, method,
                              old_values=None, new_values=None,
                              additional_log_values=None):
                  """Create logs. `old_values` and `new_values` are dictionnaries, e.g:
                      {RES_ID: {'FIELD': VALUE, ...}}
          Severity: Minor
          Found in auditlog/models/rule.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

          Function with_language_path has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def with_language_path(self, path=None):
                  """ This method allows the system to iterate over a RecordSet with each
                  of the records being browsed in the language specified by the model's
                  _language_path attribute. Of course, this is a cache killer. It was
                  conceived to make translations in rml reports work again as using
          Severity: Minor
          Found in language_path_mixin/models/language_path_mixin.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

          Function message_route has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def message_route(
          Severity: Major
          Found in fetchmail_notify_error_to_sender/mail_thread.py - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language