OCA/server-tools

View on GitHub

Showing 317 of 317 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    try:
        import MySQLdb
        CONNECTORS.append(('mysql', 'MySQL'))
        assert MySQLdb
    except (ImportError, AssertionError):
Severity: Minor
Found in base_external_dbsource/base_external_dbsource.py and 1 other location - About 55 mins to fix
base_external_dbsource/base_external_dbsource.py on lines 39..44

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 37.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    @api.model
    def create(self, vals):
        new_record = super(ResUsers, self).create(vals)
        new_record.set_groups_from_roles()
        return new_record
Severity: Major
Found in base_user_role/models/user.py and 2 other locations - About 55 mins to fix
base_user_role/models/role.py on lines 39..43
base_user_role/models/role.py on lines 45..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 37.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    def fields_view_get(self, cr, user, view_id=None, view_type='form',
Severity: Major
Found in fetchmail_attach_from_folder/wizard/attach_mail_manually.py - About 50 mins to fix

    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 server_environment/serv_config.py - About 50 mins to fix

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

          def _handle_callback_exception(self, cr, uid, model_name, method_name,
      Severity: Major
      Found in scheduler_error_mailer/ir_cron.py - About 50 mins to fix

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

            def _import_data(self, cr, uid, flds, data, model_obj, table_obj, log):
        Severity: Major
        Found in import_odbc/import_odbc.py - About 50 mins to fix

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

              def fields_view_get(self, cr, user, view_id=None, view_type='form',
          Severity: Major
          Found in fetchmail_attach_from_folder/model/fetchmail_server.py - About 50 mins to fix

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

                def create_logs(self, uid, res_model, res_ids, method,
            Severity: Major
            Found in auditlog/models/rule.py - About 50 mins to fix

              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 execute has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def execute(self, cr, uid, ids, sqlquery, sqlparams=None, metadata=False,
                  Severity: Major
                  Found in base_external_dbsource/base_external_dbsource.py - About 50 mins to fix

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

                        def fields_view_get(
                    Severity: Major
                    Found in mass_editing/wizard/mass_editing_wizard.py - About 50 mins to fix

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                              if 'model_id' not in vals or not vals['model_id']:
                                  raise UserError(_("No model defined to create line."))
                      Severity: Minor
                      Found in auditlog/models/rule.py and 1 other location - About 50 mins to fix
                      auditlog/models/log.py on lines 75..76

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 36.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                              if 'field_id' not in vals or not vals['field_id']:
                                  raise UserError(_("No field defined to create line."))
                      Severity: Minor
                      Found in auditlog/models/log.py and 1 other location - About 50 mins to fix
                      auditlog/models/rule.py on lines 228..229

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 36.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Function _add_tz has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def _add_tz(self, value, tz):
                              """set the timezone on an rruleset and adjust dates there"""
                              value.tz = tz
                              tz = gettz(tz)
                              for rule in value._rrule:
                      Severity: Minor
                      Found in field_rrule/field_rrule.py - About 45 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

                      Avoid deeply nested control flow statements.
                      Open

                                              with rec.sftp_connection() as remote:
                                                  # Directory must exist
                                                  try:
                                                      remote.makedirs(rec.folder)
                                                  except pysftp.ConnectionException:
                      Severity: Major
                      Found in auto_backup/models/db_backup.py - About 45 mins to fix

                        Function _check_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def _check_name(self):
                                for one in self:
                                    if not one.label:
                                        raise exceptions.ValidationError(
                                            _("Field '%s' does not exist") % one.name)
                        Severity: Minor
                        Found in base_export_manager/models/ir_exports_line.py - About 45 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

                        Avoid deeply nested control flow statements.
                        Open

                                                for name in sorted(
                                                        n for n in remote.listdir(rec.folder)
                                                        if n.endswith(".dump.zip")
                                                )[:-rec.days_to_keep]:
                                                    remote.unlink('%s/%s' % (rec.folder, name))
                        Severity: Major
                        Found in auto_backup/models/db_backup.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if basename.split('_')[0] not in keep_langs:
                                                  continue
                                      yield filepath
                          Severity: Major
                          Found in module_auto_update/addon_hash.py - About 45 mins to fix

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

                                def onchange_server_type(
                            Severity: Minor
                            Found in fetchmail_attach_from_folder/model/fetchmail_server.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language