From 2d20d8485b92790f052f12b22c2a5539176cf8a3 Mon Sep 17 00:00:00 2001 From: Felipe Ripoll Date: Thu, 9 Feb 2017 11:12:16 -0600 Subject: [PATCH] [inaka/elvis#406] dialyzer warnings fixed --- src/elvis_project.erl | 6 ++++-- src/elvis_style.erl | 16 ++++++++++++---- test/examples/fail_macro_module_names.erl | 6 +++--- test/style_SUITE.erl | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/elvis_project.erl b/src/elvis_project.erl index 44d41b8..f4302c2 100644 --- a/src/elvis_project.erl +++ b/src/elvis_project.erl @@ -28,7 +28,8 @@ %% Rules %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type protocol_for_deps_erlang_mk_config() :: #{ignore => [module()]}. +-type protocol_for_deps_erlang_mk_config() :: #{ignore => [module()], + regex => string()}. %% Deprecated -spec git_for_deps_erlang_mk(elvis_config:config(), @@ -55,7 +56,8 @@ protocol_for_deps_erlang_mk(_Config, Target, RuleConfig) -> erlang_mk_dep_to_result(Line, ?DEP_NO_GIT, {IgnoreDeps, Regex}) end, BadDeps). --type protocol_for_deps_rebar_config() :: #{ignore => [module()]}. +-type protocol_for_deps_rebar_config() :: #{ignore => [module()], + regex => string()}. -spec git_for_deps_rebar(elvis_config:config(), elvis_file:file(), diff --git a/src/elvis_style.erl b/src/elvis_style.erl index f2f16b2..552f783 100644 --- a/src/elvis_style.erl +++ b/src/elvis_style.erl @@ -129,7 +129,9 @@ -type empty_rule_config() :: #{}. -type max_function_length_config() :: #{ignore_functions => [function_spec()], - max_length => non_neg_integer()}. + max_length => non_neg_integer(), + count_comments => boolean(), + count_whitespace => boolean()}. -type max_module_length_config() :: #{count_comments => boolean(), count_whitespace => boolean(), @@ -262,7 +264,8 @@ operator_spaces(Config, Target, RuleConfig) -> Rules ). --type nesting_level_config() :: #{level => integer()}. +-type nesting_level_config() :: #{level => integer(), + ignore => [atom()]}. -spec nesting_level(elvis_config:config(), elvis_file:file(), @@ -282,7 +285,8 @@ nesting_level(Config, Target, RuleConfig) -> [] end. --type god_modules_config() :: #{limit => integer()}. +-type god_modules_config() :: #{limit => integer(), + ignore => [atom()]}. -spec god_modules(elvis_config:config(), elvis_file:file(), @@ -456,9 +460,13 @@ no_spec_with_records(Config, Target, _RuleConfig) -> lists:map(ResultFun, SpecNodes) end. +-type dont_repeat_yourself_config() :: #{min_complexity => non_neg_integer(), + ignore => [module()] + }. + -spec dont_repeat_yourself(elvis_config:config(), elvis_file:file(), - empty_rule_config()) -> + dont_repeat_yourself_config()) -> [elvis_result:item()]. dont_repeat_yourself(Config, Target, RuleConfig) -> MinComplexity = maps:get(min_complexity, RuleConfig, 5), diff --git a/test/examples/fail_macro_module_names.erl b/test/examples/fail_macro_module_names.erl index 36becb0..def4b09 100644 --- a/test/examples/fail_macro_module_names.erl +++ b/test/examples/fail_macro_module_names.erl @@ -12,7 +12,7 @@ build_binary/0 ]). --define(FUNCTION_NAME, function_name). +-define(FUN_NAME, function_name). -define(BINARY, "bla"). -define(BINARY_SIZE, 3). -define(function_name, function_name). @@ -23,8 +23,8 @@ module_name() -> ?module_name:?function_name(). function_name() -> - module:?FUNCTION_NAME(params), - module:?FUNCTION_NAME (params), + module:?FUN_NAME(params), + module:?FUN_NAME (params), lists:?MODULE(). build_binary() -> diff --git a/test/style_SUITE.erl b/test/style_SUITE.erl index a7b294b..a6349bf 100644 --- a/test/style_SUITE.erl +++ b/test/style_SUITE.erl @@ -253,7 +253,7 @@ verify_nesting_level(_Config) -> #{line_num := 78}, #{line_num := 120}, #{line_num := 166} - ] = elvis_style:nesting_level(ElvisConfig, File, #{limit => 3}), + ] = elvis_style:nesting_level(ElvisConfig, File, #{level => 3}), [] = elvis_style:nesting_level( ElvisConfig , File , #{ignore => [fail_nesting_level]}).