Skip to content

Commit 89f3f77

Browse files
nshkrdotcomnshkrdotcom
authored andcommitted
initial release v0.0.1
0 parents  commit 89f3f77

195 files changed

Lines changed: 65142 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.credo.exs

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
# This file contains the configuration for Credo and you are probably reading
2+
# this after creating it with `mix credo.gen.config`.
3+
#
4+
# If you find anything wrong or unclear in this file, please report an
5+
# issue on GitHub: https://github.com/rrrene/credo/issues
6+
#
7+
%{
8+
#
9+
# You can have as many configs as you like in the `configs:` field.
10+
configs: [
11+
%{
12+
#
13+
# Run any config using `mix credo -C <name>`. If no config name is given
14+
# "default" is used.
15+
#
16+
name: "default",
17+
#
18+
# These are the files included in the analysis:
19+
files: %{
20+
#
21+
# You can give explicit globs or simply directories.
22+
# In the latter case `**/*.{ex,exs}` will be used.
23+
#
24+
included: [
25+
"lib/",
26+
"src/",
27+
"test/",
28+
"web/",
29+
"apps/*/lib/",
30+
"apps/*/src/",
31+
"apps/*/test/",
32+
"apps/*/web/"
33+
],
34+
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
35+
},
36+
#
37+
# Load and configure plugins here:
38+
#
39+
plugins: [],
40+
#
41+
# If you create your own checks, you must specify the source files for
42+
# them here, so they can be loaded by Credo before running the analysis.
43+
#
44+
requires: [],
45+
#
46+
# If you want to enforce a style guide and need a more traditional linting
47+
# experience, you can change `strict` to `true` below:
48+
#
49+
strict: false,
50+
#
51+
# To modify the timeout for parsing files, change this value:
52+
#
53+
parse_timeout: 5000,
54+
#
55+
# If you want to use uncolored output by default, you can change `color`
56+
# to `false` below:
57+
#
58+
color: true,
59+
#
60+
# You can customize the parameters of any check by adding a second element
61+
# to the tuple.
62+
#
63+
# To disable a check put `false` as second element:
64+
#
65+
# {Credo.Check.Design.DuplicatedCode, false}
66+
#
67+
checks: %{
68+
enabled: [
69+
#
70+
## Consistency Checks
71+
#
72+
{Credo.Check.Consistency.ExceptionNames, []},
73+
{Credo.Check.Consistency.LineEndings, []},
74+
{Credo.Check.Consistency.ParameterPatternMatching, []},
75+
{Credo.Check.Consistency.SpaceAroundOperators, []},
76+
{Credo.Check.Consistency.SpaceInParentheses, []},
77+
{Credo.Check.Consistency.TabsOrSpaces, []},
78+
79+
#
80+
## Design Checks
81+
#
82+
# You can customize the priority of any check
83+
# Priority values are: `low, normal, high, higher`
84+
#
85+
{Credo.Check.Design.AliasUsage,
86+
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
87+
{Credo.Check.Design.TagFIXME, []},
88+
# You can also customize the exit_status of each check.
89+
# If you don't want TODO comments to cause `mix credo` to fail, just
90+
# set this value to 0 (zero).
91+
#
92+
{Credo.Check.Design.TagTODO, [exit_status: 2]},
93+
94+
#
95+
## Readability Checks
96+
#
97+
{Credo.Check.Readability.AliasOrder, []},
98+
{Credo.Check.Readability.FunctionNames, []},
99+
{Credo.Check.Readability.LargeNumbers, []},
100+
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
101+
{Credo.Check.Readability.ModuleAttributeNames, []},
102+
{Credo.Check.Readability.ModuleDoc, []},
103+
{Credo.Check.Readability.ModuleNames, []},
104+
{Credo.Check.Readability.ParenthesesInCondition, []},
105+
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
106+
{Credo.Check.Readability.PipeIntoAnonymousFunctions, []},
107+
{Credo.Check.Readability.PredicateFunctionNames, []},
108+
{Credo.Check.Readability.PreferImplicitTry, []},
109+
{Credo.Check.Readability.RedundantBlankLines, []},
110+
{Credo.Check.Readability.Semicolons, []},
111+
{Credo.Check.Readability.SpaceAfterCommas, []},
112+
{Credo.Check.Readability.StringSigils, []},
113+
{Credo.Check.Readability.TrailingBlankLine, []},
114+
{Credo.Check.Readability.TrailingWhiteSpace, []},
115+
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
116+
{Credo.Check.Readability.VariableNames, []},
117+
{Credo.Check.Readability.WithSingleClause, []},
118+
119+
#
120+
## Refactoring Opportunities
121+
#
122+
{Credo.Check.Refactor.Apply, []},
123+
{Credo.Check.Refactor.CondStatements, []},
124+
{Credo.Check.Refactor.CyclomaticComplexity, []},
125+
{Credo.Check.Refactor.FilterCount, []},
126+
{Credo.Check.Refactor.FilterFilter, []},
127+
{Credo.Check.Refactor.FunctionArity, []},
128+
{Credo.Check.Refactor.LongQuoteBlocks, []},
129+
{Credo.Check.Refactor.MapJoin, []},
130+
{Credo.Check.Refactor.MatchInCondition, []},
131+
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
132+
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
133+
# 3 levels of nesting should be okay
134+
{Credo.Check.Refactor.Nesting, [max_nesting: 3]},
135+
{Credo.Check.Refactor.RedundantWithClauseResult, []},
136+
{Credo.Check.Refactor.RejectReject, []},
137+
{Credo.Check.Refactor.UnlessWithElse, []},
138+
{Credo.Check.Refactor.WithClauses, []},
139+
140+
#
141+
## Warnings
142+
#
143+
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
144+
{Credo.Check.Warning.BoolOperationOnSameValues, []},
145+
{Credo.Check.Warning.Dbg, []},
146+
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
147+
{Credo.Check.Warning.IExPry, []},
148+
{Credo.Check.Warning.IoInspect, []},
149+
{Credo.Check.Warning.MissedMetadataKeyInLoggerConfig, []},
150+
{Credo.Check.Warning.OperationOnSameValues, []},
151+
{Credo.Check.Warning.OperationWithConstantResult, []},
152+
{Credo.Check.Warning.RaiseInsideRescue, []},
153+
{Credo.Check.Warning.SpecWithStruct, []},
154+
{Credo.Check.Warning.UnsafeExec, []},
155+
{Credo.Check.Warning.UnusedEnumOperation, []},
156+
{Credo.Check.Warning.UnusedFileOperation, []},
157+
{Credo.Check.Warning.UnusedKeywordOperation, []},
158+
{Credo.Check.Warning.UnusedListOperation, []},
159+
{Credo.Check.Warning.UnusedPathOperation, []},
160+
{Credo.Check.Warning.UnusedRegexOperation, []},
161+
{Credo.Check.Warning.UnusedStringOperation, []},
162+
{Credo.Check.Warning.UnusedTupleOperation, []},
163+
{Credo.Check.Warning.WrongTestFileExtension, []}
164+
],
165+
disabled: [
166+
#
167+
# Checks scheduled for next check update (opt-in for now)
168+
{Credo.Check.Refactor.UtcNowTruncate, []},
169+
170+
#
171+
# Controversial and experimental checks (opt-in, just move the check to `:enabled`
172+
# and be sure to use `mix credo --strict` to see low priority checks)
173+
#
174+
{Credo.Check.Consistency.MultiAliasImportRequireUse, []},
175+
{Credo.Check.Consistency.UnusedVariableNames, []},
176+
{Credo.Check.Design.DuplicatedCode, []},
177+
{Credo.Check.Design.SkipTestWithoutComment, []},
178+
{Credo.Check.Readability.AliasAs, []},
179+
{Credo.Check.Readability.BlockPipe, []},
180+
{Credo.Check.Readability.ImplTrue, []},
181+
{Credo.Check.Readability.MultiAlias, []},
182+
{Credo.Check.Readability.NestedFunctionCalls, []},
183+
{Credo.Check.Readability.OneArityFunctionInPipe, []},
184+
{Credo.Check.Readability.OnePipePerLine, []},
185+
{Credo.Check.Readability.SeparateAliasRequire, []},
186+
{Credo.Check.Readability.SingleFunctionToBlockPipe, []},
187+
{Credo.Check.Readability.SinglePipe, []},
188+
{Credo.Check.Readability.Specs, []},
189+
{Credo.Check.Readability.StrictModuleLayout, []},
190+
{Credo.Check.Readability.WithCustomTaggedTuple, []},
191+
{Credo.Check.Refactor.ABCSize, []},
192+
{Credo.Check.Refactor.AppendSingleItem, []},
193+
{Credo.Check.Refactor.DoubleBooleanNegation, []},
194+
{Credo.Check.Refactor.FilterReject, []},
195+
{Credo.Check.Refactor.IoPuts, []},
196+
{Credo.Check.Refactor.MapMap, []},
197+
{Credo.Check.Refactor.ModuleDependencies, []},
198+
{Credo.Check.Refactor.NegatedIsNil, []},
199+
{Credo.Check.Refactor.PassAsyncInTestCases, []},
200+
{Credo.Check.Refactor.PipeChainStart, []},
201+
{Credo.Check.Refactor.RejectFilter, []},
202+
{Credo.Check.Refactor.VariableRebinding, []},
203+
{Credo.Check.Warning.LazyLogging, []},
204+
{Credo.Check.Warning.LeakyEnvironment, []},
205+
{Credo.Check.Warning.MapGetUnsafePass, []},
206+
{Credo.Check.Warning.MixEnv, []},
207+
{Credo.Check.Warning.UnsafeToAtom, []}
208+
209+
# {Credo.Check.Refactor.MapInto, []},
210+
211+
#
212+
# Custom checks can be created using `mix credo.gen.check`.
213+
#
214+
]
215+
}
216+
}
217+
]
218+
}

.dialyzer_ignore.exs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
# These functions work correctly in practice but Dialyzer can't analyze the complex call chains
3+
# involving Runtime.create_schema, Runtime.validate, and TypeAdapter calls
4+
~r/lib\/exdantic\/enhanced_validator\.ex:118.*Function validate_wrapped.* has no local return/,
5+
~r/lib\/exdantic\/enhanced_validator\.ex:121.*Function validate_wrapped.* has no local return/,
6+
~r/lib\/exdantic\/enhanced_validator\.ex:123.*Function validate_wrapped.* has no local return/,
7+
~r/lib\/exdantic\/wrapper\.ex:58.*Function create_wrapper.* has no local return/,
8+
~r/lib\/exdantic\/wrapper\.ex:60.*Function create_wrapper.* has no local return/,
9+
~r/lib\/exdantic\/wrapper\.ex:70.*Function do_create_wrapper.* has no local return/,
10+
~r/lib\/exdantic\/wrapper\.ex:194.*Function wrap_and_validate.* has no local return/,
11+
~r/lib\/exdantic\/wrapper\.ex:225.*The created anonymous function has no local return/,
12+
~r/lib\/exdantic\/wrapper\.ex:318.*The created anonymous function has no local return/,
13+
~r/lib\/exdantic\/wrapper\.ex:461.*Function create_flexible_wrapper.* has no local return/,
14+
# Extra range warning for validate_wrapped/4 due to try/rescue always returning a tuple
15+
~r/lib\/exdantic\/enhanced_validator\.ex:125.*extra_range/,
16+
# The type specification has too many types for the function.
17+
{"lib/exdantic/enhanced_validator.ex", :extra_range, 125},
18+
# The catch-all clause is needed for error handling even though dialyzer thinks it's unreachable
19+
~r/lib\/exdantic\/json_schema\/enhanced_resolver\.ex:766.*pattern_match_cov/
20+
]

.formatter.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]

.gitattributes

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto eol=lf
3+
4+
# Elixir files
5+
*.ex text eol=lf
6+
*.exs text eol=lf
7+
*.eex text eol=lf
8+
*.leex text eol=lf
9+
10+
# Config files
11+
.formatter.exs text eol=lf
12+
.credo.exs text eol=lf
13+
.dialyzer_ignore.exs text eol=lf
14+
mix.exs text eol=lf
15+
mix.lock text eol=lf
16+
17+
# Documentation
18+
*.md text eol=lf
19+
README* text eol=lf
20+
LICENSE text eol=lf
21+
CHANGELOG* text eol=lf
22+
23+
# Git files
24+
.gitignore text eol=lf
25+
.gitattributes text eol=lf
26+
27+
# CI files
28+
*.yml text eol=lf
29+
*.yaml text eol=lf
30+
31+
# Shell scripts
32+
*.sh text eol=lf
33+
34+
# Binary files
35+
*.png binary
36+
*.jpg binary
37+
*.jpeg binary
38+
*.gif binary
39+
*.ico binary
40+
*.pdf binary

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
pull_request:
7+
branches: [ "*" ]
8+
9+
jobs:
10+
test:
11+
name: Build and test
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
elixir: ['1.18.3']
16+
otp: ['27.3.3']
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Elixir
22+
uses: erlef/setup-beam@v1
23+
with:
24+
elixir-version: ${{ matrix.elixir }}
25+
otp-version: ${{ matrix.otp }}
26+
27+
- name: Restore dependencies cache
28+
uses: actions/cache@v4
29+
with:
30+
path: deps
31+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
32+
restore-keys: ${{ runner.os }}-mix-
33+
34+
- name: Install dependencies
35+
run: mix deps.get
36+
37+
- name: Run tests
38+
run: mix test
39+
40+
- name: Check formatting
41+
run: |
42+
echo "Running mix format check..."
43+
mix format --check-formatted || (echo "Format check failed!" && exit 1)
44+
45+
- name: Run Credo
46+
run: |
47+
echo "Running Credo..."
48+
mix credo --strict || (echo "Credo check failed!" && exit 1)
49+
50+
- name: Run Dialyzer
51+
run: |
52+
echo "Running Dialyzer..."
53+
mix dialyzer || (echo "Dialyzer check failed!" && exit 1)

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
7+
jobs:
8+
publish:
9+
name: Publish to Hex.pm
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up Elixir
16+
uses: erlef/setup-beam@v1
17+
with:
18+
otp-version: '25'
19+
elixir-version: '1.14'
20+
21+
- name: Cache deps and build
22+
uses: actions/cache@v3
23+
with:
24+
path: |
25+
deps
26+
_build
27+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
28+
restore-keys: |
29+
${{ runner.os }}-mix-
30+
31+
- name: Install dependencies
32+
run: |
33+
echo "Installing dependencies..."
34+
mix deps.get || (echo "Failed to install dependencies!" && exit 1)
35+
36+
- name: Run tests
37+
run: |
38+
echo "Running tests..."
39+
mix test || (echo "Tests failed!" && exit 1)
40+
41+
- name: Check formatting
42+
run: |
43+
echo "Running mix format check..."
44+
mix format --check-formatted || (echo "Format check failed!" && exit 1)
45+
46+
- name: Run Credo
47+
run: |
48+
echo "Running Credo..."
49+
mix credo --strict || (echo "Credo check failed!" && exit 1)
50+
51+
- name: Publish to Hex.pm
52+
env:
53+
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
54+
run: |
55+
echo "Publishing to Hex.pm..."
56+
mix hex.publish --yes || (echo "Failed to publish to Hex.pm!" && exit 1)

0 commit comments

Comments
 (0)