conan-io/conan

View on GitHub
conans/model/graph_lock.py

Summary

Maintainability
F
3 days
Test Coverage

Function lock_node has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
Open

    def lock_node(self, node, requires, build_requires=False):
        """ apply options and constraints on requirements of a node, given the information from
        the lockfile. Requires remove their version ranges.
        """
        # Important to remove the overrides, they do not need to be locked or evaluated
Severity: Minor
Found in conans/model/graph_lock.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 build_order has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
Open

    def build_order(self):
        """ This build order uses empty PREVs to decide which packages need to be built

        :return: An ordered list of lists, each inner element is a tuple with the node ID and the
                 reference (as string), possibly including revision, of the node
Severity: Minor
Found in conans/model/graph_lock.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 __init__ has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

    def __init__(self, deps_graph, revisions_enabled):
        self._nodes = {}  # {id: GraphLockNode}
        self._revisions_enabled = revisions_enabled
        self._relaxed = False  # If True, the lock can be expanded with new Nodes

Severity: Minor
Found in conans/model/graph_lock.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

Avoid deeply nested control flow statements.
Open

                        if "@" not in ref:
                            ref = ref.replace("#", "@#")
                    if (ref, locked_node.package_id, locked_node.context) not in total_prefs:
Severity: Major
Found in conans/model/graph_lock.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if node.prev is None:
                                node.prev = prev
    
    
    Severity: Major
    Found in conans/model/graph_lock.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if "@" not in ref:
                                  ref += "@"
                          else:
      Severity: Major
      Found in conans/model/graph_lock.py - About 45 mins to fix

        Function __init__ has 11 arguments (exceeds 10 allowed). Consider refactoring.
        Open

            def __init__(self, ref, package_id, prev, python_requires, options, requires, build_requires,
        Severity: Major
        Found in conans/model/graph_lock.py - About 35 mins to fix

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

                      if ref.revision:  # Search by exact ref (with RREV)
                          node_id = self._find_first(lambda n: n.ref and repr(n.ref) == search_ref)
                      else:  # search by ref without RREV
                          node_id = self._find_first(lambda n: n.ref and str(n.ref) == search_ref)
          Severity: Major
          Found in conans/model/graph_lock.py and 1 other location - About 4 hrs to fix
          conans/model/graph_lock.py on lines 687..690

          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

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

                  if ref.revision:  # Match should be exact (with RREV)
                      node_id = self._find_first(lambda n: n.ref and repr(n.ref) == search_ref)
                  else:
                      node_id = self._find_first(lambda n: n.ref and str(n.ref) == search_ref)
          Severity: Major
          Found in conans/model/graph_lock.py and 1 other location - About 4 hrs to fix
          conans/model/graph_lock.py on lines 611..614

          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

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

                      for require in locked_requires:
                          req_node = self._nodes[require]
                          if req_node.ref.name not in declared_requires:
                              raise ConanException("'%s' locked requirement '%s' not found"
                                                   % (str(node.ref), str(req_node.ref)))
          Severity: Major
          Found in conans/model/graph_lock.py and 1 other location - About 2 hrs to fix
          conans/model/graph_lock.py on lines 579..583

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

          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

                  for require in locked_requires:
                      req_node = self._nodes[require]
                      if req_node.ref.name not in declared_requires:
                          raise ConanException("'%s' locked requirement '%s' not found"
                                               % (str(node.ref), str(req_node.ref)))
          Severity: Major
          Found in conans/model/graph_lock.py and 1 other location - About 2 hrs to fix
          conans/model/graph_lock.py on lines 561..565

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

          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 not any(n in opened for n in requires):
                              current_level.append(o)
          Severity: Minor
          Found in conans/model/graph_lock.py and 1 other location - About 45 mins to fix
          conans/client/graph/graph.py on lines 366..367

          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

          Line too long (126 > 100 characters)
          Open

                  refs = {(self._nodes[id_].ref.name, self._nodes[id_].context): (self._nodes[id_].ref, id_) for id_ in locked_requires}
          Severity: Minor
          Found in conans/model/graph_lock.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          There are no issues that match your filters.

          Category
          Status