OptimumCredo.Check.Warning.HardcodedYearInTest (OptimumCredo v0.5.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

A fixed year can make a time-relative test expire. Derive time-relative dates from Date.utc_today/0 or use an explicit frozen clock. Fixed historical fixtures are legitimate; configure allow_years for those intentional cases.

Bad: Date.new!(2025, 1, 31) Good: Date.add(Date.utc_today(), 30)

Check-Specific Parameters

Use the following parameters to configure this check:

:min_year

Smallest year reported.

This parameter defaults to 2020.

:max_year

Largest year reported.

This parameter defaults to 2100.

:allow_years

Years that are always accepted.

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.