tools/gyp/pylib/gyp/common.py

Summary

Maintainability
C
1 day
Test Coverage

File common.py has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from __future__ import with_statement
Severity: Minor
Found in tools/gyp/pylib/gyp/common.py - About 3 hrs to fix

    Function WriteOnDiff has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def WriteOnDiff(filename):
      """Write to a file only if the new contents differ.
    
      Arguments:
        filename: name of the file to potentially write to.
    Severity: Minor
    Found in tools/gyp/pylib/gyp/common.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 ResolveTarget has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def ResolveTarget(build_file, target, toolset):
      # This function resolves a target into a canonical form:
      # - a fully defined build file, either absolute or relative to the current
      # directory
      # - a target name
    Severity: Minor
    Found in tools/gyp/pylib/gyp/common.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 TopologicallySorted has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def TopologicallySorted(graph, get_edges):
      """Topologically sort based on a user provided edge definition.
    
      Args:
        graph: A list of node names.
    Severity: Minor
    Found in tools/gyp/pylib/gyp/common.py - About 35 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 too many return statements within this function.
    Open

        return 'aix'
    Severity: Major
    Found in tools/gyp/pylib/gyp/common.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return 'openbsd'
      Severity: Major
      Found in tools/gyp/pylib/gyp/common.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          return 'linux'
        Severity: Major
        Found in tools/gyp/pylib/gyp/common.py - About 30 mins to fix

          Function GetFlavor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def GetFlavor(params):
            """Returns |params.flavor| if it's set, the system's default flavor else."""
            flavors = {
              'cygwin': 'win',
              'win32': 'win',
          Severity: Minor
          Found in tools/gyp/pylib/gyp/common.py - About 25 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

          There are no issues that match your filters.

          Category
          Status