OCA/openupgradelib

View on GitHub

Showing 163 of 163 total issues

Function _displayItem has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const _displayItem = (item, searchTerms, highlightTerms) => {
  const docBuilder = DOCUMENTATION_OPTIONS.BUILDER;
  const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX;
  const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX;
  const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY;
Severity: Minor
Found in docs/_static/searchtools.js - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

    if (!jQuery.browser) {
        jQuery.uaMatch = function(ua) {
            ua = ua.toLowerCase();
    
            var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
    Severity: Critical
    Found in docs/_static/_sphinx_javascript_frameworks_compat.js - About 1 hr to fix

      Function rename_tables has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def rename_tables(cr, table_spec):
          """
          Rename tables. Typically called in the pre script.
          This function also renames the id sequence if it exists and if it is
          not modified in the same run.
      Severity: Minor
      Found in openupgradelib/openupgrade.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 update_module_names has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def update_module_names(cr, namespec, merge_modules=False):
          """Deal with changed module names, making all the needed changes on the
          related tables, like XML-IDs, translations, and so on.
      
          :param namespec: list of tuples of (old name, new name)
      Severity: Minor
      Found in openupgradelib/openupgrade.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 replace_account_types has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def replace_account_types(env, type_spec, unlink=True):
          """ Replace old account types with their replacements. The old account
          type is allowed not to exist anymore, except when running unit tests.
          :param type_spec: list of tuples (xmlid of old account.account.type, \
      xmlid of new account.account.type)
      Severity: Minor
      Found in openupgradelib/openupgrade_90.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 highlight has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function highlight(node, addItems) {
              if (node.nodeType === 3) {
                  var val = node.nodeValue;
                  var pos = val.toLowerCase().indexOf(text);
                  if (pos >= 0 &&
      Severity: Minor
      Found in docs/_static/_sphinx_javascript_frameworks_compat.js - About 1 hr to fix

        Function objectSearchCallback has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            const objectSearchCallback = (prefix, match) => {
              const name = match[4]
              const fullname = (prefix ? prefix + "." : "") + name;
              const fullnameLower = fullname.toLowerCase();
              if (fullnameLower.indexOf(object) < 0) return;
        Severity: Minor
        Found in docs/_static/searchtools.js - About 1 hr to fix

          Function initOnKeyListeners has 35 lines of code (exceeds 25 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 1 hr to fix

            Function convert_xml_node has 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def convert_xml_node(
            Severity: Major
            Found in openupgradelib/openupgrade_tools.py - About 1 hr to fix

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

              def _change_reference_refs_sql(
                  env, model_name, record_ids, target_record_id, exclude_columns
              ):
                  cr = env.cr
                  cr.execute(
              Severity: Minor
              Found in openupgradelib/openupgrade_merge_records.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 apply_operations_by_field_type has 10 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def apply_operations_by_field_type(
              Severity: Major
              Found in openupgradelib/openupgrade_merge_records.py - About 1 hr to fix

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

                def move_field_m2o(
                Severity: Major
                Found in openupgradelib/openupgrade.py - About 1 hr to fix

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

                  def merge_records(
                  Severity: Major
                  Found in openupgradelib/openupgrade_merge_records.py - About 1 hr to fix

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

                    def copy_fields_multilang(
                    Severity: Major
                    Found in openupgradelib/openupgrade.py - About 1 hr to fix

                      Function highlightSearchWords has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        highlightSearchWords: () => {
                          if (!SPHINX_HIGHLIGHT_ENABLED) return;  // bail if no highlight
                      
                          // get and clear terms from localstorage
                          const url = new URL(window.location);
                      Severity: Minor
                      Found in docs/_static/sphinx_highlight.js - About 1 hr to fix

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

                        def _change_reference_refs_orm(
                            env, model_name, record_ids, target_record_id, exclude_columns
                        ):
                            fields = env["ir.model.fields"].search([("ttype", "=", "reference")])
                            if version_info[0] >= 12:
                        Severity: Minor
                        Found in openupgradelib/openupgrade_merge_records.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

                                fallback_activity = ir_model_data_model.get_object(
                                    cr,
                                    SUPERUSER_ID,
                                    fallback_external_id.split(".")[0],
                                    fallback_external_id.split(".")[1],
                        Severity: Major
                        Found in openupgradelib/openupgrade.py and 1 other location - About 1 hr to fix
                        openupgradelib/openupgrade.py on lines 1413..1417

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

                        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

                                target_activity = ir_model_data_model.get_object(
                                    cr,
                                    SUPERUSER_ID,
                                    target_external_id.split(".")[0],
                                    target_external_id.split(".")[1],
                        Severity: Major
                        Found in openupgradelib/openupgrade.py and 1 other location - About 1 hr to fix
                        openupgradelib/openupgrade.py on lines 1419..1423

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

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

                        def delete_model_workflow(cr, model, drop_indexes=False):
                            """
                            Forcefully remove active workflows for obsolete models,
                            to prevent foreign key issues when the orm deletes the model.
                        
                        
                        Severity: Minor
                        Found in openupgradelib/openupgrade.py - About 55 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

                        Function rename_columns has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def rename_columns(cr, column_spec):
                            """
                            Rename table columns. Typically called in the pre script.
                        
                            :param column_spec: a hash with table keys, with lists of tuples as \
                        Severity: Minor
                        Found in openupgradelib/openupgrade.py - About 55 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

                        Severity
                        Category
                        Status
                        Source
                        Language