-
Notifications
You must be signed in to change notification settings - Fork 57
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
Showing
10 changed files
with
216 additions
and
27 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 |
---|---|---|
|
@@ -2,8 +2,9 @@ | |
|
||
(since [1.0.0](https://github.com/inaka/elvis_core/releases/tag/1.0.0)) | ||
|
||
All atoms should be named according to the regular expression provided. Atoms enclosed in | ||
apostrophes have special meaning and are thus handled by a different configuration option (use | ||
All atoms should be named according to the regular expression provided. | ||
Except if it matches with a defined `forbidden_regex`. | ||
Atoms enclosed in apostrophes have special meaning and are thus handled by a different configuration option (use | ||
Check failure on line 7 in doc_rules/elvis_style/atom_naming_convention.md GitHub Actions / md_and_ymlLine length
|
||
`same` if you want the same value as `regex`). | ||
|
||
> Works on `.beam` file? Yes! | ||
|
@@ -14,6 +15,8 @@ apostrophes have special meaning and are thus handled by a different configurati | |
- default: `"^([a-z][a-z0-9]*_?)*(_SUITE)?$"`. | ||
- `enclosed_atoms :: string()`. | ||
- default: `".*"`. | ||
- `forbidden_regex :: string() | undefined`. | ||
- default: `undefined`. | ||
|
||
## Example | ||
|
||
|
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
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
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
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
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,14 @@ | ||
-module(forbidden_atom_naming_convention). | ||
|
||
-export([for_test/0]). | ||
|
||
for_test() -> | ||
this_is_an_ok_atom, | ||
'and_so_is_this', | ||
'and_this_1_too', | ||
non_200, | ||
'_', % used by ets/mnesia/etc. | ||
non200, % valid, even without underscores | ||
valid_200even_if_numb3rs_appear_between_letters, | ||
blahblah_SUITE, | ||
x. |
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,31 @@ | ||
-module(forbidden_function_naming_convention). | ||
|
||
-dialyzer({nowarn_function, bad_names_inside/0}). | ||
|
||
-export([bad_names_inside/0]). | ||
|
||
%% Function names must use only lowercase characters. | ||
%% Words in function names must be separated with _. | ||
|
||
%% Cf. https://github.com/inaka/erlang_guidelines#function-names | ||
|
||
bad_names_inside() -> | ||
good_name(should, fail), | ||
not_forbidden_but_still_bad____(should, fail), | ||
no_numbers_1(should, fail), | ||
fun2ms(should, fail). | ||
|
||
%% Private / hidden functions still checked | ||
|
||
good_name(Should, Fail) -> | ||
[Should, Fail]. | ||
|
||
not_forbidden_but_still_bad____(Should, Fail) -> | ||
[Should, Fail]. | ||
|
||
no_numbers_1(Should, Fail) -> | ||
[Should, Fail]. | ||
|
||
fun2ms(Should, Fail) -> | ||
[Should, Fail]. | ||
|
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 @@ | ||
-module(forbidden_module_naming_convention_12). |
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,22 @@ | ||
-module(forbidden_variable_naming_convention). | ||
|
||
-export([should_pass/5]). | ||
-export([should_pass/0, should_pass/1]). | ||
|
||
%% CamelCase must be used for variables. Don’t | ||
%% separate words in variables with _. | ||
|
||
%% Cf. https://github.com/inaka/erlang_guidelines#variable-names | ||
|
||
should_pass(Should, Pass, Way2Home, Fun1, Fun2) -> | ||
[_IgnoredVariable, _] = ["Ignored but valid", "also valid"], | ||
Should = "Should", | ||
Pass = "Pass", | ||
Way2Home = "Way to home", | ||
Fun1 = Should ++ Pass, | ||
Fun2 = Fun1 ++ Way2Home. | ||
|
||
should_pass() -> | ||
?MODULE_STRING. | ||
|
||
should_pass(_) -> ?MODULE_STRING. |
Oops, something went wrong.