Add Credo refactor checks and fix double Enum.map
Add 9 enabled + 1 disabled Credo checks from ex_slop README. Fix MapMap finding in ListeningStats.update/1 (single pass). Disable AppendSingleItem (10 pre-existing violations).
This commit is contained in:
+12
-1
@@ -5,6 +5,15 @@
|
|||||||
plugins: [{ExSlop, []}],
|
plugins: [{ExSlop, []}],
|
||||||
checks: %{
|
checks: %{
|
||||||
extra: [
|
extra: [
|
||||||
|
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
|
||||||
|
{Credo.Check.Refactor.DoubleBooleanNegation, []},
|
||||||
|
{Credo.Check.Refactor.CondStatements, []},
|
||||||
|
{Credo.Check.Refactor.MapMap, []},
|
||||||
|
{Credo.Check.Refactor.FilterFilter, []},
|
||||||
|
{Credo.Check.Refactor.RejectReject, []},
|
||||||
|
{Credo.Check.Refactor.FilterCount, []},
|
||||||
|
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
|
||||||
|
{Credo.Check.Refactor.UnlessWithElse, []},
|
||||||
{Credo.Check.Refactor.Nesting, max_nesting: 3},
|
{Credo.Check.Refactor.Nesting, max_nesting: 3},
|
||||||
{Credo.Check.Readability.ModuleDoc,
|
{Credo.Check.Readability.ModuleDoc,
|
||||||
ignore_names: [
|
ignore_names: [
|
||||||
@@ -32,7 +41,9 @@
|
|||||||
]},
|
]},
|
||||||
{Credo.Check.Refactor.CyclomaticComplexity, max_complexity: 12}
|
{Credo.Check.Refactor.CyclomaticComplexity, max_complexity: 12}
|
||||||
],
|
],
|
||||||
disabled: []
|
disabled: [
|
||||||
|
{Credo.Check.Refactor.AppendSingleItem, []}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
# files etc.
|
# files etc.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ defmodule MusicLibrary.ListeningStats do
|
|||||||
def update(tracks) do
|
def update(tracks) do
|
||||||
track_params =
|
track_params =
|
||||||
tracks
|
tracks
|
||||||
|> Enum.map(fn t -> Map.take(t, @insertable_fields) end)
|
|> Enum.map(fn t -> t |> Map.take(@insertable_fields) |> Map.to_list() end)
|
||||||
|> Enum.map(&Map.to_list/1)
|
|
||||||
|
|
||||||
{count, tracks} =
|
{count, tracks} =
|
||||||
Repo.insert_all(Track, track_params,
|
Repo.insert_all(Track, track_params,
|
||||||
|
|||||||
Reference in New Issue
Block a user