Skip to content

Commit

Permalink
Fix credo
Browse files Browse the repository at this point in the history
  • Loading branch information
sgessa committed Mar 15, 2024
1 parent 44b0ea0 commit d611fd6
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lib/mix_audit/cli/audit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ defmodule MixAudit.CLI.Audit do
format = Keyword.get(opts, :format)
ignored_advisory_ids = ignored_advisory_ids(opts)
ignored_package_names = ignored_package_names(opts)
ignored_ids_from_file = ignored_ids_from_file(opts)

# Synchronize and get security advisories
advisories =
MixAudit.Repo.advisories()
|> Enum.reject(&(&1.id in ignored_advisory_ids))
|> Enum.reject(&(&1.id in ignored_ids_from_file))
|> Enum.group_by(& &1.package)

# Get project dependencies
Expand All @@ -35,20 +33,20 @@ defmodule MixAudit.CLI.Audit do
end

defp ignored_advisory_ids(opts) do
opts
|> Keyword.get(:ignore_advisory_ids, "")
|> String.split(",")
|> Enum.map(&String.trim/1)
ignored_ids_from_cli = ignored_advisory_ids_from_cli(opts)
ignored_ids_from_file = ignored_advisory_ids_from_file(opts)

Enum.uniq(ignored_ids_from_cli ++ ignored_ids_from_file)
end

defp ignored_package_names(opts) do
defp ignored_advisory_ids_from_cli(opts) do
opts
|> Keyword.get(:ignore_package_names, "")
|> Keyword.get(:ignore_advisory_ids, "")
|> String.split(",")
|> Enum.map(&String.trim/1)
end

def ignored_ids_from_file(opts) do
def ignored_advisory_ids_from_file(opts) do
case Keyword.get(opts, :ignore_file) do
nil ->
[]
Expand All @@ -60,4 +58,11 @@ defmodule MixAudit.CLI.Audit do
|> Enum.reject(fn line -> String.starts_with?(line, "#") || String.trim(line) == "" end)
end
end

defp ignored_package_names(opts) do
opts
|> Keyword.get(:ignore_package_names, "")
|> String.split(",")
|> Enum.map(&String.trim/1)
end
end

0 comments on commit d611fd6

Please sign in to comment.