enclose-io/compiler

View on GitHub
lts/tools/gyp/pylib/gyp/generator/ninja.py

Summary

Maintainability
F
6 mos
Test Coverage

File ninja.py has 1951 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright (c) 2013 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 print_function
Severity: Major
Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 5 days to fix

    Function GenerateOutputForConfig has a Cognitive Complexity of 111 (exceeds 5 allowed). Consider refactoring.
    Open

    def GenerateOutputForConfig(target_list, target_dicts, data, params,
                                config_name):
      options = params['options']
      flavor = gyp.common.GetFlavor(params)
      generator_flags = params.get('generator_flags', {})
    Severity: Minor
    Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 2 days 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 WriteLinkForArch has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
    Open

      def WriteLinkForArch(self, ninja_file, spec, config_name, config,
                           link_deps, compile_deps, arch=None):
        """Write out a link step. Fills out target.binary. """
        command = {
          'executable':      'link',
    Severity: Minor
    Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 1 day 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 WriteRules has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

      def WriteRules(self, rules, extra_sources, prebuild,
                     mac_bundle_resources, extra_mac_bundle_resources):
        env = self.GetToolchainEnv()
        all_outputs = []
        for rule in rules:
    Severity: Minor
    Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 1 day 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 WriteSpec has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Open

      def WriteSpec(self, spec, config_name, generator_flags):
        """The main entry point for NinjaWriter: write the build rules for a spec.
    
        Returns a Target object, which represents the output paths for this spec.
        Returns None if there are no outputs (e.g. a settings-only 'none' type
    Severity: Minor
    Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 7 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 WriteSourcesForArch has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

      def WriteSourcesForArch(self, ninja_file, config_name, config, sources,
                              predepends, precompiled_header, spec, arch=None):
        """Write build rules to compile all of |sources|."""
    
        extra_defines = []
    Severity: Minor
    Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 5 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

    NinjaWriter has 38 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class NinjaWriter(object):
      def __init__(self, hash_for_rules, target_outputs, base_dir, build_dir,
                   output_file, toplevel_build, output_file_name, flavor,
                   toplevel_dir=None):
        """
    Severity: Minor
    Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 5 hrs to fix

      Function WriteTarget has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        def WriteTarget(self, spec, config_name, config, link_deps, compile_deps):
          extra_link_deps = any(self.target_outputs.get(dep).Linkable()
                                for dep in spec.get('dependencies', [])
                                if dep in self.target_outputs)
          if spec['type'] == 'none' or (not link_deps and not extra_link_deps):
      Severity: Minor
      Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 4 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 ComputeOutput has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def ComputeOutput(self, spec, arch=None):
          """Compute the path for the final output of the spec."""
          type = spec['type']
      
          if self.flavor == 'win':
      Severity: Minor
      Found in lts/tools/gyp/pylib/gyp/generator/ninja.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 GetDefaultConcurrentLinks has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      def GetDefaultConcurrentLinks():
        """Returns a best-guess for a number of concurrent links."""
        pool_size = int(os.environ.get('GYP_LINK_CONCURRENCY', 0))
        if pool_size:
          return pool_size
      Severity: Minor
      Found in lts/tools/gyp/pylib/gyp/generator/ninja.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 GenerateOutput has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      def GenerateOutput(target_list, target_dicts, data, params):
        # Update target_dicts for iOS device builds.
        target_dicts = gyp.xcode_emulation.CloneConfigurationForDeviceAndEmulator(
            target_dicts)
      
      
      Severity: Minor
      Found in lts/tools/gyp/pylib/gyp/generator/ninja.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 GenerateOutputForConfig has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def GenerateOutputForConfig(target_list, target_dicts, data, params,
                                  config_name):
        options = params['options']
        flavor = gyp.common.GetFlavor(params)
        generator_flags = params.get('generator_flags', {})
      Severity: Minor
      Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

              if ext in ('cc', 'cpp', 'cxx'):
                command = 'cxx'
                self.target.uses_cpp = True
              elif ext == 'c' or (ext == 'S' and self.flavor != 'win'):
                command = 'cc'
        Severity: Critical
        Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 1 hr to fix

          Function WriteCopies has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def WriteCopies(self, copies, prebuild, mac_bundle_depends):
              outputs = []
              if self.xcode_settings:
                extra_env = self.xcode_settings.GetPerTargetSettings()
                env = self.GetToolchainEnv(additional_settings=extra_env)
          Severity: Minor
          Found in lts/tools/gyp/pylib/gyp/generator/ninja.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 WriteActions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def WriteActions(self, actions, extra_sources, prebuild,
                             extra_mac_bundle_resources):
              # Actions cd into the base directory.
              env = self.GetToolchainEnv()
              all_outputs = []
          Severity: Minor
          Found in lts/tools/gyp/pylib/gyp/generator/ninja.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 __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def __init__(self, hash_for_rules, target_outputs, base_dir, build_dir,
          Severity: Major
          Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 1 hr to fix

            Function ComputeOutputFileName has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def ComputeOutputFileName(self, spec, type=None):
                """Compute the filename of the final output for the current target."""
                if not type:
                  type = spec['type']
            
            
            Severity: Minor
            Found in lts/tools/gyp/pylib/gyp/generator/ninja.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 WriteNewNinjaRule has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def WriteNewNinjaRule(self, name, args, description, is_cygwin, env, pool,
                                    depfile=None):
                """Write out a new ninja "rule" statement for a given command.
            
                Returns the name of the new rule, and a copy of |args| with variables
            Severity: Minor
            Found in lts/tools/gyp/pylib/gyp/generator/ninja.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 WriteSpec has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def WriteSpec(self, spec, config_name, generator_flags):
                """The main entry point for NinjaWriter: write the build rules for a spec.
            
                Returns a Target object, which represents the output paths for this spec.
                Returns None if there are no outputs (e.g. a settings-only 'none' type
            Severity: Minor
            Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 1 hr to fix

              Function WriteSourcesForArch has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def WriteSourcesForArch(self, ninja_file, config_name, config, sources,
              Severity: Major
              Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 1 hr to fix

                Function WriteLink has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def WriteLink(self, spec, config_name, config, link_deps, compile_deps):
                    """Write out a link step. Fills out target.binary. """
                    if self.flavor != 'mac' or len(self.archs) == 1:
                      return self.WriteLinkForArch(
                          self.ninja, spec, config_name, config, link_deps, compile_deps)
                Severity: Minor
                Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 55 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 WriteActionsRulesCopies has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def WriteActionsRulesCopies(self, spec, extra_sources, prebuild,
                                              mac_bundle_depends):
                    """Write out the Actions, Rules, and Copies steps.  Return a path
                    representing the outputs of these steps."""
                    outputs = []
                Severity: Minor
                Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 55 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 WriteSources has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def WriteSources(self, ninja_file, config_name, config, sources, predepends,
                Severity: Major
                Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 50 mins to fix

                  Function WriteLinkForArch has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def WriteLinkForArch(self, ninja_file, spec, config_name, config,
                  Severity: Major
                  Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 50 mins to fix

                    Function WriteNewNinjaRule has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def WriteNewNinjaRule(self, name, args, description, is_cygwin, env, pool,
                    Severity: Major
                    Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 50 mins to fix

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

                        def ExpandRuleVariables(self, path, root, dirname, source, ext, name):
                      Severity: Minor
                      Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                    if new_dep not in extra_link_deps:
                                      extra_link_deps.add(new_dep)
                                      link_deps.append(new_dep)
                        
                        
                        Severity: Major
                        Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 45 mins to fix

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

                            def GypPathToNinja(self, path, env=None):
                              """Translate a gyp path to a ninja path, optionally expanding environment
                              variable references in |path| with |env|.
                          
                              See the above discourse on path conversions."""
                          Severity: Minor
                          Found in lts/tools/gyp/pylib/gyp/generator/ninja.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 not match:
                                      continue
                                    # Allow 8Gb per link on Linux because Gold is quite memory hungry
                                    return max(1, int(match.group(1)) / (8 * (2 ** 20)))
                          Severity: Major
                          Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                        if target.compile_deps:
                                          order_deps.add(target.compile_deps)
                                      elif self.flavor == 'win' and target.import_lib:
                            Severity: Major
                            Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 45 mins to fix

                              Function WriteLink has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                def WriteLink(self, spec, config_name, config, link_deps, compile_deps):
                              Severity: Minor
                              Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 35 mins to fix

                                Function GenerateOutputForConfig has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                def GenerateOutputForConfig(target_list, target_dicts, data, params,
                                Severity: Minor
                                Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 35 mins to fix

                                  Function WriteRules has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                    def WriteRules(self, rules, extra_sources, prebuild,
                                  Severity: Minor
                                  Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 35 mins to fix

                                    Function WriteTarget has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                      def WriteTarget(self, spec, config_name, config, link_deps, compile_deps):
                                    Severity: Minor
                                    Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 35 mins to fix

                                      Function AppendPostbuildVariable has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                        def AppendPostbuildVariable(self, variables, spec, output, binary,
                                      Severity: Minor
                                      Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 35 mins to fix

                                        Function WriteMacBundle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          def WriteMacBundle(self, spec, mac_bundle_depends, is_empty):
                                            assert self.is_mac_bundle
                                            package_framework = spec['type'] in ('shared_library', 'loadable_module')
                                            output = self.ComputeMacBundleOutput()
                                            if is_empty:
                                        Severity: Minor
                                        Found in lts/tools/gyp/pylib/gyp/generator/ninja.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 self.GypPathToUniqueOutput(filename, qualified=False)
                                        Severity: Major
                                        Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                return max(1, avail_bytes / (4 * (2 ** 30)))  # total / 4GB
                                          Severity: Major
                                          Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                  return 1
                                            Severity: Major
                                            Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                    return os.path.join(libdir, filename)
                                              Severity: Major
                                              Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                    return 1
                                                Severity: Major
                                                Found in lts/tools/gyp/pylib/gyp/generator/ninja.py - About 30 mins to fix

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

                                                    def WriteMacXCassets(self, xcassets, bundle_depends):
                                                      """Writes ninja edges for 'mac_bundle_resources' .xcassets files.
                                                  
                                                      This add an invocation of 'actool' via the 'mac_tool.py' helper script.
                                                      It assumes that the assets catalogs define at least one imageset and
                                                  Severity: Minor
                                                  Found in lts/tools/gyp/pylib/gyp/generator/ninja.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

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

                                                    def GetPostbuildCommand(self, spec, output, output_binary, is_command_start):
                                                      """Returns a shell command that runs all the postbuilds, and removes
                                                      |output| if any of them fails. If |is_command_start| is False, then the
                                                      returned string will start with ' && '."""
                                                      if not self.xcode_settings or spec['type'] == 'none' or not output:
                                                  Severity: Minor
                                                  Found in lts/tools/gyp/pylib/gyp/generator/ninja.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

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

                                                  Severity: Major
                                                  Found in lts/tools/gyp/pylib/gyp/generator/ninja.py and 1 other location - About 6 mos to fix
                                                  current/tools/gyp/pylib/gyp/generator/ninja.py on lines 0..2501

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

                                                  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

                                                  There are no issues that match your filters.

                                                  Category
                                                  Status