From a083332c78b132879a0fb812a633b775ea41534e Mon Sep 17 00:00:00 2001 From: Felipe Ripoll Date: Thu, 9 Feb 2017 06:48:45 -0600 Subject: [PATCH 1/4] [inaka/elvis#41] no_nested_try_catch rule added --- src/elvis_rulesets.erl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/elvis_rulesets.erl b/src/elvis_rulesets.erl index d59d745d..68c6381e 100644 --- a/src/elvis_rulesets.erl +++ b/src/elvis_rulesets.erl @@ -35,6 +35,7 @@ rules(erl_files) -> , variable_naming_convention , #{regex => "^_?([A-Z][0-9a-zA-Z]*)$"} } + , {elvis_style, no_nested_try_catch} ]; rules(makefiles) -> [ {elvis_project, no_deps_master_erlang_mk, #{ignore => []}} From 2d20d8485b92790f052f12b22c2a5539176cf8a3 Mon Sep 17 00:00:00 2001 From: Felipe Ripoll Date: Thu, 9 Feb 2017 11:12:16 -0600 Subject: [PATCH 2/4] [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 44d41b86..f4302c23 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 f2f16b28..552f7839 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 36becb05..def4b097 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 a7b294be..a6349bf5 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]}). From 51249021845e325ec7a83453354a95dfacf3bf04 Mon Sep 17 00:00:00 2001 From: Felipe Ripoll Date: Thu, 9 Feb 2017 12:58:06 -0600 Subject: [PATCH 3/4] [inaka/elvis#402] ct:print added to no_debug_call rule --- src/elvis_style.erl | 5 +++++ test/examples/fail_no_debug_call.erl | 4 +++- test/style_SUITE.erl | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/elvis_style.erl b/src/elvis_style.erl index 552f7839..405befcd 100644 --- a/src/elvis_style.erl +++ b/src/elvis_style.erl @@ -606,6 +606,11 @@ no_debug_call(Config, Target, RuleConfig) -> {Root, _} = elvis_file:parse_tree(Config, Target), ModuleName = elvis_code:module_name(Root), DefaultDebugFuns = [{ct, pal}, + {ct, print, 1}, + {ct, print, 2}, + {ct, print, 3}, + {ct, print, 4}, + {ct, print, 5}, {io, format, 1}, {io, format, 2}], DebugFuns = maps:get(debug_functions, RuleConfig, DefaultDebugFuns), diff --git a/test/examples/fail_no_debug_call.erl b/test/examples/fail_no_debug_call.erl index abbc4ba5..ad23f656 100644 --- a/test/examples/fail_no_debug_call.erl +++ b/test/examples/fail_no_debug_call.erl @@ -11,4 +11,6 @@ fail() -> % Sending explicit io to a device is not considered debugging io:format(user, "Not a debug print ~s~n", ["Not debug"]), ct:pal("Debug"), - ct:pal("Debug ~s", ["Debug Info"]). + ct:pal("Debug ~s", ["Debug Info"]), + ct:print("Debug"), + ct:print("Debug ~s", ["Debug Info"]). diff --git a/test/style_SUITE.erl b/test/style_SUITE.erl index a6349bf5..343622d4 100644 --- a/test/style_SUITE.erl +++ b/test/style_SUITE.erl @@ -525,7 +525,7 @@ verify_no_debug_call(_Config) -> PathFail = "fail_no_debug_call.erl", {ok, FileFail} = elvis_test_utils:find_file(SrcDirs, PathFail), - [_, _, _, _] = elvis_style:no_debug_call(ElvisConfig, FileFail, #{}), + [_, _, _, _, _, _] = elvis_style:no_debug_call(ElvisConfig, FileFail, #{}), RuleConfig = #{ignore => [fail_no_debug_call]}, [] = elvis_style:no_debug_call(ElvisConfig, FileFail, RuleConfig), @@ -538,7 +538,10 @@ verify_no_debug_call(_Config) -> RuleConfig4 = #{debug_functions => [{io, format}]}, [_, _, _] = - elvis_style:no_debug_call(ElvisConfig, FileFail, RuleConfig4). + elvis_style:no_debug_call(ElvisConfig, FileFail, RuleConfig4), + + RuleConfig5 = #{debug_functions => [{ct, print}]}, + [_, _] = elvis_style:no_debug_call(ElvisConfig, FileFail, RuleConfig5). -spec verify_no_nested_try_catch(config()) -> any(). verify_no_nested_try_catch(_Config) -> From 64cd0768a1660238987d9f640afb6f47281ea93b Mon Sep 17 00:00:00 2001 From: Felipe Ripoll Date: Thu, 9 Feb 2017 13:48:56 -0600 Subject: [PATCH 4/4] [inaka/elvis#423] Version Bump to 0.3.5 --- CHANGELOG.md | 18 ++++++++++++++++++ src/elvis.app.src | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41bfcd62..08060c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,28 @@ # Change Log +## [0.3.5](https://github.com/inaka/elvis_core/tree/0.3.5) (2017-02-09) +[Full Changelog](https://github.com/inaka/elvis_core/compare/0.3.5-pre...0.3.5) + +**Merged pull requests:** + +- \[inaka/elvis\#402\] ct:print added to no\_debug\_call rule [\#77](https://github.com/inaka/elvis_core/pull/77) ([ferigis](https://github.com/ferigis)) +- \[inaka/elvis\#406\] dialyzer warnings fixed [\#76](https://github.com/inaka/elvis_core/pull/76) ([ferigis](https://github.com/ferigis)) +- \[inaka/elvis\#410\] no\_nested\_try\_catch rule added [\#75](https://github.com/inaka/elvis_core/pull/75) ([ferigis](https://github.com/ferigis)) + +## [0.3.5-pre](https://github.com/inaka/elvis_core/tree/0.3.5-pre) (2017-02-08) +[Full Changelog](https://github.com/inaka/elvis_core/compare/0.3.4...0.3.5-pre) + +**Merged pull requests:** + +- \[inaka/elvis\#424\] updating dependencies [\#74](https://github.com/inaka/elvis_core/pull/74) ([ferigis](https://github.com/ferigis)) +- Fix unnecessary loading of files caused by git-branch option \(\#421\) [\#72](https://github.com/inaka/elvis_core/pull/72) ([onno-vos-dev](https://github.com/onno-vos-dev)) + ## [0.3.4](https://github.com/inaka/elvis_core/tree/0.3.4) (2016-11-15) [Full Changelog](https://github.com/inaka/elvis_core/compare/0.3.3...0.3.4) **Merged pull requests:** +- \[Close inaka/elvis\#417\] bump version to 0.3.4 - elvis\_core [\#71](https://github.com/inaka/elvis_core/pull/71) ([Euen](https://github.com/Euen)) - \[Close inaka/elvis\#416\] update wrong file type [\#70](https://github.com/inaka/elvis_core/pull/70) ([Euen](https://github.com/Euen)) ## [0.3.3](https://github.com/inaka/elvis_core/tree/0.3.3) (2016-11-11) diff --git a/src/elvis.app.src b/src/elvis.app.src index dac3b48a..fdadea10 100644 --- a/src/elvis.app.src +++ b/src/elvis.app.src @@ -3,7 +3,7 @@ [ {pkg_name, elvis_core}, {description, "Core library for the Erlang style reviewer"}, - {vsn, "0.3.4"}, + {vsn, "0.3.5"}, {applications, [kernel, stdlib, lager, zipper, katana_code]}, {modules, [