CocoaPods/CocoaPods

View on GitHub
lib/cocoapods/installer/analyzer.rb

Summary

Maintainability
F
5 days
Test Coverage
A
99%

File analyzer.rb has 717 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'cocoapods/podfile'

module Pod
  class Installer
    # Analyzes the Podfile, the Lockfile, and the sandbox manifest to generate
Severity: Major
Found in lib/cocoapods/installer/analyzer.rb - About 1 day to fix

    Class Analyzer has 40 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Analyzer
          include Config::Mixin
    
          autoload :AnalysisResult,            'cocoapods/installer/analyzer/analysis_result'
          autoload :LockingDependencyAnalyzer, 'cocoapods/installer/analyzer/locking_dependency_analyzer'
    Severity: Minor
    Found in lib/cocoapods/installer/analyzer.rb - About 5 hrs to fix

      Method analyze_host_targets_in_podfile has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

            def analyze_host_targets_in_podfile(aggregate_targets, embedded_aggregate_targets)
              target_definitions_by_uuid = {}
              cli_host_with_dynamic_linkage = []
              cli_product_type = 'com.apple.product-type.tool'
              # Collect aggregate target definitions by uuid to later lookup host target
      Severity: Minor
      Found in lib/cocoapods/installer/analyzer.rb - 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

      Method dependencies_for_specs has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

            def dependencies_for_specs(specs, platform, all_specs)
              dependent_specs = {
                :debug => Set.new,
                :release => Set.new,
              }
      Severity: Minor
      Found in lib/cocoapods/installer/analyzer.rb - 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

      Method analyze_host_targets_in_podfile has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def analyze_host_targets_in_podfile(aggregate_targets, embedded_aggregate_targets)
              target_definitions_by_uuid = {}
              cli_host_with_dynamic_linkage = []
              cli_product_type = 'com.apple.product-type.tool'
              # Collect aggregate target definitions by uuid to later lookup host target
      Severity: Major
      Found in lib/cocoapods/installer/analyzer.rb - About 2 hrs to fix

        Method embedded_target_pod_targets_by_host has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

              def embedded_target_pod_targets_by_host(aggregate_target, embedded_aggregate_targets, libraries_only)
                return {} if aggregate_target.requires_host_target?
                aggregate_user_target_uuids = Set.new(aggregate_target.user_targets.map(&:uuid))
                embedded_pod_targets_by_build_config = Hash.new([].freeze)
                embedded_aggregate_targets.each do |embedded_aggregate_target|
        Severity: Minor
        Found in lib/cocoapods/installer/analyzer.rb - 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

        Method generate_pod_targets has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def generate_pod_targets(resolver_specs_by_target, target_inspections)
                if installation_options.deduplicate_targets?
                  distinct_targets = resolver_specs_by_target.each_with_object({}) do |dependency, hash|
                    target_definition, dependent_specs = *dependency
                    dependent_specs.group_by(&:root).each do |root_spec, resolver_specs|
        Severity: Major
        Found in lib/cocoapods/installer/analyzer.rb - About 2 hrs to fix

          Method generate_aggregate_target has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                def generate_aggregate_target(target_definition, target_inspections, pod_targets_by_target_definition)
                  if installation_options.integrate_targets?
                    target_inspection = target_inspections[target_definition]
                    raise "missing inspection for #{target_definition.inspect}" unless target_inspection
                    target_requires_64_bit = Analyzer.requires_64_bit_archs?(target_definition.platform, target_inspection.project.object_version)
          Severity: Minor
          Found in lib/cocoapods/installer/analyzer.rb - 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

          Method generate_targets has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def generate_targets(resolver_specs_by_target, target_inspections)
                  resolver_specs_by_target = resolver_specs_by_target.reject { |td, _| td.abstract? && !td.platform }
                  pod_targets = generate_pod_targets(resolver_specs_by_target, target_inspections)
                  pod_targets_by_target_definition = group_pod_targets_by_target_definition(pod_targets, resolver_specs_by_target)
                  aggregate_targets = resolver_specs_by_target.keys.reject(&:abstract?).map do |target_definition|
          Severity: Minor
          Found in lib/cocoapods/installer/analyzer.rb - About 1 hr to fix

            Method analyze has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def analyze(allow_fetches = true)
                    return @result if @result
                    validate_podfile!
                    validate_lockfile_version!
                    if installation_options.integrate_targets?
            Severity: Minor
            Found in lib/cocoapods/installer/analyzer.rb - About 1 hr to fix

              Method generate_targets has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                    def generate_targets(resolver_specs_by_target, target_inspections)
                      resolver_specs_by_target = resolver_specs_by_target.reject { |td, _| td.abstract? && !td.platform }
                      pod_targets = generate_pod_targets(resolver_specs_by_target, target_inspections)
                      pod_targets_by_target_definition = group_pod_targets_by_target_definition(pod_targets, resolver_specs_by_target)
                      aggregate_targets = resolver_specs_by_target.keys.reject(&:abstract?).map do |target_definition|
              Severity: Minor
              Found in lib/cocoapods/installer/analyzer.rb - 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

              Method generate_version_locking_dependencies has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def generate_version_locking_dependencies(podfile_state)
                      if update_mode == :all || !lockfile
                        LockingDependencyAnalyzer.unlocked_dependency_graph
                      else
                        deleted_and_changed = podfile_state.changed + podfile_state.deleted
              Severity: Minor
              Found in lib/cocoapods/installer/analyzer.rb - 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

              Method generate_pod_targets has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def generate_pod_targets(resolver_specs_by_target, target_inspections)
                      if installation_options.deduplicate_targets?
                        distinct_targets = resolver_specs_by_target.each_with_object({}) do |dependency, hash|
                          target_definition, dependent_specs = *dependency
                          dependent_specs.group_by(&:root).each do |root_spec, resolver_specs|
              Severity: Minor
              Found in lib/cocoapods/installer/analyzer.rb - 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

              Method validate_platforms has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def validate_platforms(resolver_specs_by_target)
                      resolver_specs_by_target.each do |target, specs|
                        specs.map(&:spec).each do |spec|
                          next unless target_platform = target.platform
                          unless spec.available_platforms.any? { |p| target_platform.supports?(p) }
              Severity: Minor
              Found in lib/cocoapods/installer/analyzer.rb - 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

              Method generate_pod_target has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def generate_pod_target(target_definitions, build_type, target_inspections, specs, scope_suffix: nil,
                                            swift_version: nil)
                      target_inspections = target_inspections.select { |t, _| target_definitions.include?(t) }.values
                      object_version = target_inspections.map { |ti| ti.project.object_version }.min
                      target_requires_64_bit = target_definitions.all? { |td| Analyzer.requires_64_bit_archs?(td.platform, object_version) }
              Severity: Minor
              Found in lib/cocoapods/installer/analyzer.rb - 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

              Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def initialize(sandbox, podfile, lockfile = nil, plugin_sources = nil, has_dependencies = true,
                                   pods_to_update = false, sources_manager = Source::Manager.new(config.repos_dir))
              Severity: Major
              Found in lib/cocoapods/installer/analyzer.rb - About 50 mins to fix

                Method analyze has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def analyze(allow_fetches = true)
                        return @result if @result
                        validate_podfile!
                        validate_lockfile_version!
                        if installation_options.integrate_targets?
                Severity: Minor
                Found in lib/cocoapods/installer/analyzer.rb - 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

                Method requires_64_bit_archs? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                        def requires_64_bit_archs?(platform, object_version)
                          return false unless platform
                          case platform.name
                          when :osx
                            true
                Severity: Minor
                Found in lib/cocoapods/installer/analyzer.rb - 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

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

                          target.test_dependent_targets_by_spec_name_by_config = target.test_specs.each_with_object({}) do |test_spec, hash|
                            test_dependencies_by_config = dependencies_for_specs([test_spec], target.platform, all_specs)
                            test_dependencies_by_config.each { |config, deps| deps.delete_if { |k, _| dependencies_by_config[config].key? k } }
                            hash[test_spec.name] = Hash[test_dependencies_by_config.map { |k, v| [k, filter_dependencies(v, pod_targets_by_name, target)] }]
                Severity: Minor
                Found in lib/cocoapods/installer/analyzer.rb and 1 other location - About 55 mins to fix
                lib/cocoapods/installer/analyzer.rb on lines 696..699

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

                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

                          target.app_dependent_targets_by_spec_name_by_config = target.app_specs.each_with_object({}) do |app_spec, hash|
                            app_dependencies_by_config = dependencies_for_specs([app_spec], target.platform, all_specs)
                            app_dependencies_by_config.each { |config, deps| deps.delete_if { |k, _| dependencies_by_config[config].key? k } }
                            hash[app_spec.name] = Hash[app_dependencies_by_config.map { |k, v| [k, filter_dependencies(v, pod_targets_by_name, target)] }]
                Severity: Minor
                Found in lib/cocoapods/installer/analyzer.rb and 1 other location - About 55 mins to fix
                lib/cocoapods/installer/analyzer.rb on lines 690..693

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

                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