CocoaPods/Core

View on GitHub
lib/cocoapods-core/podfile/target_definition.rb

Summary

Maintainability
F
3 days
Test Coverage

File target_definition.rb has 587 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Pod
  class Podfile
    # The TargetDefinition stores the information of a CocoaPods static
    # library. The target definition can be linked with one or more targets of
    # the user project.
Severity: Major
Found in lib/cocoapods-core/podfile/target_definition.rb - About 1 day to fix

    Class TargetDefinition has 67 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class TargetDefinition
          # @return [TargetDefinition, Podfile] the parent target definition or the
          #         Podfile if the receiver is root.
          #
          attr_reader :parent
    Severity: Major
    Found in lib/cocoapods-core/podfile/target_definition.rb - About 1 day to fix

      Method store_podspec has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def store_podspec(options = nil)
              options ||= {}
              unless options.keys.all? { |key| [:name, :path, :subspecs, :subspec].include?(key) }
                raise StandardError, 'Unrecognized options for the podspec ' \
                  "method `#{options}`"
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.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 podspec_path_from_options has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def podspec_path_from_options(options)
              if path = options[:path]
                if File.basename(path).include?('.podspec')
                  path_with_ext = path
                else
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.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 inhibit_warnings_hash has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def inhibit_warnings_hash
              inhibit_hash = raw_inhibit_warnings_hash
              if exclusive?
                inhibit_hash
              else
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.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 store_script_phase has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def store_script_phase(options)
              option_keys = options.keys
              unrecognized_keys = option_keys - Specification::ALL_SCRIPT_PHASE_KEYS
              unless unrecognized_keys.empty?
                raise StandardError, "Unrecognized options `#{unrecognized_keys}` in shell script `#{options[:name]}` within `#{name}` target. " \
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.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 pod_whitelisted_for_configuration? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def pod_whitelisted_for_configuration?(pod_name, configuration_name)
              found = false
              configuration_pod_whitelist.each do |configuration, pods|
                if pods.include?(pod_name)
                  found = true
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.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 use_modular_headers_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def use_modular_headers_hash
              raw_hash = raw_use_modular_headers_hash
              if exclusive?
                raw_hash
              else
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.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 podspec_dependencies has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def podspec_dependencies
              podspecs = get_hash_value('podspecs') || []
              podspecs.map do |options|
                file = podspec_path_from_options(options)
                spec = Specification.from_file(file)
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.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 platform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def platform
              name_or_hash = get_hash_value('platform')
              if name_or_hash
                if name_or_hash.is_a?(Hash)
                  name = name_or_hash.keys.first.to_sym
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.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 parse_subspecs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_subspecs(name, requirements)
              options = requirements.last
              return false unless options.is_a?(Hash)
      
              subspecs = options.delete(:subspecs)
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.rb - 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

      Method build_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def build_type
              value = get_hash_value('uses_frameworks', root? ? BuildType.static_library : parent.build_type)
              case value
              when true, false
                value ? BuildType.dynamic_framework : BuildType.static_library
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.rb - 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

            def set_use_modular_headers_for_pod(pod_name, flag)
              hash_key = case flag
                         when true
                           'for_pods'
                         when false
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.rb and 1 other location - About 35 mins to fix
      lib/cocoapods-core/podfile/target_definition.rb on lines 351..363

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

      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 set_inhibit_warnings_for_pod(pod_name, should_inhibit)
              hash_key = case should_inhibit
                         when true
                           'for_pods'
                         when false
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.rb and 1 other location - About 35 mins to fix
      lib/cocoapods-core/podfile/target_definition.rb on lines 597..609

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

      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 inhibits_warnings_for_pod?(pod_name)
              if Array(inhibit_warnings_hash['not_for_pods']).include?(pod_name)
                false
              elsif inhibit_warnings_hash['all']
                true
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.rb and 1 other location - About 25 mins to fix
      lib/cocoapods-core/podfile/target_definition.rb on lines 564..573

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

      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 build_pod_as_module?(pod_name)
              if Array(use_modular_headers_hash['not_for_pods']).include?(pod_name)
                false
              elsif use_modular_headers_hash['all']
                true
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.rb and 1 other location - About 25 mins to fix
      lib/cocoapods-core/podfile/target_definition.rb on lines 317..326

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

      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 parse_modular_headers(name, requirements)
              options = requirements.last
              return requirements unless options.is_a?(Hash)
      
              defines_module = options.delete(:modular_headers)
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.rb and 1 other location - About 20 mins to fix
      lib/cocoapods-core/podfile/target_definition.rb on lines 1057..1065

      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 parse_inhibit_warnings(name, requirements)
              options = requirements.last
              return requirements unless options.is_a?(Hash)
      
              should_inhibit = options.delete(:inhibit_warnings)
      Severity: Minor
      Found in lib/cocoapods-core/podfile/target_definition.rb and 1 other location - About 20 mins to fix
      lib/cocoapods-core/podfile/target_definition.rb on lines 1079..1087

      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