typescript:S7778 incorrectly reporting on methods that don't accept multiple arguments

  • What language is this for?
    JavaScript/TypeScript

  • Which rule?
    Multiple consecutive calls to methods that accept multiple arguments should be combined (typescript:S7778)

  • Why do you believe it’s a false-positive/false-negative?
    It reports a problem when dealing with methods that don’t accept multiple arguments

  • Are you using

    • SonarQube Cloud?
      Yes
    • SonarQube for IDE - which IDE/version?
      VS Code 1.109.4
      SonarQube for IDE v4.44.0
  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)

class CustomClass {
    private internalStore: number = 0;
    public push(item: number): void {
        this.internalStore += item;
    }
}
const instance = new CustomClass();

instance.push(1);
// Error: "Do not call `Array#push()` multiple times. sonarqube(typescript:S7778)"
instance.push(2);

The second .push call causes a false positive, as the method doesn’t accept multiple arguments, therefore it must be called multiple times.

Hi @d-ellis,

Thank you for the detailed report! This is indeed a false positive — S7778 should not flag consecutive calls to methods that only accept a single argument, since combining them would be a type error.

We’ve created a ticket to track the fix and will keep you posted on progress. Thanks again for taking the time to report this!