Skip to content

Commit f39c60b

Browse files
authored
Merge pull request #50 from firezone/master
Complete rewrite of the library
2 parents 4cef838 + a88b05f commit f39c60b

Some content is hidden

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

48 files changed

+3106
-1189
lines changed

.credo.exs

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
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: 2]},
87+
# You can also customize the exit_status of each check.
88+
# If you don't want TODO comments to cause `mix credo` to fail, just
89+
# set this value to 0 (zero).
90+
#
91+
{Credo.Check.Design.TagTODO, [exit_status: 0]},
92+
{Credo.Check.Design.TagFIXME, []},
93+
94+
#
95+
## Readability Checks
96+
#
97+
{Credo.Check.Readability.FunctionNames, []},
98+
{Credo.Check.Readability.LargeNumbers, []},
99+
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
100+
{Credo.Check.Readability.ModuleAttributeNames, []},
101+
{Credo.Check.Readability.ModuleNames, []},
102+
{Credo.Check.Readability.ParenthesesInCondition, []},
103+
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
104+
{Credo.Check.Readability.PipeIntoAnonymousFunctions, []},
105+
{Credo.Check.Readability.PredicateFunctionNames, []},
106+
{Credo.Check.Readability.PreferImplicitTry, []},
107+
{Credo.Check.Readability.RedundantBlankLines, []},
108+
{Credo.Check.Readability.Semicolons, []},
109+
{Credo.Check.Readability.SpaceAfterCommas, []},
110+
{Credo.Check.Readability.StringSigils, []},
111+
{Credo.Check.Readability.TrailingBlankLine, []},
112+
{Credo.Check.Readability.TrailingWhiteSpace, []},
113+
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
114+
{Credo.Check.Readability.VariableNames, []},
115+
{Credo.Check.Readability.WithSingleClause, []},
116+
117+
#
118+
## Refactoring Opportunities
119+
#
120+
{Credo.Check.Refactor.Apply, []},
121+
{Credo.Check.Refactor.CondStatements, []},
122+
{Credo.Check.Refactor.CyclomaticComplexity, []},
123+
{Credo.Check.Refactor.FunctionArity, []},
124+
{Credo.Check.Refactor.LongQuoteBlocks, []},
125+
{Credo.Check.Refactor.MatchInCondition, []},
126+
{Credo.Check.Refactor.MapJoin, []},
127+
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
128+
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
129+
{Credo.Check.Refactor.Nesting, []},
130+
{Credo.Check.Refactor.UnlessWithElse, []},
131+
{Credo.Check.Refactor.WithClauses, []},
132+
{Credo.Check.Refactor.FilterFilter, []},
133+
{Credo.Check.Refactor.RejectReject, []},
134+
135+
#
136+
## Warnings
137+
#
138+
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
139+
{Credo.Check.Warning.BoolOperationOnSameValues, []},
140+
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
141+
{Credo.Check.Warning.IExPry, []},
142+
{Credo.Check.Warning.IoInspect, []},
143+
{Credo.Check.Warning.OperationOnSameValues, []},
144+
{Credo.Check.Warning.OperationWithConstantResult, []},
145+
{Credo.Check.Warning.RaiseInsideRescue, []},
146+
{Credo.Check.Warning.SpecWithStruct, []},
147+
{Credo.Check.Warning.WrongTestFileExtension, []},
148+
{Credo.Check.Warning.UnusedEnumOperation, []},
149+
{Credo.Check.Warning.UnusedFileOperation, []},
150+
{Credo.Check.Warning.UnusedKeywordOperation, []},
151+
{Credo.Check.Warning.UnusedListOperation, []},
152+
{Credo.Check.Warning.UnusedPathOperation, []},
153+
{Credo.Check.Warning.UnusedRegexOperation, []},
154+
{Credo.Check.Warning.UnusedStringOperation, []},
155+
{Credo.Check.Warning.UnusedTupleOperation, []},
156+
{Credo.Check.Warning.UnsafeExec, []}
157+
],
158+
disabled: [
159+
{Credo.Check.Readability.AliasOrder, []},
160+
161+
#
162+
# Controversial and experimental checks (opt-in, just move the check to `:enabled`
163+
# and be sure to use `mix credo --strict` to see low priority checks)
164+
#
165+
{Credo.Check.Consistency.MultiAliasImportRequireUse, []},
166+
{Credo.Check.Consistency.UnusedVariableNames, []},
167+
{Credo.Check.Design.DuplicatedCode, []},
168+
{Credo.Check.Design.SkipTestWithoutComment, []},
169+
{Credo.Check.Readability.AliasAs, []},
170+
{Credo.Check.Readability.BlockPipe, []},
171+
{Credo.Check.Readability.ImplTrue, []},
172+
{Credo.Check.Readability.MultiAlias, []},
173+
{Credo.Check.Readability.NestedFunctionCalls, []},
174+
{Credo.Check.Readability.SeparateAliasRequire, []},
175+
{Credo.Check.Readability.SingleFunctionToBlockPipe, []},
176+
{Credo.Check.Readability.SinglePipe, []},
177+
{Credo.Check.Readability.Specs, []},
178+
{Credo.Check.Readability.StrictModuleLayout, []},
179+
{Credo.Check.Readability.WithCustomTaggedTuple, []},
180+
{Credo.Check.Refactor.ABCSize, []},
181+
{Credo.Check.Refactor.AppendSingleItem, []},
182+
{Credo.Check.Refactor.DoubleBooleanNegation, []},
183+
{Credo.Check.Refactor.FilterReject, []},
184+
{Credo.Check.Refactor.IoPuts, []},
185+
{Credo.Check.Refactor.MapMap, []},
186+
{Credo.Check.Refactor.ModuleDependencies, []},
187+
{Credo.Check.Refactor.NegatedIsNil, []},
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, []}
196+
197+
# {Credo.Check.Refactor.MapInto, []},
198+
199+
#
200+
# Custom checks can be created using `mix credo.gen.check`.
201+
#
202+
]
203+
}
204+
}
205+
]
206+
}

.github/workflows/test.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Test
2+
on: [push, pull_request]
3+
4+
jobs:
5+
static-analysis:
6+
runs-on: ubuntu-latest
7+
env:
8+
MIX_ENV: dev
9+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-python@v2
13+
with:
14+
python-version: "3.9"
15+
- uses: erlef/setup-beam@v1
16+
with:
17+
otp-version: "25"
18+
elixir-version: "1.14"
19+
- uses: actions/[email protected]
20+
name: Setup Elixir cache
21+
with:
22+
path: |
23+
deps
24+
_build
25+
key: ${{ runner.os }}-mix-otp-25-${{ hashFiles('**/mix.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-mix-otp-25-
28+
- uses: actions/[email protected]
29+
name: Setup Python cache
30+
with:
31+
path: ~/.cache/pip
32+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
33+
restore-keys: |
34+
${{ runner.os }}-pip-
35+
- name: Install Elixir Dependencies
36+
run: mix deps.get --only dev
37+
- name: Install Python Dependencies
38+
run: |
39+
pip install -r requirements.txt
40+
# Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old ones
41+
# Cache key based on Elixir & Erlang version (also usefull when running in matrix)
42+
- name: Restore PLT cache
43+
uses: actions/[email protected]
44+
id: plt_cache
45+
with:
46+
key: |
47+
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt
48+
restore-keys: |
49+
${{ runner.os }}-${{ steps.beam.outputs.elixir-version }}-${{ steps.beam.outputs.otp-version }}-plt
50+
path: |
51+
priv/plts
52+
# Create PLTs if no cache was found
53+
- name: Create PLTs
54+
if: steps.plt_cache.outputs.cache-hit != 'true'
55+
run: mix dialyzer --plt
56+
- name: Run pre-commit
57+
run: |
58+
pre-commit install
59+
SKIP=no-commit-to-branch pre-commit run --all-files
60+
61+
unit-test:
62+
runs-on: ubuntu-22.04
63+
env:
64+
MIX_ENV: test
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
strategy:
67+
matrix:
68+
include:
69+
- elixir-version: "1.12"
70+
otp-version: "24"
71+
- elixir-version: "1.13"
72+
otp-version: "24"
73+
- elixir-version: "1.14"
74+
otp-version: "25"
75+
steps:
76+
- uses: actions/checkout@v3
77+
- uses: erlef/setup-beam@v1
78+
with:
79+
otp-version: "${{ matrix.otp-version }}"
80+
elixir-version: "${{ matrix.elixir-version }}"
81+
- uses: actions/[email protected]
82+
with:
83+
path: |
84+
deps
85+
_build
86+
key: ${{ runner.os }}-${{ matrix.otp-version }}-${{ matrix.elixir-version }}-${{ hashFiles('**/mix.lock') }}
87+
restore-keys: |
88+
${{ runner.os }}-${{ matrix.otp-version }}-${{ matrix.elixir-version }}-
89+
- name: Install Dependencies
90+
run: mix deps.get --only test
91+
- name: Run Tests
92+
run: mix test

.pre-commit-config.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
# Elixir config
5+
# Randomly started failing
6+
# - id: mix-format
7+
# name: 'elixir: mix format'
8+
# entry: mix format --check-formatted
9+
# language: system
10+
- id: mix-lint
11+
name: 'elixir: mix credo'
12+
entry: mix credo --strict
13+
language: system
14+
pass_filenames: false
15+
files: \.exs*$
16+
- id: mix-analysis
17+
name: 'elixir: mix dialyzer'
18+
entry: mix dialyzer --format dialyxir
19+
language: system
20+
pass_filenames: false
21+
files: \.exs*$
22+
- id: mix-compile
23+
name: 'elixir: mix compile'
24+
entry: mix compile --force --warnings-as-errors
25+
language: system
26+
pass_filenames: false
27+
files: \.ex$
28+
29+
# Standard pre-commit hooks
30+
- repo: https://github.com/pre-commit/pre-commit-hooks
31+
rev: v2.3.0
32+
hooks:
33+
- id: mixed-line-ending
34+
args: ['--fix=lf']
35+
description: Forces to replace line ending by the UNIX 'lf' character.
36+
- id: check-merge-conflict
37+
- id: end-of-file-fixer
38+
exclude: "^omnibus/config/patches/"
39+
- id: trailing-whitespace
40+
exclude: "^omnibus/config/patches/"
41+
- id: check-merge-conflict
42+
- id: no-commit-to-branch
43+
args: [-b, master, -b, develop]

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## v0.2.2
44
* Allow missing `claims_supported` in discovery document
5-
* Allow overriding document params
5+
* Allow overriding document params
66

77
## v0.2.1
88
* Relaxed jason version requirement
@@ -20,4 +20,4 @@
2020

2121
## v0.1.0
2222

23-
* Initial public release
23+
* Initial public release

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
44

55
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
66

7-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)