Skip to content

Files

Latest commit

 

History

History
25 lines (18 loc) · 516 Bytes

prefer_is_not_empty.md

File metadata and controls

25 lines (18 loc) · 516 Bytes

Pattern: Missing use of isNotEmpty for Iterable/Map

Issue: -

Description

When testing whether an Iterable or Map is empty, prefer isNotEmpty over !isEmpty to improve code readability.

Example of correct code:

if (todo.isNotEmpty) {
 sendResults(request, todo.isEmpty);
}

Example of incorrect code:

if (!sources.isEmpty) {
 process(sources);
}

Further Reading