OCA/openupgradelib

View on GitHub

Showing 163 of 163 total issues

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

        cr.execute(
            r"""
            UPDATE ir_filters
            SET context = regexp_replace(
                context, %(old_pattern)s, %(new_pattern)s, 'g'
Severity: Major
Found in openupgradelib/openupgrade.py and 3 other locations - About 50 mins to fix
openupgradelib/openupgrade.py on lines 739..752
openupgradelib/openupgrade.py on lines 759..779
openupgradelib/openupgrade.py on lines 802..818

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

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 4 locations. Consider refactoring.
Open

        cr.execute(
            """
            UPDATE ir_filters
            SET domain = regexp_replace(
                domain, %(old_pattern)s, %(new_pattern)s, 'g'
Severity: Major
Found in openupgradelib/openupgrade.py and 3 other locations - About 50 mins to fix
openupgradelib/openupgrade.py on lines 759..779
openupgradelib/openupgrade.py on lines 783..799
openupgradelib/openupgrade.py on lines 802..818

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

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

Avoid deeply nested control flow statements.
Open

                    if api and isinstance(pool, api.Environment):
                        value = obj.default_get([field]).get(field)
                    else:
                        value = obj.default_get(cr, SUPERUSER_ID, [field]).get(field)
                    if value:
Severity: Major
Found in openupgradelib/openupgrade.py - About 45 mins to fix

    Function set_partner_id_from_partner_address_id has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def set_partner_id_from_partner_address_id(
    Severity: Minor
    Found in openupgradelib/openupgrade_70.py - About 45 mins to fix

      Function add_xmlid has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def add_xmlid(cr, module, xmlid, model, res_id, noupdate=False):
      Severity: Minor
      Found in openupgradelib/openupgrade.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if value:
                                write_value(ids, field, value)
                        else:
        Severity: Major
        Found in openupgradelib/openupgrade.py - About 45 mins to fix

          Function _change_many2many_refs_orm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def _change_many2many_refs_orm(
              env, model_name, record_ids, target_record_id, exclude_columns
          ):
              fields = env["ir.model.fields"].search(
                  [
          Severity: Minor
          Found in openupgradelib/openupgrade_merge_records.py - About 45 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

          Avoid deeply nested control flow statements.
          Open

                              if data and data != "None":
                                  attachment_model.create(
                                      {
                                          "name": field,
                                          "res_model": model_name,
          Severity: Major
          Found in openupgradelib/openupgrade_90.py - About 45 mins to fix

            Function invalidate_cache has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def invalidate_cache(env, flush=True):
                """Version-independent cache invalidation.
            
                :param flush: whether pending updates should be flushed before invalidation.
                    It is ``True`` by default, which ensures cache consistency.
            Severity: Minor
            Found in openupgradelib/openupgrade_tools.py - About 45 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 _change_many2one_refs_orm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def _change_many2one_refs_orm(
                env, model_name, record_ids, target_record_id, exclude_columns
            ):
                fields = env["ir.model.fields"].search(
                    [
            Severity: Minor
            Found in openupgradelib/openupgrade_merge_records.py - About 45 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

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

                if version_info[0] > 6 or version_info[0:2] == (6, 1):
            Severity: Minor
            Found in openupgradelib/openupgrade.py and 1 other location - About 45 mins to fix
            openupgradelib/openupgrade.py on lines 81..81

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

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

            def _change_translations_orm(
                env, model_name, record_ids, target_record_id, exclude_columns
            ):
                if version_info[0] > 15:
                    return
            Severity: Minor
            Found in openupgradelib/openupgrade_merge_records.py - About 45 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

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

            if version_info[0] > 6 or version_info[0:2] == (6, 1):
            Severity: Minor
            Found in openupgradelib/openupgrade.py and 1 other location - About 45 mins to fix
            openupgradelib/openupgrade.py on lines 3280..3280

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

            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

                    if field_ids:
                        logged_query(
                            cr,
                            """
                            UPDATE ir_property
            Severity: Minor
            Found in openupgradelib/openupgrade.py and 1 other location - About 45 mins to fix
            openupgradelib/openupgrade.py on lines 974..983

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

            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 _adjust_merged_values_sql has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def _adjust_merged_values_sql(
            Severity: Minor
            Found in openupgradelib/openupgrade_merge_records.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if field_type == "serialized":
                                      import json
              
                                      vals[column] = json.dumps(field_val)
                                  elif field_type == "jsonb":
              Severity: Major
              Found in openupgradelib/openupgrade_merge_records.py - About 45 mins to fix

                Function initEscapeListener has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  initEscapeListener: () => {
                    // only install a listener if it is really needed
                    if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) return;
                
                    document.addEventListener("keydown", (event) => {
                Severity: Minor
                Found in docs/_static/sphinx_highlight.js - About 45 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 convert_field_to_html has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def convert_field_to_html(
                Severity: Minor
                Found in openupgradelib/openupgrade.py - About 45 mins to fix

                  Function safe_unlink has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def safe_unlink(records, do_raise=False):
                      """Allow for errors to occur during unlinking of records.
                  
                      Prevent broken database transactions, and by default, catch exceptions.
                  
                  
                  Severity: Minor
                  Found in openupgradelib/openupgrade.py - About 45 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

                  Avoid deeply nested control flow statements.
                  Open

                                      if field in obj._defaults:
                                          if not callable(obj._defaults[field]):
                                              write_value(ids, field, obj._defaults[field])
                                          else:
                                              cr.execute(
                  Severity: Major
                  Found in openupgradelib/openupgrade.py - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language