Skip to content

Commit

Permalink
Bump katana_code to 0.2.1 which removes the usage of aleppo
Browse files Browse the repository at this point in the history
  • Loading branch information
jfacorro committed Dec 3, 2019
1 parent ef88b6e commit bc361f7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 72 deletions.
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
%% == Dependencies ==

{deps, [ {zipper, "1.0.1"}
, {katana_code, "0.1.2"}
, {katana_code, "0.2.1"}
]}.

%% == Dialyzer ==
Expand Down
6 changes: 2 additions & 4 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{"1.1.0",
[{<<"aleppo">>,{pkg,<<"inaka_aleppo">>,<<"1.1.1">>},1},
{<<"katana_code">>,{pkg,<<"katana_code">>,<<"0.1.2">>},0},
[{<<"katana_code">>,{pkg,<<"katana_code">>,<<"0.2.1">>},0},
{<<"zipper">>,{pkg,<<"zipper">>,<<"1.0.1">>},0}]}.
[
{pkg_hash,[
{<<"aleppo">>, <<"B0F7D05A118C5EBC3A735D68E92A7BD5837FE53455495EDE37CF0AA8BA4912E3">>},
{<<"katana_code">>, <<"347D42D5E89AC6C4BF8D02B64633AC1BFE14B7724B5910260D39EFEAFE737F01">>},
{<<"katana_code">>, <<"B2195859DF57D8BEBF619A9FD3327CD7D01563A98417156D0F4C5FAB435F2630">>},
{<<"zipper">>, <<"3CCB4F14B97C06B2749B93D8B6C204A1ECB6FAFC6050CACC3B93B9870C05952A">>}]}
].
10 changes: 5 additions & 5 deletions src/elvis_file.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ parse_tree(_Config, File = #{parse_tree := ParseTree}) ->
parse_tree(Config, File = #{path := Path, content := Content}) ->
Ext = filename:extension(Path),
ExtStr = elvis_utils:to_str(Ext),
ParseTree = resolve_parse_tree(Config, ExtStr, Content),
ParseTree = resolve_parse_tree(ExtStr, Content),
parse_tree(Config, File#{parse_tree => ParseTree});
parse_tree(Config, File0 = #{path := _Path}) ->
{_, File} = src(File0),
Expand Down Expand Up @@ -109,11 +109,11 @@ filter_files(Files, Dirs, Filter, IgnoreList) ->
%% Private
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-spec resolve_parse_tree(map(), string(), binary()) ->
-spec resolve_parse_tree(string(), binary()) ->
undefined | ktn_code:tree_node().
resolve_parse_tree(Config, ".erl", Content) ->
ktn_code:parse_tree(elvis_config:include_dirs(Config), Content);
resolve_parse_tree(_, _, _) ->
resolve_parse_tree(".erl", Content) ->
ktn_code:parse_tree(Content);
resolve_parse_tree( _, _) ->
undefined.

-spec glob_to_regex(iodata()) -> iodata().
Expand Down
9 changes: 5 additions & 4 deletions src/elvis_style.erl
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ check_macro_names(Line, Num, _Args) ->
end
end.

%% Macro in Function Call as Module or Functon Name
%% Macro in Function Call as Module or Function Name

-spec check_macro_module_names(binary(), integer(), [term()]) ->
no_result | {ok, elvis_result:item()}.
Expand Down Expand Up @@ -939,7 +939,8 @@ is_remote_call({Num, Col}, Root) ->
(Node0 == zipper:node(Zipper))
andalso has_remote_call_parent(Zipper)
end,
[] =/= elvis_code:find(Pred, Root, #{mode => zipper})
Opts = #{mode => zipper, traverse => all},
[] =/= elvis_code:find(Pred, Root, Opts)
end.

has_remote_call_parent(undefined) ->
Expand Down Expand Up @@ -1048,7 +1049,7 @@ is_dynamic_call(Node) ->
end.

%% Plain Variable
-spec is_var(ktn_code:tree_node()) -> boolean().
-spec is_var(zipper:zipper(_)) -> boolean().
is_var(Zipper) ->
case ktn_code:type(zipper:node(Zipper)) of
var ->
Expand All @@ -1066,7 +1067,7 @@ is_var(Zipper) ->

%% Ignored Variable

-spec is_ignored_var(ktn_code:tree_node()) ->
-spec is_ignored_var(zipper:zipper(_)) ->
boolean().
is_ignored_var(Zipper) ->
Node = zipper:node(Zipper),
Expand Down
54 changes: 0 additions & 54 deletions test/elvis_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
rock_with_rule_groups/1,
rock_this_skipping_files/1,
rock_this_not_skipping_files/1,
rock_with_include_dirs/1,
%% Util & Config
throw_configuration/1,
find_file_and_check_src/1,
Expand Down Expand Up @@ -320,59 +319,6 @@ rock_this_not_skipping_files(_Config) ->
meck:unload(elvis_file),
ok.

-spec rock_with_include_dirs(Config::config()) -> ok.
rock_with_include_dirs(_Config) ->
meck:new(ktn_code, [unstick]),
Dirs = ["../../test/examples"],
Filter = "small.erl",
_ = application:set_env(elvis, verbose, true),

% Default `include_dirs' value is used when not provided
meck:expect(ktn_code,
parse_tree,
fun(IDirs = ["include"], Content) ->
meck:passthrough([IDirs, Content]);
(_, _) ->
% Received include dirs are different than expected
throw({error, badmatch})
end),
DefaultConf = [#{dirs => Dirs, filter => Filter, ruleset => erl_files}],
% We don't care about checks results
_ = elvis_core:rock(DefaultConf),
true = meck:validate(ktn_code),

% Given `include_dirs' are used when provided
CustomIDirs = ["path/to/include1", "path/to/include2"],
meck:expect(ktn_code,
parse_tree,
fun(IDirs, Content) ->
case IDirs of
CustomIDirs ->
meck:passthrough([IDirs, Content]);
_ ->
% Received include dirs are different than expected
throw({error, badmatch})
end
end),
CustomConf = #{dirs => Dirs,
include_dirs => CustomIDirs,
filter => Filter,
ruleset => erl_files},
% We don't care about checks results
_ = elvis_core:rock([CustomConf]),
true = meck:validate(ktn_code),

% It must fail when the received include_dirs value is different
% than expected.
_ = elvis_core:rock([CustomConf#{include_dirs => ["unknown/path"]}]),
false = meck:validate(ktn_code),

% Clean up environment
_ = application:set_env(elvis, verbose, false),
_ = meck:unload(ktn_code),
ok.


%%%%%%%%%%%%%%%
%%% Utils

Expand Down
13 changes: 9 additions & 4 deletions test/examples/fail_used_ignored_variable.erl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-module(fail_used_ignored_variable).

-export([
use_ignored_var/2,
use_ignored_var_in_fun/2,
no_used_ignored_vars_here/2, handle_call/3
-export([ use_ignored_var/2
, use_ignored_var_in_fun/2
, no_used_ignored_vars_here/2, handle_call/3
, macro_with_underscore/0
]).

use_ignored_var(_One, Two) ->
Expand All @@ -24,3 +24,8 @@ no_used_ignored_vars_here(One, _Two) ->
{stop, {unknown_request, Msg}, {unknown_request, Msg}, term()}.
handle_call(Msg, _From, State) ->
{stop, {unknown_request, Msg}, {unknown_request, Msg}, State}.

-define(__(X), X).

macro_with_underscore() ->
?__("This string will be translated").

0 comments on commit bc361f7

Please sign in to comment.