-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a12044d
Showing
19 changed files
with
560 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
alias Credo.Check | ||
|
||
%{ | ||
configs: [ | ||
%{ | ||
name: "default", | ||
files: %{ | ||
included: [ | ||
"lib/", | ||
"src/", | ||
"web/", | ||
"apps/*/lib/", | ||
"apps/*/src/", | ||
"apps/*/web/" | ||
], | ||
excluded: [~r"/tests/", ~r"/_build/", ~r"/deps/", ~r"/node_modules/"] | ||
}, | ||
plugins: [], | ||
requires: [], | ||
strict: true, | ||
parse_timeout: 5000, | ||
color: true, | ||
checks: %{ | ||
enabled: [ | ||
## Consistency Checks ------------------------------------------------ | ||
{Check.Consistency.ExceptionNames, []}, | ||
{Check.Consistency.LineEndings, []}, | ||
{Check.Consistency.ParameterPatternMatching, []}, | ||
{Check.Consistency.SpaceAroundOperators, []}, | ||
{Check.Consistency.SpaceInParentheses, []}, | ||
{Check.Consistency.TabsOrSpaces, []}, | ||
|
||
## Design Checks ----------------------------------------------------- | ||
{Check.Design.AliasUsage, if_nested_deeper_than: 2}, | ||
|
||
## Readability Checks ------------------------------------------------ | ||
{Check.Readability.AliasOrder, []}, | ||
{Check.Readability.FunctionNames, []}, | ||
{Check.Readability.LargeNumbers, []}, | ||
{Check.Readability.MaxLineLength, priority: :low, max_length: 120}, | ||
{Check.Readability.ModuleAttributeNames, []}, | ||
{Check.Readability.ModuleDoc, []}, | ||
{Check.Readability.ModuleNames, []}, | ||
{Check.Readability.ParenthesesInCondition, []}, | ||
{Check.Readability.ParenthesesOnZeroArityDefs, []}, | ||
{Check.Readability.PipeIntoAnonymousFunctions, []}, | ||
{Check.Readability.PredicateFunctionNames, []}, | ||
{Check.Readability.PreferImplicitTry, []}, | ||
{Check.Readability.RedundantBlankLines, []}, | ||
{Check.Readability.Semicolons, []}, | ||
{Check.Readability.SpaceAfterCommas, []}, | ||
{Check.Readability.StringSigils, []}, | ||
{Check.Readability.TrailingBlankLine, []}, | ||
{Check.Readability.TrailingWhiteSpace, []}, | ||
{Check.Readability.UnnecessaryAliasExpansion, []}, | ||
{Check.Readability.VariableNames, []}, | ||
{Check.Readability.WithSingleClause, []}, | ||
|
||
## Refactoring Opportunities ----------------------------------------- | ||
{Check.Refactor.Apply, []}, | ||
{Check.Refactor.CondStatements, []}, | ||
{Check.Refactor.CyclomaticComplexity, []}, | ||
{Check.Refactor.FunctionArity, []}, | ||
{Check.Refactor.LongQuoteBlocks, []}, | ||
{Check.Refactor.MatchInCondition, []}, | ||
{Check.Refactor.MapJoin, []}, | ||
{Check.Refactor.NegatedConditionsInUnless, []}, | ||
{Check.Refactor.NegatedConditionsWithElse, []}, | ||
{Check.Refactor.Nesting, []}, | ||
{Check.Refactor.UnlessWithElse, []}, | ||
{Check.Refactor.WithClauses, []}, | ||
{Check.Refactor.FilterFilter, []}, | ||
{Check.Refactor.RejectReject, []}, | ||
{Check.Refactor.RedundantWithClauseResult, []}, | ||
|
||
## Warnings ---------------------------------------------------------- | ||
{Check.Warning.ApplicationConfigInModuleAttribute, []}, | ||
{Check.Warning.BoolOperationOnSameValues, []}, | ||
{Check.Warning.ExpensiveEmptyEnumCheck, []}, | ||
{Check.Warning.IExPry, []}, | ||
{Check.Warning.IoInspect, []}, | ||
{Check.Warning.OperationOnSameValues, []}, | ||
{Check.Warning.OperationWithConstantResult, []}, | ||
{Check.Warning.RaiseInsideRescue, []}, | ||
{Check.Warning.SpecWithStruct, []}, | ||
{Check.Warning.WrongTestFileExtension, []}, | ||
{Check.Warning.UnusedEnumOperation, []}, | ||
{Check.Warning.UnusedFileOperation, []}, | ||
{Check.Warning.UnusedKeywordOperation, []}, | ||
{Check.Warning.UnusedListOperation, []}, | ||
{Check.Warning.UnusedPathOperation, []}, | ||
{Check.Warning.UnusedRegexOperation, []}, | ||
{Check.Warning.UnusedStringOperation, []}, | ||
{Check.Warning.UnusedTupleOperation, []}, | ||
{Check.Warning.UnsafeExec, []}, | ||
|
||
## Checks which should always be on for consistency-sake IMO --------- | ||
{Check.Consistency.MultiAliasImportRequireUse, []}, | ||
{Check.Consistency.UnusedVariableNames, force: :meaningful}, | ||
{Check.Design.DuplicatedCode, []}, | ||
{Check.Design.SkipTestWithoutComment, []}, | ||
{Check.Readability.ImplTrue, []}, | ||
{Check.Readability.MultiAlias, []}, | ||
{Check.Readability.NestedFunctionCalls, []}, | ||
{Check.Readability.SeparateAliasRequire, []}, | ||
{Check.Readability.SingleFunctionToBlockPipe, []}, | ||
{Check.Readability.SinglePipe, []}, | ||
{Check.Readability.StrictModuleLayout, []}, | ||
{Check.Readability.WithCustomTaggedTuple, []}, | ||
{Check.Refactor.ABCSize, [max_size: 80]}, | ||
{Check.Refactor.DoubleBooleanNegation, []}, | ||
{Check.Refactor.FilterReject, []}, | ||
{Check.Refactor.MapMap, []}, | ||
{Check.Refactor.NegatedIsNil, []}, | ||
{Check.Refactor.PipeChainStart, []}, | ||
{Check.Refactor.RejectFilter, []}, | ||
{Check.Refactor.VariableRebinding, []}, | ||
{Check.Warning.LeakyEnvironment, []}, | ||
{Check.Warning.MapGetUnsafePass, []}, | ||
{Check.Warning.MixEnv, []}, | ||
{Check.Warning.UnsafeToAtom, []}, | ||
|
||
## Causes Issues with Phoenix ---------------------------------------- | ||
{Check.Readability.Specs, []}, | ||
{Check.Refactor.ModuleDependencies, [max_deps: 19]}, | ||
|
||
## Optional (move to `disabled` based on app domain) ----------------- | ||
{Check.Refactor.IoPuts, []} | ||
], | ||
disabled: [ | ||
## Checks which are overly limiting ---------------------------------- | ||
{Check.Design.TagTODO, exit_status: 2}, | ||
{Check.Design.TagFIXME, []}, | ||
{Check.Readability.BlockPipe, []}, | ||
{Check.Readability.AliasAs, []}, | ||
{Check.Refactor.AppendSingleItem, []}, | ||
|
||
## Incompatible with modern versions of Elixir ----------------------- | ||
{Check.Refactor.MapInto, []}, | ||
{Check.Warning.LazyLogging, []} | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Used by "mix format" | ||
[ | ||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
name: Endo | CI checks | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ci-${{github.ref}} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
lint-and-test: | ||
runs-on: ubuntu-latest | ||
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}} | ||
strategy: | ||
matrix: | ||
include: | ||
- otp: "26.1" | ||
elixir: "1.15.7" | ||
- otp: "24.2" | ||
elixir: "1.13.4" | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: endo_repo | ||
POSTGRES_PORT: 5432 | ||
steps: | ||
- name: Checkout Github repo | ||
uses: actions/checkout@v3.0.2 | ||
- name: Setup BEAM Env | ||
uses: erlef/setup-beam@v1.15 | ||
with: | ||
otp-version: ${{matrix.otp}} | ||
elixir-version: ${{matrix.elixir}} | ||
- name: Setup Cache | ||
uses: actions/cache@v3.0.4 | ||
id: mix-cache | ||
with: | ||
path: | | ||
deps | ||
_build | ||
priv/plts | ||
key: ${{ hashFiles('mix.lock') }}-${{ matrix.elixir }}-${{ matrix.otp }} | ||
- if: steps.mix-cache.outputs.cache-hit != 'true' | ||
run: mkdir -p priv/plts; mix deps.get; mix deps.compile | ||
- run: docker-compose up -d | ||
- run: mix lint | ||
- run: MIX_ENV=test mix do ecto.create, ecto.migrate, test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
tags | ||
.elixir_ls/ | ||
.env | ||
.envrc | ||
_build/ | ||
erl_crash.dump | ||
deps/ | ||
cover/ | ||
apps/**/cover/ | ||
priv/plts/ | ||
doc/ | ||
.direnv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Vetspire | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# EctoModel | ||
|
||
EctoModel is a library that aims to overhaul your Ecto.Schemas with additional functionality. | ||
|
||
See the [official documentation for EctoModel](https://hexdocs.pm/ecto_model/). | ||
|
||
## Installation | ||
|
||
This package can be installed by adding `ecto_model` to your list of dependencies in `mix.exs`: | ||
|
||
```elixir | ||
def deps do | ||
[ | ||
{:ecto_model, "~> 0.1.0"} | ||
] | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Config | ||
|
||
config :ecto_model, ecto_repos: [EctoModel.Repo], table_schema: "public" | ||
|
||
config :ecto_model, EctoModel.Repo, | ||
database: System.fetch_env!("POSTGRES_DB"), | ||
username: System.fetch_env!("POSTGRES_USER"), | ||
password: System.fetch_env!("POSTGRES_PASSWORD"), | ||
hostname: "localhost" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"default_stop_words": [ | ||
"defmodule", | ||
"defrecord", | ||
"defimpl", | ||
"defexception", | ||
"defprotocol", | ||
"defstruct", | ||
"def.+(.+\\\\.+).+do", | ||
"^\\s+use\\s+" | ||
], | ||
|
||
"custom_stop_words": [ | ||
], | ||
|
||
"coverage_options": { | ||
"treat_no_relevant_lines_as_covered": true, | ||
"output_dir": "cover/", | ||
"minimum_coverage": 100 | ||
}, | ||
|
||
"terminal_options": { | ||
"file_column_width": 40 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: "3.9" | ||
services: | ||
db: | ||
image: postgres | ||
environment: | ||
- POSTGRES_USER | ||
- POSTGRES_DB | ||
- POSTGRES_PASSWORD | ||
ports: | ||
- ${POSTGRES_PORT}:5432 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils }: | ||
flake-utils.lib.eachDefaultSystem ( | ||
system: | ||
let | ||
pkgs = import nixpkgs { inherit system; }; | ||
|
||
# `sha256` can be programmatically obtained via running the following: | ||
# `nix-prefetch-url --unpack https://github.com/elixir-lang/elixir/archive/v${version}.tar.gz` | ||
elixir_1_15_7 = (pkgs.beam.packagesWith pkgs.erlangR26).elixir_1_15.override { | ||
version = "1.15.7"; | ||
sha256 = "0yfp16fm8v0796f1rf1m2r0m2nmgj3qr7478483yp1x5rk4xjrz8"; | ||
}; | ||
in | ||
with pkgs; { | ||
devShells.default = mkShell { | ||
buildInputs = [ elixir_1_15_7 inotify-tools docker-compose ]; | ||
env = { | ||
POSTGRES_PORT="5432"; | ||
POSTGRES_USER = "postgres"; | ||
POSTGRES_PASSWORD = "postgres"; | ||
POSTGRES_DB = "ecto_model_repo"; | ||
}; | ||
}; | ||
} | ||
); | ||
} |
Oops, something went wrong.