From 621747d3170124e56470ecdcae1f3f4b9b3a6b47 Mon Sep 17 00:00:00 2001 From: baldarn Date: Fri, 15 Mar 2024 08:59:51 +0100 Subject: [PATCH] ignored ids from file works only if the file is defined --- README.md | 2 +- lib/mix_audit/cli/audit.ex | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 557765a..6d2e5b6 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ $ mix deps.audit | `--format` | String | `"human"` | The format of the report to generate (`"json"` or `"human"`) | | `--ignore-advisory-ids` | String | `""` | Comma-separated list of advisory IDs to ignore | | `--ignore-package-names` | String | `""` | Comma-separated list of package names to ignore | -| `--ignore-file` | String | `.mix-audit-skips` | Path of the ignore file | +| `--ignore-file` | String | `""` | Path of the ignore file | ## Example diff --git a/lib/mix_audit/cli/audit.ex b/lib/mix_audit/cli/audit.ex index 1af9875..08b64b4 100644 --- a/lib/mix_audit/cli/audit.ex +++ b/lib/mix_audit/cli/audit.ex @@ -48,11 +48,15 @@ defmodule MixAudit.CLI.Audit do |> Enum.map(&String.trim/1) end - defp ignored_ids_from_file(opts) do - opts - |> Keyword.get(:ignore_file, ".mix-audit-skips") - |> File.read!() - |> String.split("\n") - |> Enum.reject(fn line -> String.starts_with?(line, "#") || String.trim(line) == "" end) + def ignored_ids_from_file(opts) do + case Keyword.get(opts, :ignore_file) do + nil -> + [] + + ignore_file -> + File.read!(ignore_file) + |> String.split("\n") + |> Enum.reject(fn line -> String.starts_with?(line, "#") || String.trim(line) == "" end) + end end end