Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Enable Dialyzer and Credo in CI (#2315)
Uku Taht8bdbabbdad02
diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.ymlindex be302f79e9..b523cb86ac 100644--- a/.github/workflows/elixir.yml+++ b/.github/workflows/elixir.yml@@ -40,7 +40,9 @@ jobs:--health-retries 5steps:- - uses: actions/checkout@v2+ - uses: actions/checkout@v3+ with:+ fetch-depth: 0- name: Read .tool-versionsuses: marocchino/tool-versions-action@v1id: versions@@ -66,11 +68,11 @@ jobs:run: mix compile --warnings-as-errors --all-warnings- name: Generate tracker filesrun: npm run deploy --prefix ./tracker+ - name: Check Credo Warnings+ run: mix credo diff --from-git-merge-base origin/master- name: Run testsrun: mix test- #- name: Check Dialyzer- # run: mix dialyzer <-- false negatives- - name: Check Credo Warnings- run: mix credo --strict --only warning --ignore Consistency+ - name: Check Dialyzer+ run: mix dialyzerenv:MIX_ENV: testdiff --git a/lib/plausible/billing/billing.ex b/lib/plausible/billing/billing.exindex 70a1e05933..04d5ef331b 100644--- a/lib/plausible/billing/billing.ex+++ b/lib/plausible/billing/billing.ex@@ -13,12 +13,10 @@ defmodule Plausible.Billing doenddefp active_subscription_query(user_id) do- from(- s in Subscription,+ from s in Subscription,where: s.user_id == ^user_id and s.status == "active",order_by: [desc: s.inserted_at],limit: 1- )enddef subscription_created(params) do@@ -47,7 +45,7 @@ defmodule Plausible.Billing doRepo.get(Plausible.Auth.User, subscription.user_id)|> Map.put(:subscription, subscription)- {:ok, user}+ user|> maybe_remove_grace_period|> check_lock_status|> maybe_adjust_api_key_limits@@ -251,12 +249,13 @@ defmodule Plausible.Billing dodefp has_active_enterprise_subscription(user) doPlausible.Repo.exists?(- from s in Plausible.Billing.Subscription,+ from(s in Plausible.Billing.Subscription,join: e in Plausible.Billing.EnterprisePlan,on: s.user_id == e.user_id and s.paddle_plan_id == e.paddle_plan_id,where: s.user_id == ^user.id,where: s.paddle_plan_id == ^user.enterprise_plan.paddle_plan_id,where: s.status == "active"+ ))end@@ -278,7 +277,7 @@ defmodule Plausible.Billing dodefp present?(nil), do: falsedefp present?(_), do: true- defp maybe_remove_grace_period({:ok, user}) do+ defp maybe_remove_grace_period(%Plausible.Auth.User{} = user) doalias Plausible.Auth.GracePeriodcase user.grace_period do@@ -298,8 +297,6 @@ defmodule Plausible.Billing doendend- defp maybe_remove_grace_period(err), do: err-defp check_lock_status({:ok, user}) doPlausible.Billing.SiteLocker.check_sites_for(user){:ok, user}diff --git a/lib/plausible/billing/subscription.ex b/lib/plausible/billing/subscription.exindex 806b217e45..b2dcfcca2d 100644--- a/lib/plausible/billing/subscription.ex+++ b/lib/plausible/billing/subscription.ex@@ -1,7 +1,10 @@defmodule Plausible.Billing.Subscription do+ @moduledoc falseuse Ecto.Schemaimport Ecto.Changeset+ @type t() :: %__MODULE__{}+@required_fields [:paddle_subscription_id,:paddle_plan_id,diff --git a/lib/plausible/stats/base.ex b/lib/plausible/stats/base.exindex c9b70223bc..b381a9165b 100644--- a/lib/plausible/stats/base.ex+++ b/lib/plausible/stats/base.ex@@ -3,6 +3,8 @@ defmodule Plausible.Stats.Base doalias Plausible.Stats.{Query, Filters}import Ecto.Query+ # Ecto typespec has not been updated for this PR: https://github.com/elixir-ecto/ecto/pull/3592+ @dialyzer {:nowarn_function, add_sample_hint: 2}@no_ref "Direct / None"def base_event_query(site, query) dodiff --git a/lib/plausible_web/controllers/stats_controller.ex b/lib/plausible_web/controllers/stats_controller.exindex 8a4e7d9906..fc99b47729 100644--- a/lib/plausible_web/controllers/stats_controller.ex+++ b/lib/plausible_web/controllers/stats_controller.ex@@ -46,7 +46,7 @@ defmodule PlausibleWeb.StatsController doalias Plausible.Stats.{Query, Filters}alias PlausibleWeb.Api- plug PlausibleWeb.AuthorizeSiteAccess when action in [:stats, :csv_export]+ plug(PlausibleWeb.AuthorizeSiteAccess when action in [:stats, :csv_export])def stats(%{assigns: %{site: site}} = conn, _params) dostats_start_date = Plausible.Sites.stats_start_date(site)@@ -106,7 +106,7 @@ defmodule PlausibleWeb.StatsController do|> Enum.join()filename =- "Plausible export #{params["domain"]} #{Timex.format!(query.date_range.first, "{ISOdate} ")} to #{Timex.format!(query.date_range.last, "{ISOdate} ")}.zip"+ 'Plausible export #{params["domain"]} #{Timex.format!(query.date_range.first, "{ISOdate} ")} to #{Timex.format!(query.date_range.last, "{ISOdate} ")}.zip'params = Map.merge(params, %{"limit" => "300", "csv" => "True", "detailed" => "True"})limited_params = Map.merge(params, %{"limit" => "100"})@@ -181,9 +181,10 @@ defmodule PlausibleWeb.StatsController dodef shared_link(conn, %{"domain" => slug}) doshared_link =Repo.one(- from l in Plausible.Site.SharedLink,+ from(l in Plausible.Site.SharedLink,where: l.slug == ^slug and l.inserted_at < ^@old_format_deprecation_date,preload: :site+ ))if shared_link do@@ -217,12 +218,13 @@ defmodule PlausibleWeb.StatsController dodefp find_shared_link(domain, auth) dolink_query =- from link in Plausible.Site.SharedLink,+ from(link in Plausible.Site.SharedLink,inner_join: site in assoc(link, :site),where: link.slug == ^auth,where: site.domain == ^domain,limit: 1,preload: [site: site]+ )case Repo.one(link_query) do%Plausible.Site.SharedLink{password_hash: hash} = link when not is_nil(hash) ->diff --git a/test/support/test_utils.ex b/test/support/test_utils.exindex f9c6015e88..ed2b41f076 100644--- a/test/support/test_utils.ex+++ b/test/support/test_utils.ex@@ -141,8 +141,8 @@ defmodule Plausible.TestUtils doendend)- if native, do: populate_native_stats(native)- if imported, do: populate_imported_stats(imported)+ populate_native_stats(native)+ populate_imported_stats(imported)enddefp populate_native_stats(events) do