Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

### Added

- `--quiet` flag for `mix assay` to suppress informational output (header,
ignore logs, summary, and the warnings exit message). Formatted warning
output and exit codes are unchanged.

## [0.6.1] - 2026-06-05

### Fixed
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ mix assay
mix assay --print-config
mix assay --format github --format sarif
mix assay --no-compile # skip compilation (project must already be compiled)
mix assay --quiet # suppress header, ignore logs, summary, and exit message
```

Exit codes: `0` (clean), `1` (warnings), `2` (error).
Expand Down
11 changes: 9 additions & 2 deletions lib/mix/tasks/assay.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule Mix.Tasks.Assay do
* `--dialyzer-flag FLAG` - Pass additional Dialyzer flags
* `--ignore-file PATH` - Override ignore file path (default: `dialyzer_ignore.exs`)
* `--explain-ignores` - Show detailed information about which warnings were ignored and which rules matched them
* `--quiet` - Suppress informational output (header, ignore logs, summary, and warnings exit message)

## Exit Codes

Expand All @@ -29,6 +30,7 @@ defmodule Mix.Tasks.Assay do
mix assay --dialyzer-flag="--statistics"
mix assay --ignore-file="custom_ignore.exs"
mix assay --explain-ignores
mix assay --quiet --format json
"""
use Mix.Task

Expand All @@ -43,7 +45,10 @@ defmodule Mix.Tasks.Assay do
:ok

:warnings ->
Mix.shell().info("Dialyzer reported warnings")
if !Keyword.get(opts, :quiet, false) do
Mix.shell().info("Dialyzer reported warnings")
end

exit({:shutdown, 1})
end
end
Expand All @@ -60,7 +65,8 @@ defmodule Mix.Tasks.Assay do
apps: :string,
warning_apps: :string,
ignore_file: :string,
explain_ignores: :boolean
explain_ignores: :boolean,
quiet: :boolean
],
aliases: [f: :format]
)
Expand Down Expand Up @@ -92,6 +98,7 @@ defmodule Mix.Tasks.Assay do
|> Keyword.put(:formats, normalized_formats)
|> Keyword.put(:no_compile, Keyword.get(opts, :no_compile, false))
|> Keyword.put(:explain_ignores, Keyword.get(opts, :explain_ignores, false))
|> Keyword.put(:quiet, Keyword.get(opts, :quiet, false))
|> maybe_put(:apps, apps_override)
|> maybe_put(:warning_apps, warning_override)
|> maybe_put(:dialyzer_flags, flag_overrides)
Expand Down
33 changes: 33 additions & 0 deletions test/mix_tasks_assay_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,39 @@ defmodule Mix.Tasks.AssayTest do
assert Keyword.get(runner_opts, :no_compile) == false
end

test "run forwards --quiet flag" do
Process.put(:runner_stub_status, :ok)

ExUnit.CaptureIO.capture_io(fn ->
Assay.run(["--quiet"])
end)

assert_received {:runner_called, _config, runner_opts}
assert Keyword.get(runner_opts, :quiet) == true
end

test "run defaults quiet to false when flag is omitted" do
Process.put(:runner_stub_status, :ok)

ExUnit.CaptureIO.capture_io(fn ->
Assay.run([])
end)

assert_received {:runner_called, _config, runner_opts}
assert Keyword.get(runner_opts, :quiet) == false
end

test "run suppresses warnings exit message when --quiet is set" do
Process.put(:runner_stub_status, :warnings)

output =
capture_io(fn ->
assert catch_exit(Assay.run(["--quiet"])) == {:shutdown, 1}
end)

refute output =~ "Dialyzer reported warnings"
end

test "assay.daemon task boots the daemon" do
Application.put_env(:assay, :daemon_module, DaemonStub)

Expand Down
6 changes: 3 additions & 3 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ defmodule Assay.TestSupport.IOProxy do
case :binary.match(buffer, "\n") do
{pos, _len} ->
len = pos + 1
<<line::binary-size(len), rest::binary>> = buffer
<<line::binary-size(^len), rest::binary>> = buffer
{:reply, line, rest}

:nomatch ->
Expand All @@ -215,7 +215,7 @@ defmodule Assay.TestSupport.IOProxy do

defp fetch_chars(buffer, true, len) do
if byte_size(buffer) >= len do
<<chunk::binary-size(len), rest::binary>> = buffer
<<chunk::binary-size(^len), rest::binary>> = buffer
{:reply, chunk, rest}
else
{:reply, buffer, <<>>}
Expand All @@ -224,7 +224,7 @@ defmodule Assay.TestSupport.IOProxy do

defp fetch_chars(buffer, false, len) do
if byte_size(buffer) >= len do
<<chunk::binary-size(len), rest::binary>> = buffer
<<chunk::binary-size(^len), rest::binary>> = buffer
{:reply, chunk, rest}
else
:pending
Expand Down