Skip to content

cfg_not_test #11234

Closed
Closed
@JonathanWoollett-Light

Description

@JonathanWoollett-Light

What it does

Disallows usage of any conditional compilation that always excludes code from test builds.

Advantage

  • Prevents code being excluded from tests builds. Preventing the case where a codebase appears to have 100% coverage while having untested code.
  • Enforces simplicity in testing, guarding against excessive mocking anti-pattern.

Drawbacks

  • May prevent rare legitimate use cases for excluding code from test runs.

Example

The following would trigger this lint:

#[cfg(not(test))]
#[cfg(all(debug_assertions, not(test)))]
#[cfg(not(any(not(debug_assertions), test)))]

Metadata

Metadata

Assignees

Labels

A-lintArea: New lintsL-restrictionLint: Belongs in the restriction lint group

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions