# unnecessary-filter-map

Disallow filterMap callbacks with a definitely defined result

A `filterMap` callback with a definitely defined result cannot filter any element.
Instead, you SHOULD call `map` to express the unconditional transformation.

- Category: style
- Level: warning
- Fix: suggestion
- Scope: module

## Reported

```ds title="main.ds"
function increment(values: int32[]): int32[] {
    return values.filterMap((value) => value + 1);
}
```

## Accepted

```ds title="main.ds"
function increment(values: int32[]): int32[] {
    return values.map((value) => value + 1);
}
```

## Prior art

- [Clippy · unnecessary_filter_map](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_filter_map)

[language/linter/src/rules/style/unnecessary_filter_map.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/unnecessary_filter_map.rs#L8)
