Skip to content

Commit

Permalink
Merge pull request #24 from paulo-ferraz-oliveira/feature/improved_re…
Browse files Browse the repository at this point in the history
…adme

Improve README.md and rebar.config
  • Loading branch information
paulo-ferraz-oliveira authored Jan 22, 2021
2 parents 7abe17a + ad7fb96 commit aabfa13
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 78 deletions.
92 changes: 39 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
<Plugin Output>

## Configuration ##
```bash
$ rebar3 lint
===> Fetching rebar3_lint
===> Compiling rebar3_lint
<plugin output>
```

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 }]
```
39 changes: 31 additions & 8 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 => ["."],
Expand All @@ -37,4 +61,3 @@
ruleset => elvis_config }
]}
]}.

26 changes: 9 additions & 17 deletions src/rebar3_lint_prv.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }].

0 comments on commit aabfa13

Please sign in to comment.