diff --git a/README.md b/README.md index d442e26..6f99270 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,63 @@ rebar3_lint -===== +=== ![build](https://github.com/project-fifo/rebar3_lint/workflows/build/badge.svg) -A rebar plugin - -Build ------ - - $ rebar3 compile +`rebar3_lint` is a `rebar3` plugin to ease the integration of +[elvis](https://github.com/inaka/elvis_core) into your project. Use --- -Add the plugin to your rebar config: +Add the plugin to your `rebar.config`: ```erlang -{profiles, - [ - {lint, [{plugins, [{rebar3_lint, {git, "https://github.com/project-fifo/rebar3_lint.git", {tag, "0.1.11"}}}]}]} - ] -}. +{project_plugins, [ + rebar3_lint +]}. ``` -Then just call your plugin directly in an existing application: - +Then call it: - $ rebar3 as lint lint - ===> Fetching rebar3_lint - ===> Compiling rebar3_lint - - -## Configuration ## +```bash +$ rebar3 lint +===> Fetching rebar3_lint +===> Compiling rebar3_lint + +``` -the plugin supports the following configuration options in the rebar.config: +Configuration +--- -Elvis check configuration (keyword config if placed in application config or -elvis.config file) +The plugin supports configuration option `elvis_output_format` in `rebar.config`: ```erlang -{elvis, [map()]}. +{elvis_output_format, plain | colors | parsable}. % default: colors ``` -Specify output format. Default: colors +It also supports option `elvis` (in `rebar.config`) as you'd find `elvis`'s own +`config` (inside option `elvis`). -```erlang -{elvis_output_format, plain | colors}. -``` +If no `elvis` configuration is present in `rebar.config`, the +plug-in will look for an `elvis.config` file in the project root folder +(but only the `config` section will be applied - this is an `elvis` idiosyncrasy). + +The output format may then be configured separately in `rebar.config`, as previously +explained. -If no `elvis` configuation statement is given in the `rebar.config` file the -plug-in will look for a `elvis.config` file in the project root folder. But -only the config section will be applied (this is an elvis idiosyncrasy). The -output format may be configured separately in the `rebar.config` +This is the default configuration if no input is provided: -[### This is the default if no config is provided ###](src/rebar3_lint_prv.erl#L86-L105) ```erlang -{elvis, - [#{dirs => ["apps/*/src", "src"], - filter => "*.erl", - ruleset => erl_files - }, - #{dirs => ["."], - filter => "Makefile", - ruleset => makefiles - }, - #{dirs => ["."], - filter => "rebar.config", - ruleset => rebar_config - } - #{dirs => ["."], - filter => "elvis.config", - ruleset => elvis_config - } - ] -} +[#{ dirs => ["apps/*/src/**", "src/**"], + filter => "*.erl", + ruleset => erl_files }, + #{ dirs => ["."], + filter => "Makefile", + ruleset => makefiles }, + #{ dirs => ["."], + filter => "rebar.config", + ruleset => rebar_config } + #{ dirs => ["."], + filter => "elvis.config", + ruleset => elvis_config }] ``` diff --git a/rebar.config b/rebar.config index aeebd79..19c40e4 100644 --- a/rebar.config +++ b/rebar.config @@ -1,12 +1,34 @@ -{erl_opts, [debug_info]}. -{deps, [{elvis_core, "~>1.0.0"}]}. +%% == Erlang Compiler == + +{erl_opts, [ + debug_info +]}. + +%% == Dependencies and plugins == + +{deps, [ + {elvis_core, "~>1.0.0"} +]}. + {project_plugins, [rebar3_hex]}. +%% == Dialyzer == + {dialyzer, [ - {warnings, [unmatched_returns, error_handling, underspecs]} + {warnings, [ + error_handling, + underspecs, + unmatched_returns + ]} ]}. +%% == Profiles == + {profiles, [ + {test, [ + {cover_enabled, true}, + {cover_opts, [verbose]} + ]}, {xref, [ {xref_checks, [ deprecated_function_calls, @@ -18,15 +40,17 @@ ]} ]}. -{cover_enabled, true}. +%% == Aliases == -{cover_opts, [verbose]}. +{alias, [ + {test, [xref, dialyzer, ct, cover]} +]}. -{alias, [{test, [dialyzer, ct, cover]}]}. +%% == elvis == {elvis, [ {config, [ - #{ dirs => ["src"], + #{ dirs => ["apps/*/src/**", "src/**"], filter => "*.erl", ruleset => erl_files }, #{ dirs => ["."], @@ -37,4 +61,3 @@ ruleset => elvis_config } ]} ]}. - diff --git a/src/rebar3_lint_prv.erl b/src/rebar3_lint_prv.erl index 2775605..da86cc0 100644 --- a/src/rebar3_lint_prv.erl +++ b/src/rebar3_lint_prv.erl @@ -89,20 +89,12 @@ try_elvis_config_file(State) -> -spec default_config() -> elvis_config:config(). default_config() -> rebar_api:debug("Using default Elvis configuration", []), - [#{dirs => ["apps/*/src", "src"], - filter => "*.erl", - ruleset => erl_files - }, - #{dirs => ["."], - filter => "Makefile", - ruleset => makefiles - }, - #{dirs => ["."], - filter => "rebar.config", - ruleset => rebar_config - } - #{dirs => ["."], - filter => "elvis.config", - ruleset => elvis_config - } - ]. + [#{ dirs => ["apps/*/src/**", "src/**"], + filter => "*.erl", + ruleset => erl_files }, + #{ dirs => ["."], + filter => "rebar.config", + ruleset => rebar_config } + #{ dirs => ["."], + filter => "elvis.config", + ruleset => elvis_config }].