JavaScript / TypeScript
typescript:S2301
We understand that the main idea of the rule and agree. For example, we should do something like this:
export function getFieldTitle ({ isField }: TestObject) {
return isField ? getCoolValue() : getUndefined();
}
But we believe that when we use objects the rule is redundant. When working with objects, we do not have a problem with “developers calling the method won’t see the parameter name, only its value”, and it would be better to exclude this case from this rule.
Community Build v24.12.0.100206
Code example:
export function getFieldTitle ({ isField }: TestObject) {
return isField ? TITLES.COOL_VALUE : undefined;
}
ilia
(Ilia)
February 28, 2025, 10:49am
3
Hello Osmyslitelny,
Thank you for your feedback!
I didn’t manage to raise an issue using both samples that you provide. What change are you asking for?
In simple terms, for this rule:
Do not catch cases when we use TestObject
Catch cases when we use just bool value (current behave)
ilia
(Ilia)
March 5, 2025, 8:41am
6
As I mentioned, the rule is not raising an issue for both coding examples that you mentionned in the latest version of the analyzer.
Is it raising an issue for you?
Yes, it is.
Attached is a screenshot from my Sonar. We set these issue levels to ‘low’ to pass the Quality Gate, but it’s just a workaround.
Hello @Osmyslitelny ,
I was able to reproduce this. I created a ticket to track this improvement.
Thanks for the feedback!
Victor
1 Like
Hey Victor,
We have just hit this internally too - do you know what release this will be targeted so I can give some feedback internally?
Cheers N
1 Like
Hi @mayneframe ,
Should be fixed in the coming weeks. So it should be visible in SonarQube Cloud shortly after.
Cheers,
Victor
2 Likes
Nice one Victor, how about Sonar Server?
I would expect the fix to land in the Community build 25.8 in August, or 25.9 at the latest.
1 Like