Skip to content

Commit 37a911c

Browse files
Updates repo (#738)
1 parent 8e9bafb commit 37a911c

13 files changed

Lines changed: 220 additions & 155 deletions

.credo.exs

Lines changed: 155 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,41 @@
1010
configs: [
1111
%{
1212
#
13-
# Run any exec using `mix credo -C <name>`. If no exec name is given
13+
# Run any config using `mix credo -C <name>`. If no config name is given
1414
# "default" is used.
15+
#
1516
name: "default",
1617
#
1718
# These are the files included in the analysis:
1819
files: %{
1920
#
2021
# You can give explicit globs or simply directories.
2122
# In the latter case `**/*.{ex,exs}` will be used.
22-
included: ["lib/", "src/", "web/", "apps/"],
23+
included: ["config/", "lib/", "test/"],
2324
excluded: [~r"/_build/", ~r"/deps/"]
2425
},
2526
#
27+
# Load and configure plugins here:
28+
#
29+
plugins: [],
30+
#
2631
# If you create your own checks, you must specify the source files for
2732
# them here, so they can be loaded by Credo before running the analysis.
28-
requires: [],
2933
#
30-
# Credo automatically checks for updates, like e.g. Hex does.
31-
# You can disable this behaviour below:
32-
check_for_updates: true,
34+
requires: [],
3335
#
3436
# If you want to enforce a style guide and need a more traditional linting
3537
# experience, you can change `strict` to `true` below:
38+
#
3639
strict: false,
3740
#
41+
# To modify the timeout for parsing files, change this value:
42+
#
43+
parse_timeout: 5000,
44+
#
3845
# If you want to use uncolored output by default, you can change `color`
3946
# to `false` below:
47+
#
4048
color: true,
4149
#
4250
# You can customize the parameters of any check by adding a second element
@@ -46,106 +54,153 @@
4654
#
4755
# {Credo.Check.Design.DuplicatedCode, false}
4856
#
49-
checks: [
50-
#
51-
## Consistency Checks
52-
#
53-
{Credo.Check.Consistency.ExceptionNames, []},
54-
{Credo.Check.Consistency.LineEndings, []},
55-
{Credo.Check.Consistency.ParameterPatternMatching, []},
56-
{Credo.Check.Consistency.SpaceAroundOperators, []},
57-
{Credo.Check.Consistency.SpaceInParentheses, []},
58-
{Credo.Check.Consistency.TabsOrSpaces, []},
57+
checks: %{
58+
enabled: [
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, []},
5968

60-
#
61-
## Design Checks
62-
#
63-
# You can customize the priority of any check
64-
# Priority values are: `low, normal, high, higher`
65-
#
66-
{Credo.Check.Design.AliasUsage,
67-
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 1]},
68-
# You can also customize the exit_status of each check.
69-
# If you don't want TODO comments to cause `mix credo` to fail, just
70-
# set this value to 0 (zero).
71-
#
72-
{Credo.Check.Design.TagTODO, [exit_status: 2]},
73-
{Credo.Check.Design.TagFIXME, []},
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, [priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
76+
{Credo.Check.Design.TagFIXME, []},
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: 2]},
7482

75-
#
76-
## Readability Checks
77-
#
78-
{Credo.Check.Readability.AliasOrder, []},
79-
{Credo.Check.Readability.FunctionNames, []},
80-
{Credo.Check.Readability.LargeNumbers, []},
81-
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
82-
{Credo.Check.Readability.ModuleAttributeNames, []},
83-
{Credo.Check.Readability.ModuleDoc, []},
84-
{Credo.Check.Readability.ModuleNames, []},
85-
{Credo.Check.Readability.ParenthesesInCondition, []},
86-
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
87-
{Credo.Check.Readability.PredicateFunctionNames, []},
88-
{Credo.Check.Readability.PreferImplicitTry, []},
89-
{Credo.Check.Readability.RedundantBlankLines, []},
90-
{Credo.Check.Readability.Semicolons, []},
91-
{Credo.Check.Readability.SpaceAfterCommas, []},
92-
{Credo.Check.Readability.StringSigils, []},
93-
{Credo.Check.Readability.TrailingBlankLine, []},
94-
{Credo.Check.Readability.TrailingWhiteSpace, []},
95-
{Credo.Check.Readability.VariableNames, []},
83+
#
84+
## Readability Checks
85+
#
86+
{Credo.Check.Readability.AliasOrder, []},
87+
{Credo.Check.Readability.FunctionNames, []},
88+
{Credo.Check.Readability.LargeNumbers, []},
89+
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
90+
{Credo.Check.Readability.ModuleAttributeNames, []},
91+
{Credo.Check.Readability.ModuleDoc, false},
92+
{Credo.Check.Readability.ModuleNames, []},
93+
{Credo.Check.Readability.ParenthesesInCondition, []},
94+
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
95+
{Credo.Check.Readability.PipeIntoAnonymousFunctions, []},
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, []},
106+
{Credo.Check.Readability.WithSingleClause, []},
96107

97-
#
98-
## Refactoring Opportunities
99-
#
100-
{Credo.Check.Refactor.CondStatements, []},
101-
{Credo.Check.Refactor.CyclomaticComplexity, []},
102-
{Credo.Check.Refactor.FunctionArity, []},
103-
{Credo.Check.Refactor.LongQuoteBlocks, []},
104-
{Credo.Check.Refactor.MapInto, []},
105-
{Credo.Check.Refactor.MatchInCondition, []},
106-
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
107-
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
108-
{Credo.Check.Refactor.Nesting, []},
109-
{Credo.Check.Refactor.PipeChainStart,
110-
[excluded_argument_types: [:atom, :binary, :fn, :keyword], excluded_functions: []]},
111-
{Credo.Check.Refactor.UnlessWithElse, []},
108+
#
109+
## Refactoring Opportunities
110+
#
111+
{Credo.Check.Refactor.Apply, []},
112+
{Credo.Check.Refactor.CondStatements, []},
113+
{Credo.Check.Refactor.CyclomaticComplexity, []},
114+
{Credo.Check.Refactor.FilterCount, []},
115+
{Credo.Check.Refactor.FilterFilter, []},
116+
{Credo.Check.Refactor.FunctionArity, []},
117+
{Credo.Check.Refactor.LongQuoteBlocks, []},
118+
{Credo.Check.Refactor.MapJoin, []},
119+
{Credo.Check.Refactor.MatchInCondition, []},
120+
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
121+
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
122+
{Credo.Check.Refactor.Nesting, []},
123+
{Credo.Check.Refactor.RedundantWithClauseResult, []},
124+
{Credo.Check.Refactor.RejectReject, []},
125+
{Credo.Check.Refactor.UnlessWithElse, []},
126+
{Credo.Check.Refactor.WithClauses, []},
112127

113-
#
114-
## Warnings
115-
#
116-
{Credo.Check.Warning.BoolOperationOnSameValues, []},
117-
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
118-
{Credo.Check.Warning.IExPry, []},
119-
{Credo.Check.Warning.IoInspect, []},
120-
{Credo.Check.Warning.LazyLogging, []},
121-
{Credo.Check.Warning.OperationOnSameValues, []},
122-
{Credo.Check.Warning.OperationWithConstantResult, []},
123-
{Credo.Check.Warning.RaiseInsideRescue, []},
124-
{Credo.Check.Warning.UnusedEnumOperation, []},
125-
{Credo.Check.Warning.UnusedFileOperation, []},
126-
{Credo.Check.Warning.UnusedKeywordOperation, []},
127-
{Credo.Check.Warning.UnusedListOperation, []},
128-
{Credo.Check.Warning.UnusedPathOperation, []},
129-
{Credo.Check.Warning.UnusedRegexOperation, []},
130-
{Credo.Check.Warning.UnusedStringOperation, []},
131-
{Credo.Check.Warning.UnusedTupleOperation, []},
128+
#
129+
## Warnings
130+
#
131+
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
132+
{Credo.Check.Warning.BoolOperationOnSameValues, []},
133+
{Credo.Check.Warning.Dbg, []},
134+
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
135+
{Credo.Check.Warning.IExPry, []},
136+
{Credo.Check.Warning.IoInspect, []},
137+
{Credo.Check.Warning.MissedMetadataKeyInLoggerConfig, []},
138+
{Credo.Check.Warning.OperationOnSameValues, []},
139+
{Credo.Check.Warning.OperationWithConstantResult, []},
140+
{Credo.Check.Warning.RaiseInsideRescue, []},
141+
{Credo.Check.Warning.SpecWithStruct, []},
142+
{Credo.Check.Warning.UnsafeExec, []},
143+
{Credo.Check.Warning.UnusedEnumOperation, []},
144+
{Credo.Check.Warning.UnusedFileOperation, []},
145+
{Credo.Check.Warning.UnusedKeywordOperation, []},
146+
{Credo.Check.Warning.UnusedListOperation, []},
147+
{Credo.Check.Warning.UnusedPathOperation, []},
148+
{Credo.Check.Warning.UnusedRegexOperation, []},
149+
{Credo.Check.Warning.UnusedStringOperation, []},
150+
{Credo.Check.Warning.UnusedTupleOperation, []},
151+
{Credo.Check.Warning.WrongTestFileExtension, []}
152+
],
153+
disabled: [
154+
#
155+
# Checks scheduled for next check update (opt-in for now)
156+
{Credo.Check.Refactor.UtcNowTruncate, []},
132157

133-
#
134-
# Controversial and experimental checks (opt-in, just remove `, false`)
135-
#
136-
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
137-
{Credo.Check.Design.DuplicatedCode, false},
138-
{Credo.Check.Readability.Specs, false},
139-
{Credo.Check.Refactor.ABCSize, false},
140-
{Credo.Check.Refactor.AppendSingleItem, false},
141-
{Credo.Check.Refactor.DoubleBooleanNegation, false},
142-
{Credo.Check.Refactor.VariableRebinding, false},
143-
{Credo.Check.Warning.MapGetUnsafePass, false},
144-
{Credo.Check.Warning.UnsafeToAtom, false}
158+
#
159+
# Controversial and experimental checks (opt-in, just move the check to `:enabled`
160+
# and be sure to use `mix credo --strict` to see low priority checks)
161+
#
162+
{Credo.Check.Consistency.MultiAliasImportRequireUse, []},
163+
{Credo.Check.Consistency.UnusedVariableNames, []},
164+
{Credo.Check.Design.DuplicatedCode, []},
165+
{Credo.Check.Design.SkipTestWithoutComment, []},
166+
{Credo.Check.Readability.AliasAs, []},
167+
{Credo.Check.Readability.BlockPipe, []},
168+
{Credo.Check.Readability.ImplTrue, []},
169+
{Credo.Check.Readability.MultiAlias, []},
170+
{Credo.Check.Readability.NestedFunctionCalls, []},
171+
{Credo.Check.Readability.OneArityFunctionInPipe, []},
172+
{Credo.Check.Readability.OnePipePerLine, []},
173+
{Credo.Check.Readability.SeparateAliasRequire, []},
174+
{Credo.Check.Readability.SingleFunctionToBlockPipe, []},
175+
{Credo.Check.Readability.SinglePipe, []},
176+
{Credo.Check.Readability.Specs, []},
177+
{Credo.Check.Readability.StrictModuleLayout, []},
178+
{Credo.Check.Readability.WithCustomTaggedTuple, []},
179+
{Credo.Check.Refactor.ABCSize, []},
180+
{Credo.Check.Refactor.AppendSingleItem, []},
181+
{Credo.Check.Refactor.DoubleBooleanNegation, []},
182+
{Credo.Check.Refactor.FilterReject, []},
183+
{Credo.Check.Refactor.IoPuts, []},
184+
{Credo.Check.Refactor.MapMap, []},
185+
{Credo.Check.Refactor.ModuleDependencies, []},
186+
{Credo.Check.Refactor.NegatedIsNil, []},
187+
{Credo.Check.Refactor.PassAsyncInTestCases, []},
188+
{Credo.Check.Refactor.PipeChainStart, []},
189+
{Credo.Check.Refactor.RejectFilter, []},
190+
{Credo.Check.Refactor.VariableRebinding, []},
191+
{Credo.Check.Warning.LazyLogging, []},
192+
{Credo.Check.Warning.LeakyEnvironment, []},
193+
{Credo.Check.Warning.MapGetUnsafePass, []},
194+
{Credo.Check.Warning.MixEnv, []},
195+
{Credo.Check.Warning.UnsafeToAtom, []}
145196

146-
# Custom checks can be created using `mix credo.gen.check`.
147-
#
148-
]
197+
# {Credo.Check.Refactor.MapInto, []},
198+
199+
#
200+
# Custom checks can be created using `mix credo.gen.check`.
201+
#
202+
]
203+
}
149204
}
150205
]
151206
}

.formatter.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Used by "mix format"
22
[
3-
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
3+
inputs: ["{mix,.credo,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
44
line_length: 120
55
]

.github/workflows/ci.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,56 @@ on:
99
jobs:
1010
Test:
1111
runs-on: ubuntu-latest
12+
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
13+
strategy:
14+
matrix:
15+
versions:
16+
- elixir: "1.16"
17+
otp: "26"
18+
- elixir: "1.17"
19+
otp: "27"
20+
- elixir: "1.18"
21+
otp: "27"
1222
env:
1323
MIX_ENV: test
1424
steps:
1525
- name: Checkout Code
16-
uses: actions/checkout@v1
26+
uses: actions/checkout@v4
27+
28+
- uses: actions/cache@v4
29+
with:
30+
path: |
31+
deps
32+
_build
33+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-mix-
1736
1837
- name: Set up Elixir
1938
uses: erlef/setup-beam@v1
2039
with:
21-
version-file: .tool-versions
22-
version-type: strict
40+
otp-version: ${{matrix.versions.otp}}
41+
elixir-version: ${{matrix.versions.elixir}}
2342

2443
- name: Install Dependencies
2544
run: |
26-
mix local.rebar --force
27-
mix local.hex --force
2845
mix deps.get
29-
mix deps.update ssl_verify_fun
3046
3147
- name: Run Tests
3248
run: mix test
3349

3450
Linting:
3551
runs-on: ubuntu-latest
52+
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} Linting
3653
steps:
3754
- name: Checkout Code
38-
uses: actions/checkout@v1
55+
uses: actions/checkout@v4
3956

4057
- name: Set up Elixir
4158
uses: erlef/setup-beam@v1
4259
with:
43-
version-file: .tool-versions
44-
version-type: strict
60+
elixir-version: "1.16"
61+
otp-version: "26"
4562

4663
- name: Install Dependencies
4764
run: |

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
erlang 26.0
2-
elixir 1.15
1+
erlang 27.3.4
2+
elixir 1.18.4-otp-27

0 commit comments

Comments
 (0)