Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc_rules/elvis_style/no_debug_call.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ lead to performance degradation, unwanted output, or inconsistent logging behavi
- default: `[{ct, pal}, {ct, print}, {io, format, 1}, {io, format, 2}, {erlang, display, 1},
{io, put_chars, 1}, {io, put_chars, 2}]`

`{erlang, display, 1}` was added in [1.5.0](https://github.com/inaka/elvis_core/releases/tag/1.5.0)).
`{erlang, display, 1}` was added in [1.5.0](https://github.com/inaka/elvis_core/releases/tag/1.5.0).

`{io, put_chars, 1}, {io, put_chars, 2}` was added in [4.0.0](https://github.com/inaka/elvis_core/releases/tag/4.0.0)).
`{io, put_chars, 1}, {io, put_chars, 2}` was added in [4.0.0](https://github.com/inaka/elvis_core/releases/tag/4.0.0).

## Example configuration

Expand Down
2 changes: 1 addition & 1 deletion doc_rules/elvis_style/no_space.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ codebase.
- default: `[{right, "("}, {left, ")"}, {left, ","}, {left, ":"}, {right, "#"}, {right, "?"},
{right, "?"}]`

`{right, "#"}, {right, "?"}` was added in [4.0.0](https://github.com/inaka/elvis_core/releases/tag/4.0.0)).
`{right, "#"}, {right, "?"}` was added in [4.0.0](https://github.com/inaka/elvis_core/releases/tag/4.0.0).

## Example configuration

Expand Down
57 changes: 29 additions & 28 deletions doc_rules/elvis_style/operator_spaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,44 @@ compromised without adequate spacing.
- default:

```erlang
[{left, "!"}, {right, "!"}, {left, "*"}, {right, "*"}
, {left, "+"}, {right, "+"}, {left, "++"}, {right, "++"}
, {left, "-"}, {right, "-"}, {left, "--"}, {right, "--"}
, {left, "->"}, {right, "->"}, {left, "/"}, {right, "/"}
, {left, "/="}, {right, "/="}, {left, "::"}, {right, "::"}
, {left, ":="}, {right, ":="}, {left, "<"}, {right, "<"}
, {left, "<-"}, {right, "<-"}, {left, "<="}, {right, "<="}
, {left, "="}, {right, "="}, {left, "=/="}, {right, "=/="}
, {left, "=:="}, {right, "=:="}, {left, "=<"}, {right, "=<"}
, {left, "=="}, {right, "=="}, {left, "=>"}, {right, "=>"}
, {left, ">"}, {right, ">"}, {left, ">="}, {right, ">="}
, {left, "|"}, {right, "|"}, {left, "||"}, {right, "||"}
, {right, ","}]
[{right, "++"}, {left, "++"}, {right, "="}, {left, "="}
, {right, "+"}, {left, "+"}, {right, "-"}, {left, "-"}
, {right, "*"}, {left, "*"}, {right, "/"}, {left, "/"}
, {right, "=<"}, {left, "=<"}, {right, "<"}, {left, "<"}
, {right, ">"}, {left, ">"}, {right, ">="}, {left, ">="}
, {right, "=="}, {left, "=="}, {right, "=:="}, {left, "=:="}
, {right, "/="}, {left, "/="}, {right, "=/="}, {left, "=/="}
, {right, "--"}, {left, "--"}, {right, "=>"}, {left, "=>"}
, {right, ":="}, {left, ":="}, {right, "<-"}, {left, "<-"}
, {right, "<="}, {left, "<="}, {right, "||"}, {left, "||"}
, {right, "|"}, {left, "|"}, {right, "::"}, {left, "::"}
, {right, "->"}, {left, "->"}, {right, ","}, {right, "!"}
, {left, "!"}, {right, "?="}, {left, "?="}
]
```

`rules` was `[{right, ","}, {right, "++"}, {left, "++"}]` until [1.5.0](https://github.com/inaka/elvis_core/releases/tag/1.5.0).

`{left, "!"}, {right, "!"}` was added in [4.0.0](https://github.com/inaka/elvis_core/releases/tag/4.0.0)).
`{right, "!"}, {left, "!"}` was added in [4.0.0](https://github.com/inaka/elvis_core/releases/tag/4.0.0).

`{left, "?="}, {right, "?="}` was added in [4.1.0](https://github.com/inaka/elvis_core/releases/tag/4.1.0)).
`{right, "?="}, {left, "?="}` was added in [4.1.0](https://github.com/inaka/elvis_core/releases/tag/4.1.0).

## Example configuration

```erlang
{elvis_style, operator_spaces, #{ rules => [{left, "!"}, {right, "!"}, {left, "*"}, {right, "*"}
, {left, "+"}, {right, "+"}, {left, "++"}, {right, "++"}
, {left, "-"}, {right, "-"}, {left, "--"}, {right, "--"}
, {left, "->"}, {right, "->"}, {left, "/"}, {right, "/"}
, {left, "/="}, {right, "/="}, {left, "::"}, {right, "::"}
, {left, ":="}, {right, ":="}, {left, "<"}, {right, "<"}
, {left, "<-"}, {right, "<-"}, {left, "<="}, {right, "<="}
, {left, "="}, {right, "="}, {left, "=/="}, {right, "=/="}
, {left, "=:="}, {right, "=:="}, {left, "=<"}, {right, "=<"}
, {left, "=="}, {right, "=="}, {left, "=>"}, {right, "=>"}
, {left, ">"}, {right, ">"}, {left, ">="}, {right, ">="}
, {left, "|"}, {right, "|"}, {left, "||"}, {right, "||"}
, {right, ","}
{elvis_style, operator_spaces, #{ rules => [{right, "++"}, {left, "++"}, {right, "="}, {left, "="}
, {right, "+"}, {left, "+"}, {right, "-"}, {left, "-"}
, {right, "*"}, {left, "*"}, {right, "/"}, {left, "/"}
, {right, "=<"}, {left, "=<"}, {right, "<"}, {left, "<"}
, {right, ">"}, {left, ">"}, {right, ">="}, {left, ">="}
, {right, "=="}, {left, "=="}, {right, "=:="}, {left, "=:="}
, {right, "/="}, {left, "/="}, {right, "=/="}, {left, "=/="}
, {right, "--"}, {left, "--"}, {right, "=>"}, {left, "=>"}
, {right, ":="}, {left, ":="}, {right, "<-"}, {left, "<-"}
, {right, "<="}, {left, "<="}, {right, "||"}, {left, "||"}
, {right, "|"}, {left, "|"}, {right, "::"}, {left, "::"}
, {right, "->"}, {left, "->"}, {right, ","}, {right, "!"}
, {left, "!"}, {right, "?="}, {left, "?="}
]
}}
```
1 change: 1 addition & 0 deletions doc_rules/elvis_style/state_record_and_type.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ corresponding state type (public - `type()` - or private - `opaque`).
- `gen_server`
- `gen_event` [![](https://img.shields.io/badge/since-0.7.0-blue)](https://github.com/inaka/elvis_core/releases/tag/0.7.0)
- `gen_fsm`
- `gen_statem` [![](https://img.shields.io/badge/since-0.7.0-blue)](https://github.com/inaka/elvis_core/releases/tag/0.7.0)
- `supervisor_bridge`

**Note**: if used together with `export_used_types`, the `state` record **should be** defined as a
Expand Down
2 changes: 1 addition & 1 deletion src/elvis_style.erl
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ default(operator_spaces) ->
{right, "->"},
{left, "->"},
{right, ","},
{left, "!"},
{right, "!"},
{left, "!"},
{right, "?="},
{left, "?="}
]
Expand Down
3 changes: 0 additions & 3 deletions test/examples/fail_macro_module_names.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
module_name() ->
?MODULE:function_name(),
?module_name:?function_name(),
?module_name:function_name(with, arguments),
?MODULE:?function_name(with, arguments),
?module_name:?function_name(with, arguments),
?function_name(with, arguments).

function_name() ->
Expand Down
8 changes: 0 additions & 8 deletions test/examples/fail_used_ignored_variable.erl
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
-module(fail_used_ignored_variable).

-if(?OTP_RELEASE >= 25).

-feature(maybe_expr, enable).

-endif.

-export([ use_ignored_var/2
, use_ignored_var_in_fun/2
, no_used_ignored_vars_here/2, handle_call/3
Expand All @@ -14,8 +10,6 @@

-elvis([{elvis_style, no_macros, #{allow => ['__']}}]).

-if(?OTP_RELEASE >= 25).

-export([no_used_ignored_vars_in_maybe/2]).

no_used_ignored_vars_in_maybe(One, _Two) ->
Expand All @@ -25,8 +19,6 @@ no_used_ignored_vars_in_maybe(One, _Two) ->
One
end.

-endif.

use_ignored_var(_One, Two) ->
Three = _One + Two,
case Three of
Expand Down
3 changes: 2 additions & 1 deletion test/examples/no_init_lists_examples/fail_no_init_lists5.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-module(fail_no_init_lists5).

-if(?OTP_RELEASE < 28).
-behaviour(gen_fsm).

-export([init/1, handle_sync_event/4, handle_event/3]).
Expand All @@ -9,4 +10,4 @@ init([]) -> {error, "Don't use list for init/1"}.
handle_sync_event(_, _, _, _) -> ok.

handle_event(_, _, _) -> ok.

-endif.
10 changes: 0 additions & 10 deletions test/examples/pass_maybe.erl
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
-module(pass_maybe).

-if(?OTP_RELEASE >= 25).

-feature(maybe_expr, enable).

-endif.

-export([sum_numbers/2]).


-if(?OTP_RELEASE >= 25).
sum_numbers(Number1, Number2) ->
maybe
ValidNumber1 ?= validate_number(Number1),
Expand All @@ -24,7 +18,3 @@ validate_number(Number) when is_number(Number) ->
Number;
validate_number(_) ->
{error, invalid_number}.
-else.
sum_numbers(Number1, Number2) ->
Number1 + Number2.
-endif.
14 changes: 5 additions & 9 deletions test/style_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,9 @@ verify_macro_module_names(Config) ->
[
#{line_num := 24},
#{line_num := 24},
#{line_num := 25},
#{line_num := 26},
#{line_num := 27},
#{line_num := 27},
#{line_num := 31},
#{line_num := 32},
#{line_num := 33}
#{line_num := 28},
#{line_num := 29},
#{line_num := 30}
] =
elvis_core_apply_rule(Config, elvis_style, macro_module_names, #{}, Path).

Expand Down Expand Up @@ -725,8 +721,8 @@ verify_operator_spaces(Config) ->
#{info := [left, "||" | _]},
#{info := [right, "|" | _]},
#{info := [left, "|" | _]},
#{info := [left, "!" | _]},
#{info := [right, "!" | _]},
#{info := [left, "!" | _]},
#{info := [right, "?=" | _]},
#{info := [left, "?=" | _]}
] =
Expand Down Expand Up @@ -923,7 +919,7 @@ verify_used_ignored_variable(Config) ->
[#{line_num := _}, #{line_num := _}, #{line_num := _}, #{line_num := _}] =
elvis_core_apply_rule(Config, elvis_style, used_ignored_variable, #{}, Path);
erl_files ->
[#{line_num := 31}, #{line_num := 34}, #{line_num := 38}, #{line_num := 38}] =
[#{line_num := 23}, #{line_num := 26}, #{line_num := 30}, #{line_num := 30}] =
elvis_core_apply_rule(Config, elvis_style, used_ignored_variable, #{}, Path),
[] = elvis_core_apply_rule(Config, elvis_style, used_ignored_variable, #{}, Path2)
end,
Expand Down