OCA/server-tools

View on GitHub

Showing 317 of 317 total issues

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

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

                elif key == 'ir.actions.report.xml':
                    res[mnames[data_id.module]]['reports_by_module'].append(
                        report_obj.browse(cr, uid, data_id.res_id).name
Severity: Major
Found in base_module_doc_rst/wizard/tech_rst_guide.py and 1 other location - About 1 hr to fix
base_module_doc_rst/wizard/tech_rst_guide.py on lines 455..457

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 41.

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

    @api.multi
    def set_auth_admin_passkey_send_to_admin(self):
        for config in self:
            self.env['ir.config_parameter'].set_param(
                "auth_admin_passkey.send_to_admin",
Severity: Major
Found in auth_admin_passkey/models/res_config.py and 1 other location - About 1 hr to fix
auth_admin_passkey/models/res_config.py on lines 36..41

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 41.

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

    @api.multi
    def set_auth_admin_passkey_send_to_user(self):
        for config in self:
            self.env['ir.config_parameter'].set_param(
                "auth_admin_passkey.send_to_user",
Severity: Major
Found in auth_admin_passkey/models/res_config.py and 1 other location - About 1 hr to fix
auth_admin_passkey/models/res_config.py on lines 21..26

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 41.

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

                elif key == 'ir.ui.menu':
                    res[mnames[data_id.module]]['menus_by_module'].append(
                        menu_obj.browse(cr, uid, data_id.res_id).complete_name
Severity: Major
Found in base_module_doc_rst/wizard/tech_rst_guide.py and 1 other location - About 1 hr to fix
base_module_doc_rst/wizard/tech_rst_guide.py on lines 451..453

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 41.

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 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

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

            def _register_hook(self, cr):
                self._patch_quick_create(cr, self.search(cr, SUPERUSER_ID, []))
                return super(IrModel, self)._register_hook(cr)
        Severity: Major
        Found in base_optional_quick_create/model.py and 1 other location - About 1 hr to fix
        base_field_validator/models/ir_model.py on lines 66..68

        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 39.

        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 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

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

            def _register_hook(self, cr):
                self._field_validator_hook(cr, self.search(cr, SUPERUSER_ID, []))
                return super(IrModel, self)._register_hook(cr)
        Severity: Major
        Found in base_field_validator/models/ir_model.py and 1 other location - About 1 hr to fix
        base_optional_quick_create/model.py on lines 51..53

        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 39.

        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

        Severity
        Category
        Status
        Source
        Language