diff --git a/doc_rules/elvis_style/max_function_arity.md b/doc_rules/elvis_style/max_function_arity.md index b97eb2c..1ca953c 100644 --- a/doc_rules/elvis_style/max_function_arity.md +++ b/doc_rules/elvis_style/max_function_arity.md @@ -12,7 +12,7 @@ but it applies to regular functions only (not anonymous ones). - `max_arity :: non_neg_integer()`. - default: `8`. -- `non_exported_max_arity :: non_neg_integer()`. +- `non_exported_max_arity :: non_neg_integer() | same`. - default: `8`. ## Example diff --git a/src/elvis_style.erl b/src/elvis_style.erl index c22298f..944a4c2 100644 --- a/src/elvis_style.erl +++ b/src/elvis_style.erl @@ -893,7 +893,9 @@ max_anonymous_function_arity(Config, Target, RuleConfig) -> [elvis_result:item()]. max_function_arity(Config, Target, RuleConfig) -> ExportedMaxArity = option(max_arity, RuleConfig, max_function_arity), - NonExportedMaxArity = option(non_exported_max_arity, RuleConfig, max_function_arity), + NonExportedMaxArity = + specific_or_default(option(non_exported_max_arity, RuleConfig, max_function_arity), + ExportedMaxArity), Root = get_root(Config, Target, RuleConfig), IsFunction = fun(Node) -> ktn_code:type(Node) == function end, Functions = elvis_code:find(IsFunction, Root), diff --git a/test/style_SUITE.erl b/test/style_SUITE.erl index c15e3ac..c5f9d32 100644 --- a/test/style_SUITE.erl +++ b/test/style_SUITE.erl @@ -1048,6 +1048,13 @@ verify_max_function_arity(Config) -> max_function_arity, #{max_arity => 1, non_exported_max_arity => 2}, PathNonExportedFail), + + [_, _, _, _, _] = + elvis_core_apply_rule(Config, + elvis_style, + max_function_arity, + #{max_arity => 3, non_exported_max_arity => same}, + PathNonExportedPass), ok. -spec verify_max_anonymous_function_arity(config()) -> any().