Make sure to read this post before raising a thread here:
Then tell us:
- What language is this for? TypeScript
- Which rule? S2301
- Why do you believe it’s a false-positive/false-negative? In the attached example the boolean isn’t a selector it’s the input value for the transformation function and the suggestion would not apply to functions of this nature. You literally can’t break this into two functions and there aren’t two paths through the method. This rule also get’s triggered on other similar functions where the boolean is the only input value and it’s a simple pass fail evaluation not a branch to what should be two different functions.
- Are you using
- SonarQube Cloud?
- SonarQube Server / Community Build - which version? v25.3.0.104237
- SonarQube for IDE - which IDE/version?
- in connected mode with SonarQube Server / Community Build or SonarQube Cloud?
- How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'yesNo'
})
export class YesNoPipe implements PipeTransform {
transform(value: boolean): string {
return value ? 'Yes' : 'No';
}
}