elvis_utils (elvis_core v4.1.1)

View Source

Summary

Functions

Takes a binary that holds source code and applies Fun to each line. Fun takes 2 or 3 arguments (the line as a binary, the line number and the optional supplied Args) and returns 'no_result' or {'ok', Result}.

Checks each line calling fun and providing the previous and next lines based on the context tuple {Before, After}.

Takes a binary that holds source code and applies Fun to each line. Fun takes 3 arguments (the line as a binary, the line number and the supplied Args) and returns 'no_result' or {'ok', Result}.

This is defined so that it can be mocked for tests.

Takes a line, a character and a count, returning the indentation level invalid if the number of character is not a multiple of count.

Types

file/0

-type file() :: #{path => string(), content => binary()}.

line_content/0

-type line_content() :: {integer(), integer()}.

Functions

check_lines(Src, Fun, Args)

-spec check_lines(binary(), fun(), term()) -> [elvis_result:item()].

Takes a binary that holds source code and applies Fun to each line. Fun takes 2 or 3 arguments (the line as a binary, the line number and the optional supplied Args) and returns 'no_result' or {'ok', Result}.

check_lines_with_context(Src, Fun, Args, Ctx)

-spec check_lines_with_context(binary(), fun(), term(), line_content()) -> [elvis_result:item()].

Checks each line calling fun and providing the previous and next lines based on the context tuple {Before, After}.

check_nodes(RootNode, Fun, Args)

-spec check_nodes(ktn_code:tree_node(), fun(), [term()]) -> [elvis_result:item()].

Takes a binary that holds source code and applies Fun to each line. Fun takes 3 arguments (the line as a binary, the line number and the supplied Args) and returns 'no_result' or {'ok', Result}.

erlang_halt(Code)

-spec erlang_halt(integer()) -> no_return().

This is defined so that it can be mocked for tests.

error(Message)

-spec error(string()) -> ok.

error(Message, Args)

-spec error(string(), [term()]) -> ok.

error_prn(Message)

-spec error_prn(string()) -> ok.

error_prn(Message, Args)

-spec error_prn(string(), [term()]) -> ok.

indentation(Line, Char, Count)

-spec indentation(binary() | string(), char(), integer()) -> invalid | integer().

Takes a line, a character and a count, returning the indentation level invalid if the number of character is not a multiple of count.

info(Message)

-spec info(string()) -> ok.

info(Message, Args)

-spec info(string(), [term()]) -> ok.

notice(Message)

-spec notice(string()) -> ok.

notice(Message, Args)

-spec notice(string(), [term()]) -> ok.

parse_colors(Message)

-spec parse_colors(string()) -> string().

split_all_lines(Binary)

-spec split_all_lines(binary()) -> [binary(), ...].

split_all_lines(Binary, Opts)

-spec split_all_lines(binary(), list()) -> [binary()].

to_str(Arg)

-spec to_str(binary() | list() | atom() | integer()) -> string().

warn_prn(Message, Args)

-spec warn_prn(string(), [term()]) -> ok.