Skip to content

Commit

Permalink
lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Marlon Pina Tojal <[email protected]>
  • Loading branch information
Marlon Pina Tojal committed Feb 29, 2024
1 parent ea74719 commit ea90242
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/cyclonedx/cocoapods/cli_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ def analyze(options)

component = component_from_options(options)

if !component.nil?
#add top level pods to main component
unless component.nil?
# add top level pods to main component
top_deps = analyzer.top_level_deps(podfile, lockfile)
dependencies[component.bomref] = top_deps
end
Expand Down
7 changes: 3 additions & 4 deletions lib/cyclonedx/cocoapods/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ def initialize(name:, version:, type:, group: nil)
@name = name
@version = version
@type = type
@bomref= name + "@" + version
@bomref = "#{name}@#{version}"

if !group.nil?
@bomref= group + "/" + @bomref
end
return if group.nil?

@bomref = "#{group}/#{@bomref}"
end
end
end
Expand Down
17 changes: 7 additions & 10 deletions lib/cyclonedx/cocoapods/podfile_analyzer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ def populate_pods_with_additional_info(pods)
end

def top_level_deps(podfile, lockfile)
pods_used = top_level_pods(podfile, lockfile)
deps = dependencies_for_pod(pods_used, podfile, lockfile)
deps
pods_used = top_level_pods(podfile)
dependencies_for_pod(pods_used, podfile, lockfile)
end

private
Expand Down Expand Up @@ -106,13 +105,13 @@ def load_one_plugin(plugin_name)
def validate_options(project_dir, options)
raise PodfileParsingError, "#{options[:path]} is not a valid directory." unless File.directory?(project_dir)

options[:podfile_path] = project_dir + 'Podfile'
options[:podfile_path] = "#{project_dir}Podfile"
unless File.exist?(options[:podfile_path])
raise PodfileParsingError, "Missing Podfile in #{project_dir}. Please use the --path option if " \
'not running from the CocoaPods project directory.'
end

options[:podfile_lock_path] = project_dir + 'Podfile.lock'
options[:podfile_lock_path] = "#{project_dir}Podfile.lock"
return if File.exist?(options[:podfile_lock_path])

raise PodfileParsingError, "Missing Podfile.lock, please run 'pod install' before generating BOM"
Expand Down Expand Up @@ -210,21 +209,19 @@ def append_all_pod_dependencies(pods_used, pods_cache)
[result, dependencies_hash]
end

def top_level_pods(podfile, lockfile)
def top_level_pods(podfile)
included_targets = podfile.target_definition_list.select { |target| include_target_named(target.label) }
included_target_names = included_targets.map(&:label)
@logger.debug "Including all pods for targets: #{included_target_names}"

top_level_deps = included_targets.map(&:dependencies).flatten.uniq
pods_used = top_level_deps.map(&:name).uniq

pods_used
top_level_deps.map(&:name).uniq
end

def create_list_of_included_pods(podfile, lockfile)
pods_cache = simple_hash_of_lockfile_pods(lockfile)

pods_used = top_level_pods(podfile, lockfile)
pods_used = top_level_pods(podfile)
pods_used, dependencies = append_all_pod_dependencies(pods_used, pods_cache)

[pods_used.sort, dependencies]
Expand Down

0 comments on commit ea90242

Please sign in to comment.