Skip to content

Commit 6c92ed7

Browse files
committed
update c
1 parent 4d882c4 commit 6c92ed7

File tree

11 files changed

+53
-33
lines changed

11 files changed

+53
-33
lines changed

.credo.exs

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,7 @@
2121
# You can give explicit globs or simply directories.
2222
# In the latter case `**/*.{ex,exs}` will be used.
2323
#
24-
included: [
25-
"lib/",
26-
"src/",
27-
"test/",
28-
"web/",
29-
"apps/*/lib/",
30-
"apps/*/src/",
31-
"apps/*/test/",
32-
"apps/*/web/"
33-
],
24+
included: ["example/lib", "example/test", "lib/", "test/"],
3425
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
3526
},
3627
#
@@ -83,7 +74,11 @@
8374
# Priority values are: `low, normal, high, higher`
8475
#
8576
{Credo.Check.Design.AliasUsage,
86-
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
77+
[
78+
priority: :low,
79+
if_nested_deeper_than: 2,
80+
if_called_more_often_than: 0
81+
]},
8782
# You can also customize the exit_status of each check.
8883
# If you don't want TODO comments to cause `mix credo` to fail, just
8984
# set this value to 0 (zero).
@@ -97,7 +92,8 @@
9792
{Credo.Check.Readability.AliasOrder, []},
9893
{Credo.Check.Readability.FunctionNames, []},
9994
{Credo.Check.Readability.LargeNumbers, []},
100-
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 80]},
95+
{Credo.Check.Readability.MaxLineLength,
96+
[priority: :low, max_length: 80]},
10197
{Credo.Check.Readability.ModuleAttributeNames, []},
10298
{Credo.Check.Readability.ModuleDoc, []},
10399
{Credo.Check.Readability.ModuleNames, []},
@@ -131,6 +127,7 @@
131127
{Credo.Check.Refactor.Nesting, []},
132128
{Credo.Check.Refactor.UnlessWithElse, []},
133129
{Credo.Check.Refactor.WithClauses, []},
130+
{Credo.Check.Refactor.FilterCount, []},
134131
{Credo.Check.Refactor.FilterFilter, []},
135132
{Credo.Check.Refactor.RejectReject, []},
136133
{Credo.Check.Refactor.RedundantWithClauseResult, []},
@@ -140,9 +137,11 @@
140137
#
141138
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
142139
{Credo.Check.Warning.BoolOperationOnSameValues, []},
140+
{Credo.Check.Warning.Dbg, []},
143141
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
144142
{Credo.Check.Warning.IExPry, []},
145143
{Credo.Check.Warning.IoInspect, []},
144+
{Credo.Check.Warning.MissedMetadataKeyInLoggerConfig, []},
146145
{Credo.Check.Warning.OperationOnSameValues, []},
147146
{Credo.Check.Warning.OperationWithConstantResult, []},
148147
{Credo.Check.Warning.RaiseInsideRescue, []},
@@ -159,24 +158,18 @@
159158
{Credo.Check.Warning.UnsafeExec, []},
160159

161160
#
162-
## Controversial and experimental checks
161+
## Checks disabled by default
163162
#
164-
{Credo.Check.Consistency.UnusedVariableNames, []},
165-
{Credo.Check.Readability.ImplTrue, []},
166-
{Credo.Check.Readability.MultiAlias, []},
167-
{Credo.Check.Readability.SingleFunctionToBlockPipe, []},
163+
168164
{Credo.Check.Readability.SinglePipe, []},
169165
{Credo.Check.Readability.StrictModuleLayout, []},
170166
{Credo.Check.Readability.WithCustomTaggedTuple, []},
171167
{Credo.Check.Refactor.DoubleBooleanNegation, []},
172168
{Credo.Check.Refactor.FilterReject, []},
173169
{Credo.Check.Refactor.MapMap, []},
174-
{Credo.Check.Refactor.NegatedIsNil, []},
175170
{Credo.Check.Refactor.PipeChainStart, []},
176171
{Credo.Check.Refactor.RejectFilter, []},
177-
{Credo.Check.Refactor.VariableRebinding, []},
178-
{Credo.Check.Warning.MapGetUnsafePass, []},
179-
{Credo.Check.Warning.UnsafeToAtom, []}
172+
{Credo.Check.Warning.MapGetUnsafePass, []}
180173
],
181174
disabled: [
182175
#
@@ -187,19 +180,30 @@
187180
# and be sure to use `mix credo --strict` to see low priority checks)
188181
#
189182
{Credo.Check.Consistency.MultiAliasImportRequireUse, []},
183+
{Credo.Check.Consistency.UnusedVariableNames, []},
190184
{Credo.Check.Design.DuplicatedCode, []},
191185
{Credo.Check.Design.SkipTestWithoutComment, []},
192186
{Credo.Check.Readability.AliasAs, []},
187+
{Credo.Check.Readability.BlockPipe, []},
188+
{Credo.Check.Readability.ImplTrue, []},
189+
{Credo.Check.Readability.MultiAlias, []},
190+
{Credo.Check.Readability.NestedFunctionCalls, []},
191+
{Credo.Check.Readability.OneArityFunctionInPipe, []},
192+
{Credo.Check.Readability.OnePipePerLine, []},
193193
{Credo.Check.Readability.SeparateAliasRequire, []},
194+
{Credo.Check.Readability.SingleFunctionToBlockPipe, []},
194195
{Credo.Check.Readability.Specs, []},
195196
{Credo.Check.Refactor.ABCSize, []},
196197
{Credo.Check.Refactor.AppendSingleItem, []},
197198
{Credo.Check.Refactor.IoPuts, []},
198199
{Credo.Check.Refactor.ModuleDependencies, []},
200+
{Credo.Check.Refactor.NegatedIsNil, []},
201+
{Credo.Check.Refactor.PassAsyncInTestCases, []},
202+
{Credo.Check.Refactor.VariableRebinding, []},
199203
{Credo.Check.Warning.LazyLogging, []},
200204
{Credo.Check.Warning.LeakyEnvironment, []},
201205
{Credo.Check.Warning.MixEnv, []},
202-
206+
{Credo.Check.Warning.UnsafeToAtom, []}
203207

204208
# {Credo.Check.Refactor.MapInto, []},
205209

example/lib/nested/helpers.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
defmodule Nested.Helpers do
2+
@moduledoc """
3+
Defines a helper function for handling deletions of associations.
4+
"""
25
import Ecto.Changeset
36
alias Ecto.Changeset
47

example/lib/nested/members/owner.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
defmodule Nested.Members.Owner do
2+
@moduledoc """
3+
Schema for pet owners.
4+
"""
25
use Ecto.Schema
36
import Ecto.Changeset
47
alias Nested.Members.Pet

example/lib/nested/members/pet.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
defmodule Nested.Members.Pet do
2+
@moduledoc """
3+
Schema for pets, which are owned by owners.
4+
"""
25
use Ecto.Schema
36

47
import Ecto.Changeset

example/lib/nested/members/toy.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
defmodule Nested.Members.Toy do
2+
@moduledoc """
3+
Schema for toys, which are owned by pets.
4+
"""
25
use Ecto.Schema
36

47
import Ecto.Changeset

example/lib/nested_web/components/core_components.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ defmodule NestedWeb.CoreComponents do
1111
"""
1212
use Phoenix.Component
1313

14+
alias Phoenix.HTML.Form
1415
alias Phoenix.LiveView.JS
1516

1617
@doc """
@@ -360,7 +361,7 @@ defmodule NestedWeb.CoreComponents do
360361
def input(%{type: "checkbox", value: value} = assigns) do
361362
assigns =
362363
assign_new(assigns, :checked, fn ->
363-
Phoenix.HTML.Form.normalize_value("checkbox", value)
364+
Form.normalize_value("checkbox", value)
364365
end)
365366

366367
~H"""
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
defmodule NestedWeb.Layouts do
2+
@moduledoc """
3+
Defines the layouts for live views.
4+
"""
25
use NestedWeb, :html
36

4-
embed_templates "layouts/*"
7+
embed_templates("layouts/*")
58
end

example/lib/nested_web/telemetry.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
defmodule NestedWeb.Telemetry do
2+
@moduledoc false
23
use Supervisor
34
import Telemetry.Metrics
45

@@ -86,7 +87,8 @@ defmodule NestedWeb.Telemetry do
8687
defp periodic_measurements do
8788
[
8889
# A module, function and arguments to be invoked periodically.
89-
# This function must call :telemetry.execute/3 and a metric must be added above.
90+
# This function must call :telemetry.execute/3 and a metric must be added
91+
# above.
9092
# {NestedWeb, :count_users, []}
9193
]
9294
end

example/test/support/data_case.ex

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ defmodule Nested.DataCase do
1616

1717
use ExUnit.CaseTemplate
1818

19+
alias Ecto.Adapters.SQL
20+
1921
using do
2022
quote do
2123
alias Nested.Repo
@@ -36,12 +38,8 @@ defmodule Nested.DataCase do
3638
Sets up the sandbox based on the test tags.
3739
"""
3840
def setup_sandbox(tags) do
39-
pid =
40-
Ecto.Adapters.SQL.Sandbox.start_owner!(Nested.Repo,
41-
shared: not tags[:async]
42-
)
43-
44-
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
41+
pid = SQL.Sandbox.start_owner!(Nested.Repo, shared: not tags[:async])
42+
on_exit(fn -> SQL.Sandbox.stop_owner(pid) end)
4543
end
4644

4745
@doc """

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ defmodule EctoNestedChangeset.MixProject do
4141
# Run "mix help deps" to learn about dependencies.
4242
defp deps do
4343
[
44-
{:credo, "~> 1.6.0", only: [:dev, :test], runtime: false},
44+
{:credo, "~> 1.7.0", only: [:dev, :test], runtime: false},
4545
{:dialyxir, "~> 1.2.0", only: [:dev], runtime: false},
4646
{:ecto, "~> 3.7"},
4747
{:ecto_sql, "~> 3.7", only: :test},

0 commit comments

Comments
 (0)