OCA/openupgradelib

View on GitHub

Showing 120 of 163 total issues

Function move_field_m2o has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

def move_field_m2o(
    cr,
    pool,
    registry_old_model,
    field_old_model,
Severity: Minor
Found in openupgradelib/openupgrade.py - About 3 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 _get_existing_records has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

def _get_existing_records(cr, fp, module_name):
    """yield file like objects per 'leaf' node in the xml file that exists.
    This is for not trying to create a record with partial data in case the
    record was removed in the database."""

Severity: Minor
Found in openupgradelib/openupgrade.py - About 3 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 migrate has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

def migrate(no_version=False, use_env=None, uid=None, context=None):
    """
    This is the decorator for the migrate() function
    in migration scripts.

Severity: Minor
Found in openupgradelib/openupgrade.py - About 3 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 _adjust_merged_values_orm has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

def _adjust_merged_values_orm(
    env, model_name, record_ids, target_record_id, field_spec
):
    """This method deals with the values on the records to be merged +
    the target record, performing operations that make sense on the meaning
Severity: Minor
Found in openupgradelib/openupgrade_merge_records.py - About 3 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

Consider simplifying this complex logical expression.
Open

    if field_type in ("char", "text", "html"):
        if not operation:
            operation = "other" if field_type == "char" else "merge"
        if operation == "first_not_null":
            field_vals = [x for x in field_vals if x]
Severity: Critical
Found in openupgradelib/openupgrade_merge_records.py - About 3 hrs to fix

    Function load_data has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def load_data(env_or_cr, module_name, filename, idref=None, mode="init"):
        """
        Load an xml, csv or yml data file from your post script. The usual case for
        this is the
        occurrence of newly added essential or useful data in the module that is
    Severity: Minor
    Found in openupgradelib/openupgrade.py - About 3 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 convert_binary_field_to_attachment has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def convert_binary_field_to_attachment(env, field_spec):
        """This method converts the 8.0 binary fields to attachments like Odoo 9.0
        makes with the new attachment=True attribute. It has to be called on
        post-migration script, as there's a call to get the res_name of the
        target model, which is not yet loaded on pre-migration.
    Severity: Minor
    Found in openupgradelib/openupgrade_90.py - About 3 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_tools.py has 300 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*- # pylint: disable=C8202
    ##############################################################################
    #
    #    OpenERP, Open Source Management Solution
    #    This module copyright (C) 2012-2014 Therp BV (<http://therp.nl>)
    Severity: Minor
    Found in openupgradelib/openupgrade_tools.py - About 3 hrs to fix

      Function delete_record_translations has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      def delete_record_translations(cr, module, xml_ids, field_list=None):
          """Cleanup translations of specific records in a module.
      
          :param module: module name
          :param xml_ids: a tuple or list of xml record IDs
      Severity: Minor
      Found in openupgradelib/openupgrade.py - About 3 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 performTermsSearch has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        performTermsSearch: (searchTerms, excludedTerms) => {
          // prepare search
          const terms = Search._index.terms;
          const titleTerms = Search._index.titleterms;
          const filenames = Search._index.filenames;
      Severity: Major
      Found in docs/_static/searchtools.js - About 3 hrs to fix

        Function _performSearch has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _performSearch: (query, searchTerms, excludedTerms, highlightTerms, objectTerms) => {
            const filenames = Search._index.filenames;
            const docNames = Search._index.docnames;
            const titles = Search._index.titles;
            const allTitles = Search._index.alltitles;
        Severity: Major
        Found in docs/_static/searchtools.js - About 2 hrs to fix

          Function rename_xmlids has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          def rename_xmlids(cr, xmlids_spec, allow_merge=False):
              """
              Rename XML IDs. Typically called in the pre script.
              One usage example is when an ID changes module. In OpenERP 6 for example,
              a number of res_groups IDs moved to module base from other modules (
          Severity: Minor
          Found in openupgradelib/openupgrade.py - About 2 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 performObjectSearch has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            performObjectSearch: (object, objectTerms) => {
              const filenames = Search._index.filenames;
              const docNames = Search._index.docnames;
              const objects = Search._index.objects;
              const objNames = Search._index.objnames;
          Severity: Minor
          Found in docs/_static/searchtools.js - About 2 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 _adjust_merged_values_sql has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          def _adjust_merged_values_sql(
              env, model_name, record_ids, target_record_id, model_table, field_spec
          ):
              """This method deals with the values on the records to be merged +
              the target record, performing operations that make sense on the meaning
          Severity: Minor
          Found in openupgradelib/openupgrade_merge_records.py - About 2 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 convert_field_to_html has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          def convert_field_to_html(
              cr, table, field_name, html_field_name, verbose=True, translate=False
          ):
              """
              Convert field value to HTML value.
          Severity: Minor
          Found in openupgradelib/openupgrade.py - About 2 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 highlightText has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

          jQuery.fn.highlightText = function(text, className) {
              function highlight(node, addItems) {
                  if (node.nodeType === 3) {
                      var val = node.nodeValue;
                      var pos = val.toLowerCase().indexOf(text);
          Severity: Minor
          Found in docs/_static/_sphinx_javascript_frameworks_compat.js - About 2 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 m2o_to_x2m has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          def m2o_to_x2m(cr, model, table, field, source_field):
              """
              Transform many2one relations into one2many or many2many.
              For openupgrade < 14.0, use rename_columns in your pre-migrate script
              to retain the column's old value, then call m2o_to_x2m in your
          Severity: Minor
          Found in openupgradelib/openupgrade.py - About 2 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 performObjectSearch has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            performObjectSearch: (object, objectTerms) => {
              const filenames = Search._index.filenames;
              const docNames = Search._index.docnames;
              const objects = Search._index.objects;
              const objNames = Search._index.objnames;
          Severity: Major
          Found in docs/_static/searchtools.js - About 2 hrs to fix

            Function highlightText has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

              Function _highlight has a Cognitive Complexity of 15 (exceeds 5 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

              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