typescript:S7729 triggered for any function named "filter"

  • Language: Typescript
  • Rule typescript:S7729 - Array method callbacks should not use the “thisArg” parameter
  • SonarQube Server / Community Build: v25.10.0.114319
  • SonarQube for IDE: 8.28.0.14489 on Visual Studio 2022 (not connected)

This rule seems to be applied to any method on a class named “filter” with two parameters, regardless of whether it has anything to do with arrays.

class SomeClass {
    filter(param1: string, param2: number) {
        return null;
    }

    something(param: string) {
        return this.filter(param, 1); // the second parameter of this function triggers the rule
    }
}

Hi @m-gallesio,

good catch, thanks again for the feedback. I created a ticket to fix this.

Cheers

This also applies to methods named map, find, findLast and most likely others.

1 Like