Skip to content

Instantly share code, notes, and snippets.

@Nezteb
Created March 29, 2023 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nezteb/eb654f399fa599d0805d38d9a4b56da4 to your computer and use it in GitHub Desktop.
Save Nezteb/eb654f399fa599d0805d38d9a4b56da4 to your computer and use it in GitHub Desktop.
Theoretical mix task that will fail/alert when new Dialyzer errors are added to codebase. Based on: https://www.youtube.com/watch?v=4PZE40h13wM
defmodule Mix.Tasks.CheckTypes do
@moduledoc "The checktypes mix task: `mix help checktypes`"
use Mix.Task
@shortdoc "Runs Dialyzer and compares the results to our existing errors."
def run(_args) do
# https://github.com/jeremyjh/dialyxir/blob/ed0df656a74eb6d4e906fe20fc056ca42ba7d5ec/lib/mix/tasks/dialyzer.ex#L145-L155
output = Mix.Task.run("dialyzer", ["--quiet", "--format", "ignore_file"])
# TODO: 1. Parse text output from dialyzer into list of Dialyzer error tuples.
# TODO: 2. Compare the list of old errors and list of new errors.
# TODO: 3. If any new errors have been added, fail.
# TODO: 4. If lists are equal or list of new errors is smaller, succeed.
# TODO: 5. As old errors are fixed, devs will remove lines from below list so they aren't checked in the future.
end
def old_type_check_errors() do
[
# Huge list of Dialyzer error tuples
]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment