From adf1d403ddb8db697a1883a70c818496b4ad763e Mon Sep 17 00:00:00 2001 From: Paulo Oliveira Date: Wed, 5 Aug 2020 17:51:13 +0100 Subject: [PATCH 1/2] Allow use of rebar_raw_resource in rebar3 -oriented projects --- src/elvis_project.erl | 2 ++ test/examples/rebar.config.fail | 4 +++- test/examples/rebar3.config.success | 3 ++- test/project_SUITE.erl | 16 ++++++++-------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/elvis_project.erl b/src/elvis_project.erl index 3274a27..1d1715e 100644 --- a/src/elvis_project.erl +++ b/src/elvis_project.erl @@ -182,6 +182,8 @@ is_rebar_not_git_dep({_AppName, {pkg, _OtherName}}, _Regex) -> false; is_rebar_not_git_dep({_AppName, {_SCM, Url, _Branch}}, Regex) -> nomatch == re:run(Url, Regex, []); +is_rebar_not_git_dep({_AppName, {raw, {git, Url, _Branch}}}, Regex) -> + nomatch == re:run(Url, Regex, []); is_rebar_not_git_dep({_AppName, {_SCM, Url}}, Regex) -> nomatch == re:run(Url, Regex, []); is_rebar_not_git_dep({_AppName, _Vsn, {_SCM, Url}}, Regex) -> diff --git a/test/examples/rebar.config.fail b/test/examples/rebar.config.fail index 63ab43f..aed8082 100644 --- a/test/examples/rebar.config.fail +++ b/test/examples/rebar.config.fail @@ -28,6 +28,7 @@ {jiffy, "0.*", {git, "git@github.com:davisp/jiffy.git"}}, {ibrowse, "4.*", {git, "https://github.com/cmullaparthi/ibrowse.git", "v4.1.1"}}, {aleppo, "0.*", {git, "https://github.com/inaka/aleppo.git", "master"}}, + {jsx, {raw, {git, "git@github.com:talentdeficit.git", {branch, "develop"}}}}, {lager, {git, "git://github.com/basho/lager.git", "2.0.0"}}, {getopt, {git, "git@github.com:jcomellas/getopt.git", {branch, "master"}}}, @@ -35,7 +36,8 @@ {jiffy, {git, "https://github.com/davisp/jiffy.git", "0.11.3"}}, {jiffy, {git, "git@github.com:davisp/jiffy.git"}}, {ibrowse, {git, "https://github.com/cmullaparthi/ibrowse.git", "v4.1.1"}}, - {aleppo, {git, "https://github.com/inaka/aleppo.git", "master"}} + {aleppo, {git, "https://github.com/inaka/aleppo.git", "master"}}, + {jsx, {raw, {git, "https://github.com/talentdeficit.git", {branch, "master"}}}} ] }. {escript_name, "elvis"}. diff --git a/test/examples/rebar3.config.success b/test/examples/rebar3.config.success index 96171fa..63e40df 100644 --- a/test/examples/rebar3.config.success +++ b/test/examples/rebar3.config.success @@ -4,5 +4,6 @@ {uuid, "1.7.0", {pkg, uuid_erl}}, {meck, "0.8.2", {git, "https://github.com/basho/meck.git", {tag, "0.8.2"}}}, {jiffy, {git, "https://github.com/davisp/jiffy.git"}}, - recon + recon, + {jsx, {raw, {git, "https://github.com/talentdeficit.git", {branch, "develop"}}}} ]}. diff --git a/test/project_SUITE.erl b/test/project_SUITE.erl index a6a05c4..e391f52 100644 --- a/test/project_SUITE.erl +++ b/test/project_SUITE.erl @@ -148,15 +148,15 @@ verify_git_for_deps_rebar(_Config) -> Filename = "rebar.config.fail", {ok, File} = elvis_test_utils:find_file(SrcDirs, Filename), - [_, _, _, _, _, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, #{}), + [_, _, _, _, _, _, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, #{}), RuleConfig = #{ignore => [getopt]}, - [_, _, _, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, RuleConfig), + [_, _, _, _, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, RuleConfig), RuleConfig1 = #{ignore => [getopt, lager]}, - [_, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, RuleConfig1), + [_, _, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, RuleConfig1), - RuleConfig2 = #{ignore => [meck], regex => "git@.*"}, + RuleConfig2 = #{ignore => [meck, jsx], regex => "git@.*"}, [_, _, _, _, _, _, _, _] = elvis_project:git_for_deps_rebar(ElvisConfig, File, RuleConfig2). @@ -168,16 +168,16 @@ verify_protocol_for_deps_rebar(_Config) -> Filename = "rebar.config.fail", {ok, File} = elvis_test_utils:find_file(SrcDirs, Filename), - [_, _, _, _, _, _] = elvis_project:protocol_for_deps_rebar(ElvisConfig, File, #{}), + [_, _, _, _, _, _, _] = elvis_project:protocol_for_deps_rebar(ElvisConfig, File, #{}), - RuleConfig = #{ignore => [getopt]}, + RuleConfig = #{ignore => [getopt, jsx]}, [_, _, _, _] = elvis_project:protocol_for_deps_rebar(ElvisConfig, File, RuleConfig), RuleConfig1 = #{ignore => [getopt, lager]}, - [_, _] = elvis_project:protocol_for_deps_rebar(ElvisConfig, File, RuleConfig1), + [_, _, _] = elvis_project:protocol_for_deps_rebar(ElvisConfig, File, RuleConfig1), RuleConfig2 = #{ignore => [meck], regex => "git@.*"}, - [_, _, _, _, _, _, _, _] = + [_, _, _, _, _, _, _, _, _] = elvis_project:protocol_for_deps_rebar(ElvisConfig, File, RuleConfig2). -spec verify_hex_dep_rebar(config()) -> any(). From 75e284ebbd0356747cbf662578593328c21ef0cb Mon Sep 17 00:00:00 2001 From: Paulo Oliveira Date: Wed, 5 Aug 2020 18:11:01 +0100 Subject: [PATCH 2/2] Fix case for "master" verification and approach rebar_raw_resource's nomenclature --- src/elvis_project.erl | 6 ++++-- test/project_SUITE.erl | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/elvis_project.erl b/src/elvis_project.erl index 1d1715e..c673532 100644 --- a/src/elvis_project.erl +++ b/src/elvis_project.erl @@ -157,6 +157,8 @@ is_rebar_master_dep({_AppName, {_SCM, _Location, "master"}}) -> true; is_rebar_master_dep({_AppName, {_SCM, _Location, {branch, "master"}}}) -> true; +is_rebar_master_dep({AppName, {raw, DepResourceSpecification}}) -> + is_rebar_master_dep({AppName, DepResourceSpecification}); %% Rebar2 is_rebar_master_dep({_AppName, _Vsn, {_SCM, _Location, "master"}}) -> true; @@ -182,8 +184,8 @@ is_rebar_not_git_dep({_AppName, {pkg, _OtherName}}, _Regex) -> false; is_rebar_not_git_dep({_AppName, {_SCM, Url, _Branch}}, Regex) -> nomatch == re:run(Url, Regex, []); -is_rebar_not_git_dep({_AppName, {raw, {git, Url, _Branch}}}, Regex) -> - nomatch == re:run(Url, Regex, []); +is_rebar_not_git_dep({AppName, {raw, DepResourceSpecification}}, Regex) -> + is_rebar_not_git_dep({AppName, DepResourceSpecification}, Regex); is_rebar_not_git_dep({_AppName, {_SCM, Url}}, Regex) -> nomatch == re:run(Url, Regex, []); is_rebar_not_git_dep({_AppName, _Vsn, {_SCM, Url}}, Regex) -> diff --git a/test/project_SUITE.erl b/test/project_SUITE.erl index e391f52..e746e43 100644 --- a/test/project_SUITE.erl +++ b/test/project_SUITE.erl @@ -79,13 +79,16 @@ verify_no_deps_master_rebar(_Config) -> Filename = "rebar.config.fail", {ok, File} = elvis_test_utils:find_file(SrcDirs, Filename), - [_, _, _, _] = elvis_project:no_deps_master_rebar(ElvisConfig, File, #{}), + [_, _, _, _, _] = elvis_project:no_deps_master_rebar(ElvisConfig, File, #{}), RuleConfig = #{ignore => [aleppo]}, - [_, _] = elvis_project:no_deps_master_rebar(ElvisConfig, File, RuleConfig), + [_, _, _] = elvis_project:no_deps_master_rebar(ElvisConfig, File, RuleConfig), RuleConfig1 = #{ignore => [aleppo, getopt]}, - [] = elvis_project:no_deps_master_rebar(ElvisConfig, File, RuleConfig1). + [_] = elvis_project:no_deps_master_rebar(ElvisConfig, File, RuleConfig1), + + RuleConfig2 = #{ignore => [jsx]}, + [_, _, _, _] = elvis_project:no_deps_master_rebar(ElvisConfig, File, RuleConfig2). -spec verify_git_for_deps_erlang_mk(config()) -> any().