Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent rebar3 crash and more output than required #61

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/rebar3_lint_prv.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-module(rebar3_lint_prv).

-export([init/1, do/1, format_error/1]).
-export([init/1, do/1]).
-export([default_config/0]).

-define(PROVIDER, lint).
Expand Down Expand Up @@ -31,17 +31,13 @@ do(State) ->
{ok, State};
{fail, [{throw, Error} | _]} ->
rebar_api:abort("elvis_core threw an exception: ~p", [Error]);
{fail, Reason} ->
{error, {"Linting failed with ~p", Reason}}
{fail, _} ->
{error, "Linting failed"}
catch
Error ->
rebar_api:abort("elvis_core threw an exception: ~p", [Error])
end.

-spec format_error({string(), any()}) -> iolist().
format_error({Message, Reason}) ->
io_lib:format(Message, [Reason]).

-spec get_elvis_config(rebar_state:t()) -> elvis_config:configs().
get_elvis_config(State) ->
try_elvis_config_rebar(State).
Expand Down
4 changes: 1 addition & 3 deletions test/test_app_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ test_app(_Config) ->
[#{dirs => ["src"],
filter => "*.erl",
rules => [{elvis_style, max_function_length, #{max_length => 1}}]}]),
{error, {Message = "Linting failed with ~p", Reason}} = rebar3_lint_prv:do(BadState),
% Check that this doesn't throw
io:format("~p", [rebar3_lint_prv:format_error({Message, Reason})]).
{error, "Linting failed"} = rebar3_lint_prv:do(BadState).
Loading