defmodule Blogex.MixProject do use Mix.Project @version "0.1.0" @source_url "https://github.com/yourorg/blogex" def project do [ app: :blogex, version: @version, elixir: "~> 1.15", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), test_coverage: test_coverage(), docs: docs(), package: package(), description: "A multi-blog engine powered by NimblePublisher for Phoenix apps" ] end defp elixirc_paths(:test), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] def application do [ extra_applications: [:logger] ] end def cli do [ preferred_envs: [precommit: :test] ] end defp deps do [ {:nimble_publisher, "~> 2.0"}, {:floki, "~> 0.38"}, {:makeup_elixir, ">= 0.0.0"}, {:makeup_erlang, ">= 0.0.0"}, {:phoenix, "~> 1.7"}, {:phoenix_html, "~> 4.0"}, {:phoenix_live_view, "~> 1.0"}, {:jason, "~> 1.4"}, {:plug, "~> 1.15"}, # Declared directly although unused today (no boundaries, no compiler # entry): `ex_crap` supplies boundary transitively, and a compile-time # tool must not arrive or vanish as a side effect of a metric tool. {:boundary, "~> 0.11", runtime: false}, {:ex_doc, "~> 0.34", only: :dev, runtime: false}, {:rustler, "~> 0.38.0", optional: true}, {:credo, "~> 1.7", only: [:dev, :test], runtime: false}, {:ex_crap, "~> 0.1.1", only: [:dev, :test], runtime: false}, {:muex, "~> 0.12", only: [:dev, :test], runtime: false} ] end # The coverage floor the Lens pass enforces (`make verify` -> `make coverage` # in blogex/). Rule: the threshold is a FLOOR. Raise it as behavior-test yaks # land; never lower it. A drop means the change (or an exclusion) is wrong. # # Measured 2026-10-28, with the test scaffolding below excluded: 99.69% — the # same via `mix test --cover` and via `mix test --cover --export-coverage # default` + `mix test.coverage`. Floor is the integer below that. # # Excluded: the test scaffolding in `ignore_modules` below. The two registry # blog doubles (Blogex.Test.AlphaBlog/BetaBlog) are deliberately not listed # there: they are fully exercised, and excluding them measures 99.69% too — # the 99 floor holds either way. # # Everything in lib/blogex counts, and one gap is left: # Blogex.LinkError is at 88.89% (8 of 9 lines). The rendered-HTML behavior # tests closed the rest: Blogex.Components and Blogex.Layout went from 0% to # 100%, and Blogex.Router now covers its browser arms and `match _`. defp test_coverage do [ summary: [threshold: 99], ignore_modules: [ Blogex.Test.FakeBlog, Blogex.Test.PostBuilder, Blogex.Test.Setup ] ] end defp docs do [ main: "readme", source_url: @source_url, extras: ["README.md"] ] end # Same `precommit` alias name and shape as app/mix.exs, so both apps share # one loop: compile (warnings fatal), format, test. Heavy sensors belong in # the Lens pass (`make verify`), not here. # # `mutate` / `mutate.fast` are a sensor, not a gate: they are deliberately # absent from Makefile's VERIFY_SENSORS and always pass `--fail-at 0`, so a # survivor is reported rather than fatal. The scope lives in the plain-text # files beside this one; the aliases read them at run time, so the text file # stays the single source of truth. defp aliases do [ precommit: ["compile --warning-as-errors", "format", "test"], mutate: &mutate/1, "mutate.fast": &mutate_fast/1 ] end # No macro/`use` mutators: the scoped modules are plain functions, and the # macro-heavy modules (blog.ex, router.ex, components.ex, layout.ex) are out # of scope entirely. Spellings are muex 0.12's CLI names. @mutation_mutators "arithmetic,boolean,comparison,conditional,function_call,literal,return_value" defp mutate(args), do: run_mutation("mutation_scope.txt", args) defp mutate_fast(args), do: run_mutation("mutation_scope_fast.txt", args) defp run_mutation(scope_file, args) do Mix.Task.run("muex", mutation_args(scope_file, args)) end @doc false def mutation_args(scope_file, extra_args \\ []) do files = read_mutation_scope(scope_file) # `--fail-at 0` comes first so an ad-hoc override cannot turn the sensor # into a gate. Extra args come before our defaults, and OptionParser keeps # the first value, so `mix mutate --files lib/blogex/seo.ex` targets one # file while `mix mutate` covers the whole scope file. ["--fail-at", "0"] ++ extra_args ++ ["--files", Enum.join(files, ","), "--mutators", @mutation_mutators] end @doc false def read_mutation_scope(scope_file) do path = Path.expand(scope_file, Path.dirname(Mix.Project.project_file())) files = case File.read(path) do {:ok, contents} -> contents |> String.split("\n", trim: true) |> Enum.map(&String.trim/1) |> Enum.reject(&(&1 == "")) {:error, reason} -> Mix.raise( "mutation scope #{scope_file} is unreadable (#{:file.format_error(reason)}); " <> "refusing to run the mutation sensor over an unknown scope" ) end if files == [] do Mix.raise( "mutation scope #{scope_file} is empty; refusing to run the mutation sensor over nothing" ) end files end defp package do [ licenses: ["MIT"], links: %{"GitHub" => @source_url} ] end end