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
Clean up credo warnings (#6688)
Adrian Gruntkowski16120d0a92f6
diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.ymlindex 707f89dc4f..3862298e9d 100644--- a/.github/workflows/elixir.yml+++ b/.github/workflows/elixir.yml@@ -304,5 +304,5 @@ jobs:- run: mix format --check-formatted- run: mix deps.unlock --check-unused- run: mix generate_countries_meta && git diff --exit-code -- assets/data/countries_meta.json- - run: mix credo diff --from-git-merge-base origin/master+ - run: mix credo- run: mix dialyzerdiff --git a/lib/mix/tasks/pull_sandbox_subscription.ex b/lib/mix/tasks/pull_sandbox_subscription.exindex 24c268b143..d9139b5db8 100644--- a/lib/mix/tasks/pull_sandbox_subscription.ex+++ b/lib/mix/tasks/pull_sandbox_subscription.ex@@ -1,4 +1,8 @@defmodule Mix.Tasks.PullSandboxSubscription do+ @moduledoc """+ Mix task for creating subscriptions in dev environment via Paddle API.+ """+use Mix.Taskuse Plausible.Repoalias Plausible.{Repo, Auth.User, Billing.Subscription}diff --git a/lib/oban_error_reporter.ex b/lib/oban_error_reporter.exindex 1ac0a27c50..aa33973eb2 100644--- a/lib/oban_error_reporter.ex+++ b/lib/oban_error_reporter.ex@@ -1,4 +1,8 @@defmodule ObanErrorReporter do+ @moduledoc """+ Handler module for processing Oban errors.+ """+use Plausiblerequire Loggerdiff --git a/lib/plausible/auth/password.ex b/lib/plausible/auth/password.exindex 193d6e97a0..2a886bee73 100644--- a/lib/plausible/auth/password.ex+++ b/lib/plausible/auth/password.ex@@ -1,4 +1,8 @@defmodule Plausible.Auth.Password do+ @moduledoc """+ Functions for computing and comparing against Bcrypt hashed passwords.+ """+def hash(password) doBcrypt.hash_pwd_salt(password)enddiff --git a/lib/plausible/auth/token.ex b/lib/plausible/auth/token.exindex 01b818e462..88deda8d1d 100644--- a/lib/plausible/auth/token.ex+++ b/lib/plausible/auth/token.ex@@ -1,4 +1,8 @@defmodule Plausible.Auth.Token do+ @moduledoc """+ Functions for signing and verifying single-use tokens.+ """+@one_hour_in_seconds 30 * 60def sign_shared_link(slug) dodiff --git a/lib/plausible/billing/paddle_api.ex b/lib/plausible/billing/paddle_api.exindex ab174bc8b7..5857ae1b39 100644--- a/lib/plausible/billing/paddle_api.ex+++ b/lib/plausible/billing/paddle_api.ex@@ -1,4 +1,8 @@defmodule Plausible.Billing.PaddleApi do+ @moduledoc """+ Paddle API HTTP client.+ """+alias Plausible.HTTPClient@headers [diff --git a/lib/plausible/billing/plans.ex b/lib/plausible/billing/plans.exindex 143ac10c45..6d6583779f 100644--- a/lib/plausible/billing/plans.ex+++ b/lib/plausible/billing/plans.ex@@ -1,4 +1,12 @@defmodule Plausible.Billing.Plans do+ @moduledoc """+ Functions for retrieving subscription plans and their pricing.++ Plan details are loaded from locally stored static JSON files.++ Pricing is fetched from Paddle API.+ """+alias Plausible.Billing.Subscriptionsuse Plausible.Repoalias Plausible.Billing.{Subscription, Plan, EnterprisePlan}diff --git a/lib/plausible/billing/site_locker.ex b/lib/plausible/billing/site_locker.exindex 19e03b895d..808bc2efbe 100644--- a/lib/plausible/billing/site_locker.ex+++ b/lib/plausible/billing/site_locker.ex@@ -1,4 +1,8 @@defmodule Plausible.Billing.SiteLocker do+ @moduledoc """+ Api for managing team's lock state.+ """+use Plausible.Repoalias Plausible.Teamsdiff --git a/lib/plausible/clickhouse_repo.ex b/lib/plausible/clickhouse_repo.exindex cf5c0dedf7..c1ae380398 100644--- a/lib/plausible/clickhouse_repo.ex+++ b/lib/plausible/clickhouse_repo.ex@@ -1,4 +1,8 @@defmodule Plausible.ClickhouseRepo do+ @moduledoc """+ Repository for querying Clickhouse database.+ """+use Plausibleuse Ecto.Repo,diff --git a/lib/plausible/data_migration/backfill_tracker_script_configuration.ex b/lib/plausible/data_migration/backfill_tracker_script_configuration.exindex f5783b6ec5..050955600d 100644--- a/lib/plausible/data_migration/backfill_tracker_script_configuration.ex+++ b/lib/plausible/data_migration/backfill_tracker_script_configuration.ex@@ -52,7 +52,7 @@ defmodule Plausible.DataMigration.BackfillTrackerScriptConfiguration do))- if length(sites) > 0 do+ if sites != [] docreate_tracker_script_configurations(sites, now)process_batch(offset + @batch_size, now)enddiff --git a/lib/plausible/data_migration/prefix_tracker_script_configuration_id.ex b/lib/plausible/data_migration/prefix_tracker_script_configuration_id.exindex 9932c2d80e..91d3c2ffd6 100644--- a/lib/plausible/data_migration/prefix_tracker_script_configuration_id.ex+++ b/lib/plausible/data_migration/prefix_tracker_script_configuration_id.ex@@ -33,7 +33,7 @@ defmodule Plausible.DataMigration.PrefixTrackerScriptConfigurationId dodefp process_batch(last_id, total_configs, batch_size, processed_count) doconfigs = get_configurations_batch(last_id, batch_size)- if length(configs) > 0 do+ if configs != [] dobatch_num = div(processed_count, batch_size) + 1start_pos = processed_count + 1end_pos = processed_count + length(configs)diff --git a/lib/plausible/helpers/config.ex b/lib/plausible/helpers/config.exindex ed5833bd08..5010cd501f 100644--- a/lib/plausible/helpers/config.ex+++ b/lib/plausible/helpers/config.ex@@ -1,4 +1,8 @@defmodule Plausible.ConfigHelpers do+ @moduledoc """+ Helpers for parsing configuration values from env.+ """+def get_var_from_path_or_env(config_dir, var_name, default \\ nil) dovar_path = Path.join(config_dir, var_name)diff --git a/lib/plausible/prom_ex.ex b/lib/plausible/prom_ex.exindex f2186e0206..f81255ef71 100644--- a/lib/plausible/prom_ex.ex+++ b/lib/plausible/prom_ex.ex@@ -1,4 +1,8 @@defmodule Plausible.PromEx do+ @moduledoc """+ Entry point for Prometheus metrics definitions and configuration.+ """+use PromEx, otp_app: :plausiblealias PromEx.Pluginsdiff --git a/lib/plausible/props.ex b/lib/plausible/props.exindex 5130c95f53..0dfadd1e42 100644--- a/lib/plausible/props.ex+++ b/lib/plausible/props.ex@@ -194,6 +194,6 @@ defmodule Plausible.Props doReturns whether the site has configured custom props or not."""def configured?(%Plausible.Site{allowed_event_props: allowed_event_props}) do- is_list(allowed_event_props) && length(allowed_event_props) > 0+ is_list(allowed_event_props) && allowed_event_props != []endenddiff --git a/lib/plausible/segments/segment.ex b/lib/plausible/segments/segment.exindex 1187714013..6f5c493fa4 100644--- a/lib/plausible/segments/segment.ex+++ b/lib/plausible/segments/segment.ex@@ -62,7 +62,7 @@ defmodule Plausible.Segments.Segment dodefp validate_segment_data_filters(%Ecto.Changeset{} = changeset) docase get_field(changeset, :segment_data) do- %{"filters" => filters} when is_list(filters) and length(filters) > 0 ->+ %{"filters" => filters} when is_list(filters) and filters != [] ->changeset_ ->diff --git a/lib/plausible/sentry/client.ex b/lib/plausible/sentry/client.exindex 7cbf28839a..52edf9e927 100644--- a/lib/plausible/sentry/client.ex+++ b/lib/plausible/sentry/client.ex@@ -1,4 +1,8 @@defmodule Plausible.Sentry.Client do+ @moduledoc """+ Custom HTTP client configuration for Sentry integration using Finch.+ """+@behaviour Sentry.HTTPClientdefguardp is_redirect(status) when is_integer(status) and status >= 300 and status < 400diff --git a/lib/plausible/session/salts.ex b/lib/plausible/session/salts.exindex a7fd2eca49..fc5a0e1655 100644--- a/lib/plausible/session/salts.ex+++ b/lib/plausible/session/salts.ex@@ -1,4 +1,8 @@defmodule Plausible.Session.Salts do+ @moduledoc """+ Genserver caching salts and managing their rotation.+ """+use GenServeruse Plausible.Repodiff --git a/lib/plausible/stats/base.ex b/lib/plausible/stats/base.exindex 68c9391846..163f6a418c 100644--- a/lib/plausible/stats/base.ex+++ b/lib/plausible/stats/base.ex@@ -1,4 +1,8 @@defmodule Plausible.Stats.Base do+ @moduledoc """+ Entry point functions for building stats queries.+ """+use Plausiblealias Plausible.Stats.{TableDecider, SQL}diff --git a/lib/plausible/stats/compare.ex b/lib/plausible/stats/compare.exindex e492b5deb0..851b18ef09 100644--- a/lib/plausible/stats/compare.ex+++ b/lib/plausible/stats/compare.ex@@ -1,4 +1,7 @@defmodule Plausible.Stats.Compare do+ @moduledoc """+ Helper functions for uniformly calculating percent changes of metrics.+ """def calculate_change(:conversion_rate, old_value, new_value) doFloat.round(new_value - old_value, 1)enddiff --git a/lib/plausible/stats/current_visitors.ex b/lib/plausible/stats/current_visitors.exindex 73b294ac4f..d968f2c24a 100644--- a/lib/plausible/stats/current_visitors.ex+++ b/lib/plausible/stats/current_visitors.ex@@ -1,4 +1,8 @@defmodule Plausible.Stats.CurrentVisitors do+ @moduledoc """+ API for querying current number of visitors for real-time stats.+ """+use Plausible.ClickhouseRepouse Plausible.Stats.SQL.Fragmentsdiff --git a/lib/plausible/stats/filter_suggestions.ex b/lib/plausible/stats/filter_suggestions.exindex e890c7f36b..461f2fa01f 100644--- a/lib/plausible/stats/filter_suggestions.ex+++ b/lib/plausible/stats/filter_suggestions.ex@@ -1,4 +1,8 @@defmodule Plausible.Stats.FilterSuggestions do+ @moduledoc """+ Functions for retrieving dashboard filters suggestions.+ """+use Plausible.Repouse Plausible.ClickhouseRepouse Plausible.Stats.SQL.Fragmentsdiff --git a/lib/plausible/stats/imported/base.ex b/lib/plausible/stats/imported/base.exindex 1580b9e42d..a8b485a252 100644--- a/lib/plausible/stats/imported/base.ex+++ b/lib/plausible/stats/imported/base.ex@@ -79,7 +79,7 @@ defmodule Plausible.Stats.Imported.Base docond do# Behavioral filters cannot be emulated via aggregated imported stats- length(behavioral_filters) > 0 ->+ behavioral_filters != [] ->[]custom_prop_query?(query) ->diff --git a/lib/plausible/stats/imported/imported.ex b/lib/plausible/stats/imported/imported.exindex 88a923e565..caf3e5ae80 100644--- a/lib/plausible/stats/imported/imported.ex+++ b/lib/plausible/stats/imported/imported.ex@@ -27,7 +27,7 @@ defmodule Plausible.Stats.Imported dofilter or the corresponding goal filter (see Plausible.Event.SystemEvents)."""def schema_supports_query?(query) do- length(Imported.Base.decide_tables(query)) > 0+ Imported.Base.decide_tables(query) != []enddef schema_supports_interval?(query) dodiff --git a/lib/plausible/stats/query_builder.ex b/lib/plausible/stats/query_builder.exindex 0784bac368..7658111e9c 100644--- a/lib/plausible/stats/query_builder.ex+++ b/lib/plausible/stats/query_builder.ex@@ -269,7 +269,7 @@ defmodule Plausible.Stats.QueryBuilder do|> Filters.dimensions_used_in_filters(min_depth: 1, behavioral_filters: :ignore)|> Enum.filter(&(&1 in @only_toplevel))- if Enum.count(not_toplevel) > 0 do+ if not_toplevel != [] do{:error,%QueryError{code: :invalid_filters,@@ -370,7 +370,7 @@ defmodule Plausible.Stats.QueryBuilder do_ -> []end)- if length(goal_filter_clauses) > 0 do+ if goal_filter_clauses != [] doconfigured_goal_names =query.preloaded_goals.all|> Enum.map(&Plausible.Goal.display_name/1)diff --git a/lib/plausible/stats/query_optimizer.ex b/lib/plausible/stats/query_optimizer.exindex f72d01ed5b..34b7762efa 100644--- a/lib/plausible/stats/query_optimizer.ex+++ b/lib/plausible/stats/query_optimizer.ex@@ -133,7 +133,7 @@ defmodule Plausible.Stats.QueryOptimizer doquery.filters|> Enum.filter(fn [_operation, dimension | _rest] -> dimension == "event:hostname" end)- if length(hostname_filters) > 0 do+ if hostname_filters != [] doextra_filters =query.dimensions|> Enum.flat_map(&hostname_filters_for_dimension(&1, hostname_filters))diff --git a/lib/plausible/themes.ex b/lib/plausible/themes.exindex 5772bfaa5d..0ea252896d 100644--- a/lib/plausible/themes.ex+++ b/lib/plausible/themes.ex@@ -1,4 +1,8 @@defmodule Plausible.Themes do+ @moduledoc """+ Site light/dark themes definitions.+ """+@options [[key: "Follow System Theme", value: "system"],[key: "Light", value: "light"],diff --git a/lib/plausible_web/plugs/feature_flag_check_plug.ex b/lib/plausible_web/plugs/feature_flag_check_plug.exindex c04e23e38d..68c3cd4d70 100644--- a/lib/plausible_web/plugs/feature_flag_check_plug.ex+++ b/lib/plausible_web/plugs/feature_flag_check_plug.ex@@ -4,7 +4,7 @@ defmodule PlausibleWeb.Plugs.FeatureFlagCheckPlug doto halt any API connections with 404 where conn.assigns.current_user or conn.assigns.sitedon't have both feature flags true."""- def init(feature_flags) when is_list(feature_flags) and length(feature_flags) > 0 do+ def init(feature_flags) when is_list(feature_flags) and feature_flags != [] dofeature_flagsenddiff --git a/lib/plausible_web/plugs/require_logged_out.ex b/lib/plausible_web/plugs/require_logged_out.exindex f1cd1d448a..aa917a2b60 100644--- a/lib/plausible_web/plugs/require_logged_out.ex+++ b/lib/plausible_web/plugs/require_logged_out.ex@@ -1,4 +1,8 @@defmodule PlausibleWeb.RequireLoggedOutPlug do+ @moduledoc """+ Plug forcibly logging user out if they are authenticated.+ """+import Plug.Conndef init(opts \\ []) dodiff --git a/lib/workers/clean_invitations.ex b/lib/workers/clean_invitations.exindex 84b9a99ef3..79b03ed659 100644--- a/lib/workers/clean_invitations.ex+++ b/lib/workers/clean_invitations.ex@@ -1,4 +1,8 @@defmodule Plausible.Workers.CleanInvitations do+ @moduledoc """+ Worker hoovering expired invitations.+ """+use Plausible.Repouse Oban.Worker, queue: :clean_invitationsdiff --git a/lib/workers/notify_annual_renewal.ex b/lib/workers/notify_annual_renewal.exindex 59b56305ab..4f73af93f2 100644--- a/lib/workers/notify_annual_renewal.ex+++ b/lib/workers/notify_annual_renewal.ex@@ -1,4 +1,8 @@defmodule Plausible.Workers.NotifyAnnualRenewal do+ @moduledoc """+ Worker sending emails about upcoming renewal of annual subscriptions.+ """+use Plausible.Repouse Oban.Worker, queue: :notify_annual_renewaldiff --git a/lib/workers/rotate_salts.ex b/lib/workers/rotate_salts.exindex 7bc0d1effa..bb30f289df 100644--- a/lib/workers/rotate_salts.ex+++ b/lib/workers/rotate_salts.ex@@ -1,4 +1,8 @@defmodule Plausible.Workers.RotateSalts do+ @moduledoc """+ Worker rotating session salts.+ """+use Plausible.Repouse Oban.Worker, queue: :rotate_saltsdiff --git a/lib/workers/send_check_stats_emails.ex b/lib/workers/send_check_stats_emails.exindex c0ec65da5f..a031702e9c 100644--- a/lib/workers/send_check_stats_emails.ex+++ b/lib/workers/send_check_stats_emails.ex@@ -1,4 +1,7 @@defmodule Plausible.Workers.SendCheckStatsEmails do+ @moduledoc """+ Worker sending reminders about checking status, provided they are collected already.+ """use Plausible.Repouse Oban.Worker, queue: :check_stats_emailsdiff --git a/lib/workers/send_email_report.ex b/lib/workers/send_email_report.exindex 89ce4f6e2f..c36e631741 100644--- a/lib/workers/send_email_report.ex+++ b/lib/workers/send_email_report.ex@@ -1,4 +1,8 @@defmodule Plausible.Workers.SendEmailReport do+ @moduledoc """+ Worker sending weekly and monthly email reports to subscribed users.+ """+use Plausibleuse Plausible.Repouse Oban.Worker, queue: :send_email_reports, max_attempts: 1diff --git a/lib/workers/set_legacy_time_on_page_cutoff.ex b/lib/workers/set_legacy_time_on_page_cutoff.exindex 391c58d91b..310b58e463 100644--- a/lib/workers/set_legacy_time_on_page_cutoff.ex+++ b/lib/workers/set_legacy_time_on_page_cutoff.ex@@ -22,7 +22,7 @@ defmodule Plausible.Workers.SetLegacyTimeOnPageCutoff doto_update = small_sites ++ large_sites- if length(to_update) > 0 do+ if to_update != [] doLogger.notice("Setting legacy_time_on_page_cutoff for #{length(to_update)} sites (#{length(small_sites)} small, #{length(large_sites)} large)")diff --git a/test/plausible/auth/user_test.exs b/test/plausible/auth/user_test.exsindex 8b3ba56635..eb24c40aa3 100644--- a/test/plausible/auth/user_test.exs+++ b/test/plausible/auth/user_test.exs@@ -78,7 +78,7 @@ defmodule Plausible.Auth.UserTest doassert score < 3assert warning != ""- assert length(suggestions) > 0+ assert suggestions != []endtest "checks for existing phrases using name and email from changes" dodiff --git a/test/plausible_web/views/stats_view_test.exs b/test/plausible_web/views/stats_view_test.exsindex adf11e8a6e..42b9287c68 100644--- a/test/plausible_web/views/stats_view_test.exs+++ b/test/plausible_web/views/stats_view_test.exs@@ -25,7 +25,7 @@ defmodule PlausibleWeb.StatsViewTest doendtest "wat" do- assert StatsView.large_number_format(49012) == "49k"+ assert StatsView.large_number_format(49_012) == "49k"endtest "999_999 becomes 999k" dodiff --git a/test/support/assert_matches.ex b/test/support/assert_matches.exindex c2f26c31d7..5500e95027 100644--- a/test/support/assert_matches.ex+++ b/test/support/assert_matches.ex@@ -116,7 +116,7 @@ defmodule Plausible.AssertMatches doassert unquote(var_pattern) = value- if unquote(length(pins) > 0) do+ if unquote(pins != []) do{errors?, predicate_pattern} = unquote(predicate_pattern)if errors? do