Skip to content

Commit 5dbf661

Browse files
committed
update dependencies, tasks, run format
1 parent b7fcb96 commit 5dbf661

10 files changed

Lines changed: 171 additions & 181 deletions

File tree

.credo.exs

Lines changed: 119 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -53,128 +53,131 @@
5353
#
5454
# To disable a check put `false` as second element:
5555
#
56-
# {Credo.Check.Design.DuplicatedCode, false}
57-
#
58-
checks: [
59-
#
60-
## Consistency Checks
61-
#
62-
{Credo.Check.Consistency.ExceptionNames, []},
63-
{Credo.Check.Consistency.LineEndings, []},
64-
{Credo.Check.Consistency.ParameterPatternMatching, []},
65-
{Credo.Check.Consistency.SpaceAroundOperators, []},
66-
{Credo.Check.Consistency.SpaceInParentheses, []},
67-
{Credo.Check.Consistency.TabsOrSpaces, []},
56+
# {Credo.Check.Design.DuplicatedCode,[]}
57+
#
58+
checks: %{
59+
enabled: [
60+
#
61+
## Consistency Checks
62+
#
63+
{Credo.Check.Consistency.ExceptionNames, []},
64+
{Credo.Check.Consistency.LineEndings, []},
65+
{Credo.Check.Consistency.ParameterPatternMatching, []},
66+
{Credo.Check.Consistency.SpaceAroundOperators, []},
67+
{Credo.Check.Consistency.SpaceInParentheses, []},
68+
{Credo.Check.Consistency.TabsOrSpaces, []},
6869

69-
#
70-
## Design Checks
71-
#
72-
# You can customize the priority of any check
73-
# Priority values are: `low, normal, high, higher`
74-
#
75-
{Credo.Check.Design.AliasUsage,
76-
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
77-
# You can also customize the exit_status of each check.
78-
# If you don't want TODO comments to cause `mix credo` to fail, just
79-
# set this value to 0 (zero).
80-
#
81-
{Credo.Check.Design.TagTODO, [exit_status: 0]},
82-
{Credo.Check.Design.TagFIXME, []},
70+
#
71+
## Design Checks
72+
#
73+
# You can customize the priority of any check
74+
# Priority values are: `low, normal, high, higher`
75+
#
76+
{Credo.Check.Design.AliasUsage,
77+
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
78+
# You can also customize the exit_status of each check.
79+
# If you don't want TODO comments to cause `mix credo` to fail, just
80+
# set this value to 0 (zero).
81+
#
82+
{Credo.Check.Design.TagTODO, [exit_status: 0]},
83+
{Credo.Check.Design.TagFIXME, []},
8384

84-
#
85-
## Readability Checks
86-
#
87-
{Credo.Check.Readability.AliasOrder, []},
88-
{Credo.Check.Readability.FunctionNames, []},
89-
{Credo.Check.Readability.LargeNumbers, []},
90-
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
91-
{Credo.Check.Readability.ModuleAttributeNames, []},
92-
{Credo.Check.Readability.ModuleDoc, []},
93-
{Credo.Check.Readability.ModuleNames, []},
94-
{Credo.Check.Readability.ParenthesesInCondition, []},
95-
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
96-
{Credo.Check.Readability.PredicateFunctionNames, []},
97-
{Credo.Check.Readability.PreferImplicitTry, []},
98-
{Credo.Check.Readability.RedundantBlankLines, []},
99-
{Credo.Check.Readability.Semicolons, []},
100-
{Credo.Check.Readability.SpaceAfterCommas, []},
101-
{Credo.Check.Readability.StringSigils, []},
102-
{Credo.Check.Readability.TrailingBlankLine, []},
103-
{Credo.Check.Readability.TrailingWhiteSpace, []},
104-
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
105-
{Credo.Check.Readability.VariableNames, []},
85+
#
86+
## Readability Checks
87+
#
88+
{Credo.Check.Readability.AliasOrder, []},
89+
{Credo.Check.Readability.FunctionNames, []},
90+
{Credo.Check.Readability.LargeNumbers, []},
91+
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
92+
{Credo.Check.Readability.ModuleAttributeNames, []},
93+
{Credo.Check.Readability.ModuleDoc, []},
94+
{Credo.Check.Readability.ModuleNames, []},
95+
{Credo.Check.Readability.ParenthesesInCondition, []},
96+
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
97+
{Credo.Check.Readability.PredicateFunctionNames, []},
98+
{Credo.Check.Readability.PreferImplicitTry, []},
99+
{Credo.Check.Readability.RedundantBlankLines, []},
100+
{Credo.Check.Readability.Semicolons, []},
101+
{Credo.Check.Readability.SpaceAfterCommas, []},
102+
{Credo.Check.Readability.StringSigils, []},
103+
{Credo.Check.Readability.TrailingBlankLine, []},
104+
{Credo.Check.Readability.TrailingWhiteSpace, []},
105+
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
106+
{Credo.Check.Readability.VariableNames, []},
106107

107-
#
108-
## Refactoring Opportunities
109-
#
110-
{Credo.Check.Refactor.CondStatements, []},
111-
{Credo.Check.Refactor.CyclomaticComplexity, []},
112-
{Credo.Check.Refactor.FunctionArity, []},
113-
{Credo.Check.Refactor.LongQuoteBlocks, []},
114-
# {Credo.Check.Refactor.MapInto, []},
115-
{Credo.Check.Refactor.MatchInCondition, []},
116-
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
117-
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
118-
{Credo.Check.Refactor.Nesting, []},
119-
{Credo.Check.Refactor.UnlessWithElse, []},
120-
{Credo.Check.Refactor.WithClauses, []},
108+
#
109+
## Refactoring Opportunities
110+
#
111+
{Credo.Check.Refactor.CondStatements, []},
112+
{Credo.Check.Refactor.CyclomaticComplexity, []},
113+
{Credo.Check.Refactor.FunctionArity, []},
114+
{Credo.Check.Refactor.LongQuoteBlocks, []},
115+
# {Credo.Check.Refactor.MapInto, []},
116+
{Credo.Check.Refactor.MatchInCondition, []},
117+
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
118+
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
119+
{Credo.Check.Refactor.Nesting, []},
120+
{Credo.Check.Refactor.UnlessWithElse, []},
121+
{Credo.Check.Refactor.WithClauses, []},
121122

122-
#
123-
## Warnings
124-
#
125-
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
126-
{Credo.Check.Warning.BoolOperationOnSameValues, []},
127-
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
128-
{Credo.Check.Warning.IExPry, []},
129-
{Credo.Check.Warning.IoInspect, []},
130-
# {Credo.Check.Warning.LazyLogging, []},
131-
{Credo.Check.Warning.MixEnv, false},
132-
{Credo.Check.Warning.OperationOnSameValues, []},
133-
{Credo.Check.Warning.OperationWithConstantResult, []},
134-
{Credo.Check.Warning.RaiseInsideRescue, []},
135-
{Credo.Check.Warning.UnusedEnumOperation, []},
136-
{Credo.Check.Warning.UnusedFileOperation, []},
137-
{Credo.Check.Warning.UnusedKeywordOperation, []},
138-
{Credo.Check.Warning.UnusedListOperation, []},
139-
{Credo.Check.Warning.UnusedPathOperation, []},
140-
{Credo.Check.Warning.UnusedRegexOperation, []},
141-
{Credo.Check.Warning.UnusedStringOperation, []},
142-
{Credo.Check.Warning.UnusedTupleOperation, []},
143-
{Credo.Check.Warning.UnsafeExec, []},
123+
#
124+
## Warnings
125+
#
126+
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
127+
{Credo.Check.Warning.BoolOperationOnSameValues, []},
128+
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
129+
{Credo.Check.Warning.IExPry, []},
130+
{Credo.Check.Warning.IoInspect, []},
131+
# {Credo.Check.Warning.LazyLogging, []},
132+
{Credo.Check.Warning.OperationOnSameValues, []},
133+
{Credo.Check.Warning.OperationWithConstantResult, []},
134+
{Credo.Check.Warning.RaiseInsideRescue, []},
135+
{Credo.Check.Warning.UnusedEnumOperation, []},
136+
{Credo.Check.Warning.UnusedFileOperation, []},
137+
{Credo.Check.Warning.UnusedKeywordOperation, []},
138+
{Credo.Check.Warning.UnusedListOperation, []},
139+
{Credo.Check.Warning.UnusedPathOperation, []},
140+
{Credo.Check.Warning.UnusedRegexOperation, []},
141+
{Credo.Check.Warning.UnusedStringOperation, []},
142+
{Credo.Check.Warning.UnusedTupleOperation, []},
143+
{Credo.Check.Warning.UnsafeExec, []}
144144

145-
#
146-
# Checks scheduled for next check update (opt-in for now, just replace `false` with `[]`)
145+
#
146+
# Checks scheduled for next check update (opt-in for now, just replace `false` with `[]`)
147147

148-
#
149-
# Controversial and experimental checks (opt-in, just replace `false` with `[]`)
150-
#
151-
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
152-
{Credo.Check.Consistency.UnusedVariableNames, false},
153-
{Credo.Check.Design.DuplicatedCode, false},
154-
{Credo.Check.Readability.AliasAs, false},
155-
{Credo.Check.Readability.BlockPipe, false},
156-
{Credo.Check.Readability.ImplTrue, false},
157-
{Credo.Check.Readability.MultiAlias, false},
158-
{Credo.Check.Readability.SeparateAliasRequire, false},
159-
{Credo.Check.Readability.SinglePipe, false},
160-
{Credo.Check.Readability.Specs, false},
161-
{Credo.Check.Readability.StrictModuleLayout, false},
162-
{Credo.Check.Readability.WithCustomTaggedTuple, false},
163-
{Credo.Check.Refactor.ABCSize, false},
164-
{Credo.Check.Refactor.AppendSingleItem, false},
165-
{Credo.Check.Refactor.DoubleBooleanNegation, false},
166-
{Credo.Check.Refactor.ModuleDependencies, false},
167-
{Credo.Check.Refactor.NegatedIsNil, false},
168-
{Credo.Check.Refactor.PipeChainStart, false},
169-
{Credo.Check.Refactor.VariableRebinding, false},
170-
{Credo.Check.Warning.LeakyEnvironment, false},
171-
{Credo.Check.Warning.MapGetUnsafePass, false},
172-
{Credo.Check.Warning.UnsafeToAtom, false}
173-
174-
#
175-
# Custom checks can be created using `mix credo.gen.check`.
176-
#
177-
]
148+
#
149+
# Custom checks can be created using `mix credo.gen.check`.
150+
#
151+
],
152+
disabled: [
153+
{Credo.Check.Warning.MixEnv, []},
154+
#
155+
# Controversial and experimental checks (opt-in, just replace `false` with `[]`)
156+
#
157+
{Credo.Check.Consistency.MultiAliasImportRequireUse, []},
158+
{Credo.Check.Consistency.UnusedVariableNames, []},
159+
{Credo.Check.Design.DuplicatedCode, []},
160+
{Credo.Check.Readability.AliasAs, []},
161+
{Credo.Check.Readability.BlockPipe, []},
162+
{Credo.Check.Readability.ImplTrue, []},
163+
{Credo.Check.Readability.MultiAlias, []},
164+
{Credo.Check.Readability.SeparateAliasRequire, []},
165+
{Credo.Check.Readability.SinglePipe, []},
166+
{Credo.Check.Readability.Specs, []},
167+
{Credo.Check.Readability.StrictModuleLayout, []},
168+
{Credo.Check.Readability.WithCustomTaggedTuple, []},
169+
{Credo.Check.Refactor.ABCSize, []},
170+
{Credo.Check.Refactor.AppendSingleItem, []},
171+
{Credo.Check.Refactor.DoubleBooleanNegation, []},
172+
{Credo.Check.Refactor.ModuleDependencies, []},
173+
{Credo.Check.Refactor.NegatedIsNil, []},
174+
{Credo.Check.Refactor.PipeChainStart, []},
175+
{Credo.Check.Refactor.VariableRebinding, []},
176+
{Credo.Check.Warning.LeakyEnvironment, []},
177+
{Credo.Check.Warning.MapGetUnsafePass, []},
178+
{Credo.Check.Warning.UnsafeToAtom, []}
179+
]
180+
}
178181
}
179182
]
180183
}

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ knigge-*.tar
2525
# Ignore the version file as it gets generated by CI
2626
/version
2727

28-
# Ignore the dialyzer PLTs
29-
/.dialyzer/
28+
# Ignore ElixirLS
29+
.elixir_ls/

lib/knigge/code.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ defmodule Knigge.Code do
5555
Warn.definition_matching_callback(module, callback)
5656

5757
has_default?(defaults, callback) ->
58-
unless callback in optional_callbacks do
58+
if callback not in optional_callbacks do
5959
Error.default_for_required_callback!(env)
6060
end
6161

lib/knigge/module.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Knigge.Module do
44
module = inspect(__MODULE__)
55

66
def ensure_exists!(module, env) do
7-
unless Knigge.Module.exists?(module) do
7+
if !Knigge.Module.exists?(module) do
88
Knigge.Error.module_not_loaded!(module, env)
99
end
1010

lib/knigge/options.ex

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ defmodule Knigge.Options do
5454
- `[only: <envs>]` - equivalent to the option above
5555
- `[except: <envs>]` - only delegates at runtime if the current environment is __not__ contained in the list
5656
57-
__Default__: `Application.get_env(:knigge, :delegate_at_runtime?, #{
58-
inspect(@defaults[:delegate_at_runtime?])
59-
})`
57+
__Default__: `Application.get_env(:knigge, :delegate_at_runtime?, #{inspect(@defaults[:delegate_at_runtime?])})`
6058
6159
### `do_not_delegate`
6260
A keyword list defining callbacks for which no delegation should happen.
@@ -156,9 +154,7 @@ defmodule Knigge.Options do
156154

157155
message when is_binary(message) ->
158156
IO.warn(
159-
"Knigge encountered the deprecated option `#{key}`, this option is no longer supported; #{
160-
message
161-
}."
157+
"Knigge encountered the deprecated option `#{key}`, this option is no longer supported; #{message}."
162158
)
163159

164160
nil
@@ -178,13 +174,7 @@ defmodule Knigge.Options do
178174

179175
@doc """
180176
Applies the defaults to the given options:
181-
#{
182-
@defaults
183-
|> Enum.map(fn {key, value} ->
184-
" - #{key} = #{inspect(value)}"
185-
end)
186-
|> Enum.join("\n")
187-
}
177+
#{@defaults |> Enum.map(fn {key, value} -> " - #{key} = #{inspect(value)}" end) |> Enum.join("\n")}
188178
"""
189179
@spec with_defaults(raw()) :: raw()
190180
def with_defaults(opts) do
@@ -261,7 +251,7 @@ defmodule Knigge.Options do
261251
end
262252

263253
defp validate_keyword!(opts) do
264-
unless keyword?(opts) do
254+
if !keyword?(opts) do
265255
raise ArgumentError,
266256
"Knigge expects a keyword list as options, instead received: #{inspect(opts)}"
267257
end

lib/knigge/verification/context.ex

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,21 @@ defmodule Knigge.Verification.Context do
9595

9696
defp ensure_loaded(app) do
9797
case Application.load(app) do
98-
:ok -> :ok
99-
{:error, {:already_loaded, ^app}} -> :ok
100-
{:error, {'no such file or directory', _}} -> {:error, {:unknown_app, app}}
101-
{:error, :undefined} -> {:error, {:unknown_app, app}}
102-
other -> other
98+
:ok ->
99+
:ok
100+
101+
{:error, {:already_loaded, ^app}} ->
102+
:ok
103+
104+
{:error, {reason, _}}
105+
when reason in ["no such file or directory", ~c"no such file or directory"] ->
106+
{:error, {:unknown_app, app}}
107+
108+
{:error, :undefined} ->
109+
{:error, {:unknown_app, app}}
110+
111+
other ->
112+
other
103113
end
104114
end
105115

lib/knigge/warnings.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ defmodule Knigge.Warnings do
2727
2828
There are two ways to resolve this warning:
2929
1. move the behaviour into a separate module and `use Knigge, behaviour: MyBehaviour`;
30-
this enables to compiler to finish compilation of `#{inspect(implementation)}` before compiling `#{
31-
inspect(module)
32-
}`
30+
this enables to compiler to finish compilation of `#{inspect(implementation)}` before compiling `#{inspect(module)}`
3331
2. pass `delegate_at_runtime?: true` as option, this will move **all** delegation to runtime
3432
""")
3533
end

0 commit comments

Comments
 (0)