CocoaPods/CocoaPods

View on GitHub
lib/cocoapods/target/pod_target.rb

Summary

Maintainability
F
4 days
Test Coverage
A
97%

Class PodTarget has 90 methods (exceeds 20 allowed). Consider refactoring.
Open

  class PodTarget < Target
    # @return [Array<Specification>] the spec, subspecs and test specs of the target.
    #
    attr_reader :specs

Severity: Major
Found in lib/cocoapods/target/pod_target.rb - About 1 day to fix

    File pod_target.rb has 614 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'cocoapods/xcode/framework_paths'
    require 'cocoapods/xcode/xcframework'
    
    module Pod
      # Stores the information relative to the target used to compile a single Pod.
    Severity: Major
    Found in lib/cocoapods/target/pod_target.rb - About 1 day to fix

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

          def initialize(sandbox, build_type, user_build_configurations, archs, platform, specs, target_definitions,
                         file_accessors = [], scope_suffix = nil, swift_version = nil)
      Severity: Major
      Found in lib/cocoapods/target/pod_target.rb - About 1 hr to fix

        Method framework_paths has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def framework_paths
              @framework_paths ||= begin
                file_accessors.each_with_object({}) do |file_accessor, hash|
                  frameworks = file_accessor.vendored_dynamic_artifacts.map do |framework_path|
                    relative_path_to_sandbox = framework_path.relative_path_from(sandbox.root)
        Severity: Minor
        Found in lib/cocoapods/target/pod_target.rb - About 1 hr to fix

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

              def defines_module?
                return @defines_module if defined?(@defines_module)
                return @defines_module = true if uses_swift? || build_as_framework?
          
                explicit_target_definitions = target_definitions.select { |td| td.dependencies.any? { |d| d.root_name == pod_name } }
          Severity: Minor
          Found in lib/cocoapods/target/pod_target.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 _add_recursive_app_dependent_targets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def _add_recursive_app_dependent_targets(app_spec, set, configuration: nil)
                raise ArgumentError, 'Must give a app spec' unless app_spec
                dependent_targets = configuration ? app_dependent_targets_by_spec_name_by_config[app_spec.name][configuration] : app_dependent_targets_by_spec_name[app_spec.name]
                raise ArgumentError, "Unable to find deps for #{app_spec} for config #{configuration.inspect} #{app_dependent_targets_by_spec_name_by_config.inspect}" unless dependent_targets
          
          
          Severity: Minor
          Found in lib/cocoapods/target/pod_target.rb - 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

          Method _add_recursive_test_dependent_targets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def _add_recursive_test_dependent_targets(test_spec, set, configuration: nil)
                raise ArgumentError, 'Must give a test spec' unless test_spec
                dependent_targets = configuration ? test_dependent_targets_by_spec_name_by_config[test_spec.name][configuration] : test_dependent_targets_by_spec_name[test_spec.name]
                raise ArgumentError, "Unable to find deps for #{test_spec} for config #{configuration.inspect} (out of #{test_dependent_targets_by_spec_name_by_config.inspect})" unless dependent_targets
          
          
          Severity: Minor
          Found in lib/cocoapods/target/pod_target.rb - 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

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

              def header_mappings(file_accessor, headers)
                consumer = file_accessor.spec_consumer
                header_mappings_dir = consumer.header_mappings_dir
                dir = headers_sandbox
                dir += consumer.header_dir if consumer.header_dir
          Severity: Minor
          Found in lib/cocoapods/target/pod_target.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

              def recursive_app_dependent_targets(app_spec, configuration: nil)
                @recursive_app_dependent_targets ||= {}
                @recursive_app_dependent_targets[app_spec] ||= begin
                  hash = Hash[config_variants.map do |config|
                    [config, _add_recursive_app_dependent_targets(app_spec, Set.new, :configuration => config).to_a.freeze]
          Severity: Major
          Found in lib/cocoapods/target/pod_target.rb and 1 other location - About 1 hr to fix
          lib/cocoapods/target/pod_target.rb on lines 863..872

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

          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

              def recursive_test_dependent_targets(test_spec, configuration: nil)
                @recursive_test_dependent_targets ||= {}
                @recursive_test_dependent_targets[test_spec] ||= begin
                  hash = Hash[config_variants.map do |config|
                    [config, _add_recursive_test_dependent_targets(test_spec, Set.new, :configuration => config).to_a.freeze]
          Severity: Major
          Found in lib/cocoapods/target/pod_target.rb and 1 other location - About 1 hr to fix
          lib/cocoapods/target/pod_target.rb on lines 910..919

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

          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

              def create_test_build_settings_by_config
                Hash[test_specs.map do |test_spec|
                  [test_spec.name, Hash[config_variants.map do |config|
                    [config, BuildSettings::PodTargetSettings.new(self, test_spec, :configuration => config)]
                  end]]
          Severity: Minor
          Found in lib/cocoapods/target/pod_target.rb and 1 other location - About 20 mins to fix
          lib/cocoapods/target/pod_target.rb on lines 1109..1113

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

          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

              def create_app_build_settings_by_config
                Hash[app_specs.map do |app_spec|
                  [app_spec.name, Hash[config_variants.map do |config|
                    [config, BuildSettings::PodTargetSettings.new(self, app_spec, :configuration => config)]
                  end]]
          Severity: Minor
          Found in lib/cocoapods/target/pod_target.rb and 1 other location - About 20 mins to fix
          lib/cocoapods/target/pod_target.rb on lines 1101..1105

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

          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