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
2 changes: 1 addition & 1 deletion RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Most, if not all, of the rules will present (opinionated) documentation sections
- [No Init Lists](doc_rules/elvis_style/no_init_lists.md)
- [No Macros](doc_rules/elvis_style/no_macros.md)
- [No Match In Condition](doc_rules/elvis_style/no_match_in_condition.md)
- [No Nested Header Files](doc_rules/elvis_style/no_nested_hrls.md)
- [No Includes](doc_rules/elvis_style/no_includes.md)
- [No Nested `try...catch` Blocks](doc_rules/elvis_style/no_nested_try_catch.md)
- [No Operator With Same Values](doc_rules/elvis_style/no_operation_on_same_value.md)
- [No Redundant Blank Lines](doc_rules/elvis_text_style/no_redundant_blank_lines.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# No Nested Header Files [![](https://img.shields.io/badge/since-4.1.0-blue)](https://github.com/inaka/elvis_core/releases/tag/4.1.0) ![](https://img.shields.io/badge/HRL--only-yes-magenta)
# No Includes [![](https://img.shields.io/badge/since-4.1.0-blue)](https://github.com/inaka/elvis_core/releases/tag/4.1.0) ![](https://img.shields.io/badge/HRL--only-yes-magenta)

> [!NOTE]
> This rule was named `no_nested_hrls` before [4.2.0](https://github.com/inaka/elvis_core/releases/tag/4.2.0).

`-include` and `-include_lib` attributes **in header files** should be avoided.

Expand Down Expand Up @@ -28,5 +31,5 @@ The code becomes unnecessarily complex and harder to maintain.
## Example configuration

```erlang
{elvis_style, no_nested_hrls, #{}}
{elvis_style, no_includes, #{}}
```
2 changes: 1 addition & 1 deletion src/elvis_ruleset.erl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ hrl_files_rules() ->

hrl_only_files_rules() ->
[
elvis_rule:new(elvis_style, no_nested_hrls),
elvis_rule:new(elvis_style, no_includes),
elvis_rule:new(elvis_style, no_specs),
elvis_rule:new(elvis_style, no_types)
].
Expand Down
4 changes: 2 additions & 2 deletions src/elvis_style.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
no_macros/2,
no_specs/2,
no_types/2,
no_nested_hrls/2,
no_includes/2,
no_block_expressions/2,
operator_spaces/2,
no_space/2,
Expand Down Expand Up @@ -555,7 +555,7 @@ no_types(Rule, ElvisConfig) ->
|| TypeAttrNode <- TypeAttrNodes
].

no_nested_hrls(Rule, ElvisConfig) ->
no_includes(Rule, ElvisConfig) ->
{nodes, IncludeNodes} = elvis_code:find(#{
of_types => [include, include_lib],
inside => elvis_code:root(Rule, ElvisConfig)
Expand Down
12 changes: 6 additions & 6 deletions test/style_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
verify_always_shortcircuit/1,
verify_consistent_generic_type/1,
verify_no_types/1,
verify_no_nested_hrls/1,
verify_no_includes/1,
verify_no_specs/1,
verify_export_used_types/1,
verify_consistent_variable_casing/1,
Expand Down Expand Up @@ -472,14 +472,14 @@ verify_no_types(Config) ->
PathPass = "pass_no_types.hrl",
[] = elvis_test_utils:elvis_core_apply_rule(Config, elvis_style, no_types, #{}, PathPass).

verify_no_nested_hrls(Config) ->
PathFail = "fail_no_nested_hrls.hrl",
verify_no_includes(Config) ->
PathFail = "fail_no_includes.hrl",
[#{line_num := 1}, #{line_num := 2}] = elvis_test_utils:elvis_core_apply_rule(
Config, elvis_style, no_nested_hrls, #{}, PathFail
Config, elvis_style, no_includes, #{}, PathFail
),

PathPass = "pass_no_nested_hrls.hrl",
[] = elvis_test_utils:elvis_core_apply_rule(Config, elvis_style, no_nested_hrls, #{}, PathPass).
PathPass = "pass_no_includes.hrl",
[] = elvis_test_utils:elvis_core_apply_rule(Config, elvis_style, no_includes, #{}, PathPass).

verify_no_specs(Config) ->
PathFail = "fail_no_specs.hrl",
Expand Down
Loading