OCA/openupgradelib

View on GitHub

Showing 159 of 159 total issues

File openupgrade.py has 3117 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*- # pylint: disable=C8202
# Copyright 2011-2020 Therp BV <https://therp.nl>.
# Copyright 2016-2020 Tecnativa - Pedro M. Baeza.
# Copyright Odoo Community Association (OCA)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
Severity: Major
Found in openupgradelib/openupgrade.py - About 1 wk to fix

    File openupgrade_merge_records.py has 1004 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*- # pylint: disable=C8202
    # Copyright 2018 Tecnativa - Pedro M. Baeza
    # Copyright 2018 Opener B.V. - Stefan Rijnhart
    # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
    
    
    Severity: Major
    Found in openupgradelib/openupgrade_merge_records.py - About 2 days to fix

      Function apply_operations_by_field_type has a Cognitive Complexity of 124 (exceeds 5 allowed). Consider refactoring.
      Open

      def apply_operations_by_field_type(
          env,
          model_name,
          record_ids,
          target_record_id,
      Severity: Minor
      Found in openupgradelib/openupgrade_merge_records.py - About 2 days 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_defaults has a Cognitive Complexity of 105 (exceeds 5 allowed). Consider refactoring.
      Open

      def set_defaults(cr, pool, default_spec, force=False, use_orm=False):
          """
          Set default value. Useful for fields that are newly required. Uses orm, so
          call from the post script.
      
      
      Severity: Minor
      Found in openupgradelib/openupgrade.py - About 2 days 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 Stemmer has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
      Open

      var Stemmer = function() {
      
        var step2list = {
          ational: 'ate',
          tional: 'tion',
      Severity: Minor
      Found in docs/_static/language_data.js - About 1 day 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 convert_xml_node has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
      Open

      def convert_xml_node(
          node,
          attr_add=None,
          attr_rm=frozenset(),
          class_add="",
      Severity: Minor
      Found in openupgradelib/openupgrade_tools.py - About 1 day 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 _change_generic has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
      Open

      def _change_generic(
          env,
          model_name,
          record_ids,
          target_record_id,
      Severity: Minor
      Found in openupgradelib/openupgrade_merge_records.py - About 6 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 openupgrade_160.py has 428 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # Copyright 2022 ACSONE SA/NV
      # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
      
      """This module provides simple tools for OpenUpgrade migration, specific for
      the >=16.0 migration.
      Severity: Minor
      Found in openupgradelib/openupgrade_160.py - About 6 hrs to fix

        Function disable_invalid_filters has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
        Open

        def disable_invalid_filters(env):
            """It analyzes all the existing active filters to check if they are still
            correct. If not, they are disabled for avoiding errors when clicking on
            them, or worse, if they are default filters when opening the model/action.
        
        
        Severity: Minor
        Found in openupgradelib/openupgrade.py - About 6 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 add_fields has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
        Open

        def add_fields(env, field_spec):
            """This method adds all the needed stuff for having a new field populated
            in the DB (SQL column, ir.model.fields entry, ir.model.data entry...).
        
            It's intended for being run in pre-migration scripts for pre-populating
        Severity: Minor
        Found in openupgradelib/openupgrade.py - About 6 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 Stemmer has 151 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var Stemmer = function() {
        
          var step2list = {
            ational: 'ate',
            tional: 'tion',
        Severity: Major
        Found in docs/_static/language_data.js - About 6 hrs to fix

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

                  elif operation == "avg":
                      vals[column] = sum(field_vals) / len(field_vals)
                  elif operation == "max":
                      vals[column] = max(field_vals)
                  elif operation == "min":
          Severity: Major
          Found in openupgradelib/openupgrade_merge_records.py and 1 other location - About 6 hrs to fix
          openupgradelib/openupgrade_merge_records.py on lines 458..465

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

          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

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

                  if operation == "max":
                      vals[column] = max(field_vals)
                  elif operation == "min":
                      vals[column] = min(field_vals)
                  elif operation == "first_not_null":
          Severity: Major
          Found in openupgradelib/openupgrade_merge_records.py and 1 other location - About 6 hrs to fix
          openupgradelib/openupgrade_merge_records.py on lines 436..445

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

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

          def rename_models(cr, model_spec):
              """
              Rename models. Typically called in the pre script.
              :param model_spec: a list of tuples (old model name, new model name).
          
          
          Severity: Minor
          Found in openupgradelib/openupgrade.py - About 5 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 searchtools.js has 395 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /*
           * searchtools.js
           * ~~~~~~~~~~~~~~~~
           *
           * Sphinx JavaScript utilities for the full-text search.
          Severity: Minor
          Found in docs/_static/searchtools.js - About 5 hrs to fix

            File openupgrade_120.py has 386 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8 -*- # pylint: disable=C8202
            # Copyright 2019 Tecnativa - Jairo Llopis
            # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
            
            """Tools specific for migrating Odoo 11.0 to 12.0.
            Severity: Minor
            Found in openupgradelib/openupgrade_120.py - About 5 hrs to fix

              Function initOnKeyListeners has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

                initOnKeyListeners: () => {
                  // only install a listener if it is really needed
                  if (
                    !DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS &&
                    !DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS
              Severity: Minor
              Found in docs/_static/doctools.js - About 5 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 logging has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
              Open

              def logging(args_details=False, step=False):
                  """
                  This is a decorator for any sub functions called in an OpenUpgrade script.
                  (pre or post migration script)
              
              
              Severity: Minor
              Found in openupgradelib/openupgrade.py - About 4 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 _change_foreign_key_refs has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
              Open

              def _change_foreign_key_refs(
                  env,
                  model_name,
                  record_ids,
                  target_record_id,
              Severity: Minor
              Found in openupgradelib/openupgrade_merge_records.py - About 4 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

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

              def replace_html_replacement_attr_shortcut(attr_rp="", **kwargs):
                  """Shortcut to replace an attribute spec.
              
                  :param dict attr_rp:
                      EX: {'data-toggle': 'data-bs-toggle'}
              Severity: Major
              Found in openupgradelib/openupgrade_tools.py and 1 other location - About 4 hrs to fix
              openupgradelib/openupgrade_tools.py on lines 305..328

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

              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