tools/gyp/pylib/gyp/generator/xcode.py

Summary

Maintainability
F
1 wk
Test Coverage

Function GenerateOutput has a Cognitive Complexity of 299 (exceeds 5 allowed). Consider refactoring.
Open

def GenerateOutput(target_list, target_dicts, data, params):
  options = params['options']
  generator_flags = params.get('generator_flags', {})
  parallel_builds = generator_flags.get('xcode_parallel_builds', True)
  serialize_all_tests = \
Severity: Minor
Found in tools/gyp/pylib/gyp/generator/xcode.py - About 6 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

File xcode.py has 702 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.

import filecmp
Severity: Major
Found in tools/gyp/pylib/gyp/generator/xcode.py - About 1 day to fix

    Function Finalize1 has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

      def Finalize1(self, xcode_targets, serialize_all_tests):
        # Collect a list of all of the build configuration names used by the
        # various targets in the file.  It is very heavily advised to keep each
        # target in an entire project (even across multiple project files) using
        # the same set of configuration names.
    Severity: Minor
    Found in tools/gyp/pylib/gyp/generator/xcode.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 Finalize2 has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

      def Finalize2(self, xcode_targets, xcode_target_to_target_dict):
        # Finalize2 needs to happen in a separate step because the process of
        # updating references to other projects depends on the ordering of targets
        # within remote project files.  Finalize1 is responsible for sorting duty,
        # and once all project files are sorted, Finalize2 can come in and update
    Severity: Minor
    Found in tools/gyp/pylib/gyp/generator/xcode.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

    Avoid deeply nested control flow statements.
    Open

                if hasattr(dependency_xct, 'test_runner'):
                  all_run_tests.append(dependency_xct.test_runner)
    
              # Directly depend on all the runners as they depend on the target
              # that builds them.
    Severity: Major
    Found in tools/gyp/pylib/gyp/generator/xcode.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if concrete_output_index == len(concrete_outputs_by_rule_source) - 1:
                  eol = ''
                else:
                  eol = ' \\'
                makefile.write('    %s%s\n' % (concrete_output, eol))
      Severity: Major
      Found in tools/gyp/pylib/gyp/generator/xcode.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  if message:
                    # Mark it with note: so Xcode picks it up in build output.
                    makefile.write('\t@echo note: %s\n' % message)
                  makefile.write('\t%s\n' % action)
        Severity: Major
        Found in tools/gyp/pylib/gyp/generator/xcode.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      for run_test_target in all_run_tests:
                        run_all_target.AddDependency(run_test_target)
          
                      # Insert the test runner after the related target.
                      idx = self.project._properties['targets'].index(xcode_target)
          Severity: Major
          Found in tools/gyp/pylib/gyp/generator/xcode.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      for prerequisite_index in xrange(0, len(prerequisites)):
                        prerequisite = prerequisites[prerequisite_index]
                        if prerequisite_index == len(prerequisites) - 1:
                          eol = ''
                        else:
            Severity: Major
            Found in tools/gyp/pylib/gyp/generator/xcode.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if not item.startswith('$(BUILT_PRODUCTS_DIR)/'):
                          pbxp.AddOrGetFileInRootGroup(item)
              
              
              Severity: Major
              Found in tools/gyp/pylib/gyp/generator/xcode.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                          for output in concrete_outputs_for_this_rule_source:
                            AddSourceToTarget(output, type, pbxp, xct)
                
                        # If the file came from the mac_bundle_resources list or if the rule
                        # is marked to process outputs as bundle resource, do so.
                Severity: Major
                Found in tools/gyp/pylib/gyp/generator/xcode.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            for concrete_output_index in xrange(0, len(concrete_outputs)):
                              concrete_output = concrete_outputs[concrete_output_index]
                              if concrete_output_index == 0:
                                bol = ''
                              else:
                  Severity: Major
                  Found in tools/gyp/pylib/gyp/generator/xcode.py - About 45 mins to fix

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

                      def Write(self):
                        # Write the project file to a temporary location first.  Xcode watches for
                        # changes to the project file and presents a UI sheet offering to reload
                        # the project when it does change.  However, in some cases, especially when
                        # multiple projects are open or when Xcode is busy, things don't work so
                    Severity: Minor
                    Found in tools/gyp/pylib/gyp/generator/xcode.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

                              for output in concrete_outputs_for_this_rule_source:
                                AddResourceToTarget(output, pbxp, xct)
                    
                            # Do we have a message to print when this rule runs?
                            message = rule.get('message')
                    Severity: Major
                    Found in tools/gyp/pylib/gyp/generator/xcode.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                if len(concrete_output_dirs) > 0:
                                  makefile.write('\t@mkdir -p "%s"\n' %
                                                 '" "'.join(concrete_output_dirs))
                      
                                # The rule message and action have already had the necessary variable
                      Severity: Major
                      Found in tools/gyp/pylib/gyp/generator/xcode.py - About 45 mins to fix

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

                        def PerformBuild(data, configurations, params):
                          options = params['options']
                        
                          for build_file, build_file_dict in data.iteritems():
                            (build_file_root, build_file_ext) = os.path.splitext(build_file)
                        Severity: Minor
                        Found in tools/gyp/pylib/gyp/generator/xcode.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

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

                          for build_file, build_file_dict in data.iteritems():
                            (build_file_root, build_file_ext) = os.path.splitext(build_file)
                            if build_file_ext != '.gyp':
                              continue
                            xcodeproj_path = build_file_root + options.suffix + '.xcodeproj'
                        Severity: Major
                        Found in tools/gyp/pylib/gyp/generator/xcode.py and 1 other location - About 4 hrs to fix
                        tools/gyp/pylib/gyp/generator/msvs.py on lines 1893..1899

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

                        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 len(run_test_targets) > 1:
                              xccl = CreateXCConfigurationList(configurations)
                              run_all_tests_target = gyp.xcodeproj_file.PBXAggregateTarget(
                                  {
                                    'buildConfigurationList': xccl,
                        Severity: Major
                        Found in tools/gyp/pylib/gyp/generator/xcode.py and 1 other location - About 3 hrs to fix
                        tools/gyp/pylib/gyp/generator/xcode.py on lines 322..337

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

                        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 len(targets_for_all) > 1 and not has_custom_all:
                              xccl = CreateXCConfigurationList(configurations)
                              all_target = gyp.xcodeproj_file.PBXAggregateTarget(
                                  {
                                    'buildConfigurationList': xccl,
                        Severity: Major
                        Found in tools/gyp/pylib/gyp/generator/xcode.py and 1 other location - About 3 hrs to fix
                        tools/gyp/pylib/gyp/generator/xcode.py on lines 340..353

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

                        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 library_dir not in xcode_standard_library_dirs and (
                                    not xct.HasBuildSetting(_library_search_paths_var) or
                                    library_dir not in xct.GetBuildSetting(_library_search_paths_var)):
                                  xct.AppendBuildSetting(_library_search_paths_var, library_dir)
                        Severity: Major
                        Found in tools/gyp/pylib/gyp/generator/xcode.py and 1 other location - About 2 hrs to fix
                        tools/gyp/pylib/gyp/generator/xcode.py on lines 1193..1197

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

                        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

                              for library_dir in configuration.get('library_dirs', []):
                                if library_dir not in xcode_standard_library_dirs and (
                                    not xcbc.HasBuildSetting(_library_search_paths_var) or
                                    library_dir not in xcbc.GetBuildSetting(_library_search_paths_var)):
                                  xcbc.AppendBuildSetting(_library_search_paths_var, library_dir)
                        Severity: Major
                        Found in tools/gyp/pylib/gyp/generator/xcode.py and 1 other location - About 2 hrs to fix
                        tools/gyp/pylib/gyp/generator/xcode.py on lines 1181..1184

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

                        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 support_xct:
                                  support_xct.AppendProperty('buildPhases', ssbp)
                                else:
                                  # TODO(mark): this assumes too much knowledge of the internals of
                                  # xcodeproj_file; some of these smarts should move into xcodeproj_file
                        Severity: Major
                        Found in tools/gyp/pylib/gyp/generator/xcode.py and 1 other location - About 1 hr to fix
                        tools/gyp/pylib/gyp/generator/xcode.py on lines 763..770

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

                        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 support_xct:
                                support_xct.AppendProperty('buildPhases', ssbp)
                              else:
                                # TODO(mark): this assumes too much knowledge of the internals of
                                # xcodeproj_file; some of these smarts should move into xcodeproj_file
                        Severity: Major
                        Found in tools/gyp/pylib/gyp/generator/xcode.py and 1 other location - About 1 hr to fix
                        tools/gyp/pylib/gyp/generator/xcode.py on lines 1044..1051

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

                        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