Skip to content

Commit 0432a90

Browse files
authored
fix: Replace credo with styler (#170)
Contrary to [Credo](https://github.com/rrrene/credo), which requires manual intervention, [Styler](https://github.com/adobe/elixir-styler) applies changes and fixes automatically. I've also synced the minimum supported Elixir version in the mix project and in Styler. This means that Styler won't apply some rewrites (such as `to_timeout`) until the project supports Elixir 1.17 or newer only.
1 parent 74328ba commit 0432a90

34 files changed

+144
-354
lines changed

.credo.exs

Lines changed: 0 additions & 217 deletions
This file was deleted.

.formatter.exs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
# Used by "mix format"
22
locals_without_parens = [error_tracker_dashboard: 1, error_tracker_dashboard: 2]
33

4+
# Parse SemVer minor elixir version from project configuration
5+
# eg `"~> 1.15"` version requirement will yield `"1.15"`
6+
[elixir_minor_version | _] = Regex.run(~r/([\d\.]+)/, Mix.Project.config()[:elixir])
7+
48
[
59
import_deps: [:ecto, :ecto_sql, :plug, :phoenix],
610
inputs: ["{mix,.formatter,dev,dev.*}.exs", "{config,lib,test}/**/*.{heex,ex,exs}"],
7-
plugins: [Phoenix.LiveView.HTMLFormatter],
11+
plugins: [Phoenix.LiveView.HTMLFormatter, Styler],
812
locals_without_parens: locals_without_parens,
9-
export: [locals_without_parens: locals_without_parens]
13+
export: [locals_without_parens: locals_without_parens],
14+
styler: [
15+
minimum_supported_elixir_version: "#{elixir_minor_version}.0"
16+
]
1017
]

.github/workflows/elixir.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ jobs:
8585
- name: Check application compile warnings
8686
run: mix compile --force --warnings-as-errors
8787

88-
- name: Check Credo warnings
89-
run: mix credo
90-
9188
- name: Run Tests - SQLite3
9289
run: mix test
9390
env:

config/dev.example.exs

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
import Config
22

3-
config :tailwind,
4-
version: "3.4.3",
5-
default: [
6-
args: ~w(
7-
--config=tailwind.config.js
8-
--input=css/app.css
9-
--output=../priv/static/app.css
10-
),
11-
cd: Path.expand("../assets", __DIR__)
12-
]
13-
143
config :bun,
154
version: "1.1.18",
165
default: [
@@ -19,32 +8,40 @@ config :bun,
198
env: %{}
209
]
2110

22-
# PostgreSQL adapter
23-
#
24-
# To use SQLite3 on your local development machine uncomment these lines and
25-
# comment the lines of other adapters.
26-
27-
config :error_tracker, :ecto_adapter, :postgres
28-
29-
config :error_tracker, ErrorTrackerDev.Repo,
30-
url: "ecto://postgres:postgres@127.0.0.1/error_tracker_dev"
31-
3211
# MySQL/MariaDB adapter
3312
#
3413
# To use MySQL/MariaDB on your local development machine uncomment these lines and
3514
# comment the lines of other adapters.
36-
15+
#
3716
# config :error_tracker, :ecto_adapter, :mysql
38-
17+
#
3918
# config :error_tracker, ErrorTrackerDev.Repo,
4019
# url: "ecto://root:root@127.0.0.1/error_tracker_dev"
41-
20+
#
4221
# SQLite3 adapter
4322
#
4423
# To use SQLite3 on your local development machine uncomment these lines and
4524
# comment the lines of other adapters.
46-
25+
#
4726
# config :error_tracker, :ecto_adapter, :sqlite3
48-
27+
#
4928
# config :error_tracker, ErrorTrackerDev.Repo,
5029
# database: System.get_env("SQLITE_DB") || "dev.db"
30+
#
31+
# PostgreSQL adapter
32+
#
33+
# To use PostgreSQL on your local development machine uncomment these lines and
34+
# comment the lines of other adapters.
35+
config :error_tracker, ErrorTrackerDev.Repo, url: "ecto://postgres:postgres@127.0.0.1/error_tracker_dev"
36+
config :error_tracker, :ecto_adapter, :postgres
37+
38+
config :tailwind,
39+
version: "3.4.3",
40+
default: [
41+
args: ~w(
42+
--config=tailwind.config.js
43+
--input=css/app.css
44+
--output=../priv/static/app.css
45+
),
46+
cd: Path.expand("../assets", __DIR__)
47+
]

config/test.example.exs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
import Config
22

3-
config :error_tracker, ErrorTracker.Test.Repo,
4-
url: "ecto://postgres:postgres@127.0.0.1/error_tracker_test",
5-
pool: Ecto.Adapters.SQL.Sandbox,
6-
log: false
3+
alias Ecto.Adapters.SQL.Sandbox
4+
alias ErrorTracker.Test.Repo
75

8-
config :error_tracker, ErrorTracker.Test.MySQLRepo,
9-
url: "ecto://root:root@127.0.0.1/error_tracker_test",
10-
pool: Ecto.Adapters.SQL.Sandbox,
6+
config :error_tracker, ErrorTracker.Test.LiteRepo,
7+
database: "priv/lite_repo/test.db",
8+
pool: Sandbox,
119
log: false,
1210
# Use the same migrations as the PostgreSQL repo
1311
priv: "priv/repo"
1412

15-
config :error_tracker, ErrorTracker.Test.LiteRepo,
16-
database: "priv/lite_repo/test.db",
17-
pool: Ecto.Adapters.SQL.Sandbox,
13+
config :error_tracker, ErrorTracker.Test.MySQLRepo,
14+
url: "ecto://root:root@127.0.0.1/error_tracker_test",
15+
pool: Sandbox,
1816
log: false,
1917
# Use the same migrations as the PostgreSQL repo
2018
priv: "priv/repo"
2119

22-
config :error_tracker, ecto_repos: [ErrorTracker.Test.Repo]
20+
config :error_tracker, Repo,
21+
url: "ecto://postgres:postgres@127.0.0.1/error_tracker_test",
22+
pool: Sandbox,
23+
log: false
24+
25+
config :error_tracker, ecto_repos: [Repo]
2326

2427
# Repo is selected in the test_helper.exs based on the given ENV vars
2528
config :error_tracker, otp_app: :error_tracker

0 commit comments

Comments
 (0)