Skip to content

Commit

Permalink
Generate the project
Browse files Browse the repository at this point in the history
  • Loading branch information
ejpcmac committed Apr 23, 2019
0 parents commit febf2e4
Show file tree
Hide file tree
Showing 19 changed files with 774 additions and 0 deletions.
167 changes: 167 additions & 0 deletions .credo.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# This file contains the configuration for Credo and you are probably reading
# this after creating it with `mix credo.gen.config`.
#
# If you find anything wrong or unclear in this file, please report an
# issue on GitHub: https://github.com/rrrene/credo/issues
#
%{
#
# You can have as many configs as you like in the `configs:` field.
configs: [
%{
#
# Run any exec using `mix credo -C <name>`. If no exec name is given
# "default" is used.
#
name: "default",
#
# These are the files included in the analysis:
files: %{
#
# You can give explicit globs or simply directories.
# In the latter case `**/*.{ex,exs}` will be used.
#
included: ["lib/", "src/", "test/", "web/", "apps/"],
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
},
#
# If you create your own checks, you must specify the source files for
# them here, so they can be loaded by Credo before running the analysis.
#
requires: [],
#
# If you want to enforce a style guide and need a more traditional linting
# experience, you can change `strict` to `true` below:
#
strict: true,
#
# If you want to use uncolored output by default, you can change `color`
# to `false` below:
#
color: true,
#
# You can customize the parameters of any check by adding a second element
# to the tuple.
#
# To disable a check put `false` as second element:
#
# {Credo.Check.Design.DuplicatedCode, false}
#
checks: [
#
## Consistency Checks
#
{Credo.Check.Consistency.ExceptionNames, []},
{Credo.Check.Consistency.LineEndings, []},
{Credo.Check.Consistency.ParameterPatternMatching, []},
{Credo.Check.Consistency.SpaceAroundOperators, []},
{Credo.Check.Consistency.SpaceInParentheses, []},
{Credo.Check.Consistency.TabsOrSpaces, []},

#
## Design Checks
#
# You can customize the priority of any check
# Priority values are: `low, normal, high, higher`
#
{Credo.Check.Design.AliasUsage,
[
priority: :low,
if_nested_deeper_than: 2,
if_called_more_often_than: 0
]},
# For some checks, you can also set other parameters
#
# If you don't want the `setup` and `test` macro calls in ExUnit tests
# or the `schema` macro in Ecto schemas to trigger DuplicatedCode, just
# set the `excluded_macros` parameter to `[:schema, :setup, :test]`.
#
{Credo.Check.Design.DuplicatedCode, [excluded_macros: []]},
# You can also customize the exit_status of each check.
# If you don't want TODO comments to cause `mix credo` to fail, just
# set this value to 0 (zero).
#
{Credo.Check.Design.TagTODO, [exit_status: 0]},
{Credo.Check.Design.TagFIXME, []},

#
## Readability Checks
#
{Credo.Check.Readability.AliasOrder, []},
{Credo.Check.Readability.FunctionNames, []},
{Credo.Check.Readability.LargeNumbers, []},
{Credo.Check.Readability.MaxLineLength,
[priority: :low, max_length: 80]},
{Credo.Check.Readability.ModuleAttributeNames, []},
{Credo.Check.Readability.ModuleDoc, []},
{Credo.Check.Readability.ModuleNames, []},
{Credo.Check.Readability.ParenthesesInCondition, []},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
{Credo.Check.Readability.PredicateFunctionNames, []},
{Credo.Check.Readability.PreferImplicitTry, []},
{Credo.Check.Readability.RedundantBlankLines, []},
{Credo.Check.Readability.Semicolons, []},
{Credo.Check.Readability.SpaceAfterCommas, []},
{Credo.Check.Readability.StringSigils, []},
{Credo.Check.Readability.TrailingBlankLine, []},
{Credo.Check.Readability.TrailingWhiteSpace, []},
{Credo.Check.Readability.VariableNames, []},

#
## Refactoring Opportunities
#
{Credo.Check.Refactor.CondStatements, []},
{Credo.Check.Refactor.CyclomaticComplexity, []},
{Credo.Check.Refactor.FunctionArity, []},
{Credo.Check.Refactor.LongQuoteBlocks, []},
{Credo.Check.Refactor.MatchInCondition, []},
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.Nesting, []},
{Credo.Check.Refactor.PipeChainStart,
[
excluded_argument_types: [:atom, :binary, :fn, :keyword],
excluded_functions: []
]},
{Credo.Check.Refactor.UnlessWithElse, []},

#
## Warnings
#
{Credo.Check.Warning.BoolOperationOnSameValues, []},
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
{Credo.Check.Warning.IExPry, []},
{Credo.Check.Warning.IoInspect, []},
{Credo.Check.Warning.OperationOnSameValues, []},
{Credo.Check.Warning.OperationWithConstantResult, []},
{Credo.Check.Warning.RaiseInsideRescue, []},
{Credo.Check.Warning.UnusedEnumOperation, []},
{Credo.Check.Warning.UnusedFileOperation, []},
{Credo.Check.Warning.UnusedKeywordOperation, []},
{Credo.Check.Warning.UnusedListOperation, []},
{Credo.Check.Warning.UnusedPathOperation, []},
{Credo.Check.Warning.UnusedRegexOperation, []},
{Credo.Check.Warning.UnusedStringOperation, []},
{Credo.Check.Warning.UnusedTupleOperation, []},

#
# Controversial and experimental checks (opt-in, just remove `, false`)
#
{Credo.Check.Consistency.MultiAliasImportRequireUse, false},
{Credo.Check.Readability.Specs, false},
{Credo.Check.Refactor.ABCSize, false},
{Credo.Check.Refactor.AppendSingleItem, false},
{Credo.Check.Refactor.DoubleBooleanNegation, false},
{Credo.Check.Refactor.MapInto, false},
{Credo.Check.Refactor.VariableRebinding, false},
{Credo.Check.Warning.LazyLogging, false},
{Credo.Check.Warning.MapGetUnsafePass, false},
{Credo.Check.Warning.UnsafeToAtom, false}

#
# Custom checks can be created using `mix credo.gen.check`.
#
]
}
]
}
1 change: 1 addition & 0 deletions .dialyzer_ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EditorConfig is awesome: http://EditorConfig.org

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
max_line_length = 80
trim_trailing_whitespace = true
insert_final_newline = true

[*.{md,sh}]
indent_size = 4

[*.md]
trim_trailing_whitespace = false
84 changes: 84 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
####################################
# Environment setup for Nix shells #
####################################

# From https://github.com/direnv/direnv/wiki/Nix#persistent-cached-shell
#
# Usage: use_nix [...]
#
# Load environment variables from `nix-shell`.
# If you have a `default.nix` or `shell.nix` one of these will be used and
# the derived environment will be stored at ./.direnv/env-<hash>
# and symlink to it will be created at ./.direnv/default.
# Dependencies are added to the GC roots, such that the environment remains persistent.
#
# Packages can also be specified directly via e.g `use nix -p ocaml`,
# however those will not be added to the GC roots.
#
# The resulting environment is cached for better performance.
#
# To trigger switch to a different environment:
# `rm -f .direnv/default`
#
# To derive a new environment:
# `rm -rf .direnv/env-$(md5sum {shell,default}.nix 2> /dev/null | cut -c -32)`
#
# To remove cache:
# `rm -f .direnv/dump-*`
#
# To remove all environments:
# `rm -rf .direnv/env-*`
#
# To remove only old environments:
# `find .direnv -name 'env-*' -and -not -name `readlink .direnv/default` -exec rm -rf {} +`
#
use_nix() {
set -e

local shell="shell.nix"
if [[ ! -f "${shell}" ]]; then
shell="default.nix"
fi

if [[ ! -f "${shell}" ]]; then
fail "use nix: shell.nix or default.nix not found in the folder"
fi

local dir="${PWD}"/.direnv
local default="${dir}/default"
if [[ ! -L "${default}" ]] || [[ ! -d `readlink "${default}"` ]]; then
local wd="${dir}/env-`md5sum "${shell}" | cut -c -32`" # TODO: Hash also the nixpkgs version?
mkdir -p "${wd}"

local drv="${wd}/env.drv"
if [[ ! -f "${drv}" ]]; then
log_status "use nix: deriving new environment"
IN_NIX_SHELL=1 nix-instantiate --add-root "${drv}" --indirect "${shell}" > /dev/null
nix-store -r `nix-store --query --references "${drv}"` --add-root "${wd}/dep" --indirect > /dev/null
fi

rm -f "${default}"
ln -s `basename "${wd}"` "${default}"
fi

local drv=`readlink -f "${default}/env.drv"`
local dump="${dir}/dump-`md5sum ".envrc" | cut -c -32`-`md5sum ${drv} | cut -c -32`"

if [[ ! -f "${dump}" ]] || [[ "${XDG_CONFIG_DIR}/direnv/direnvrc" -nt "${dump}" ]]; then
log_status "use nix: updating cache"

old=`find "${dir}" -name 'dump-*'`
nix-shell "${drv}" --show-trace "$@" --run 'direnv dump' > "${dump}"
rm -f ${old}
fi

direnv_load cat "${dump}"

watch_file "${default}"
watch_file shell.nix
if [[ ${shell} == "default.nix" ]]; then
watch_file default.nix
fi
}

use nix
7 changes: 7 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
inputs: [
"{mix,.iex,.formatter,.credo}.exs",
"{config,lib,rel,test}/**/*.{ex,exs}"
],
line_length: 80
]
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##
## Application artifacts
##

# direnv cache for Nix shells
/.direnv/

# Elixir build directory
/_build/

# Elixir dependencies
/deps/
/.fetch

# Elixir binary files
*.beam
*.ez
/typed_struct_lens-*.tar
/typed_struct_lens

# Test coverage and documentation
/cover/
/doc/

##
## Editor artifacts
##

/.elixir_ls/
/.history/

##
## Crash dumps
##

# Erang VM
erl_crash.dump
11 changes: 11 additions & 0 deletions .gitsetup
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -e
set -x

# Setup git-flow
git flow init -d
git config gitflow.prefix.versiontag "v"
git config gitflow.feature.finish.no-ff true
git config gitflow.release.finish.sign true
git config gitflow.hotfix.finish.sign true
29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
language: elixir
elixir:
- 1.6
- 1.7
- 1.8
otp_release:
- 19.3
- 20.3
- 21.2
matrix:
exclude:
- elixir: 1.8
otp_release: 19.3
env:
- PLT_DIR=$HOME/.plt
before_script:
- mkdir -p $PLT_DIR
- mix deps.compile
- MIX_ENV=test mix deps.compile
- travis_wait mix dialyzer --plt
script:
- mix compile --force --verbose --warnings-as-errors
- mix test --trace
- mix dialyzer --no-compile --no-check --halt-exit-status
- mix credo
- if [[ "$TRAVIS_ELIXIR_VERSION" == "1.8.1" ]]; then mix format --check-formatted; fi
cache:
directories:
- $PLT_DIR
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 0.1.0-dev

* Initial version
Loading

0 comments on commit febf2e4

Please sign in to comment.