KogenCredo.Check.Warning.WeakAssertion (KogenCredo v0.1.0)

View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of low and works with any version of Elixir.

Explanation

assert is_map(result) or assert result != nil passes for almost any bug. Assert the exact value or a pattern that pins the interesting fields: assert %{status: :ok, id: ^id} = result.

Check-Specific Parameters

Use the following parameters to configure this check:

:file_suffixes

Filename suffixes treated as test files.

This parameter defaults to ["_test.exs"].

:test_macros

Macros that define a test body.

This parameter defaults to [:test].

:only_when_all_weak

Report only when every assertion in the test is weak.

This parameter defaults to true.

:weak_predicates

Type predicates considered weak.

This parameter defaults to [:is_map, :is_list, :is_binary, :is_atom, :is_integer, :is_float, :is_number, :is_tuple, :is_boolean, :is_function, :is_struct, :is_pid, :is_reference].

:weak_helpers

Names of custom assertion helpers considered weak.

This parameter defaults to [].

:assertion_helpers

Names of custom helpers that assert strongly; a test calling one is not weak.

This parameter defaults to [].

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.