OCA/openupgradelib

View on GitHub

Showing 120 of 163 total issues

Function merge_models has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def merge_models(cr, old_model, new_model, ref_field):
    """
    Update model references for models that have merged to an existing model.
    :param old_model: old model
    :param new_model: destination model
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 map_values has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def map_values(
    cr, source_column, target_column, mapping, model=None, table=None, write="sql"
):
    """
    Map old values to new values within the same model or table. Old values
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 _highlight has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const _highlight = (node, addItems, text, className) => {
  if (node.nodeType === Node.TEXT_NODE) {
    const val = node.nodeValue;
    const parent = node.parentNode;
    const pos = val.toLowerCase().indexOf(text);
Severity: Minor
Found in docs/_static/sphinx_highlight.js - About 1 hr to fix

    Function migrate_translations_to_jsonb has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def migrate_translations_to_jsonb(env, fields_spec):
        """
        In Odoo 16, translated fields no longer use the model ir.translation.
        Instead they store all their values into jsonb columns
        in the model's table.
    Severity: Minor
    Found in openupgradelib/openupgrade_160.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 delete_records_safely_by_xml_id has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def delete_records_safely_by_xml_id(env, xml_ids, delete_childs=False):
        """This removes in the safest possible way the records whose XML-IDs are
        passed as argument.
    
        If not possible to be removed, and the record is an updatable one
    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 _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
                          Severity
                          Category
                          Status
                          Source
                          Language