False positive for rule php:S1192

  • Developer Edition
  • Version 9.7 (build 61563)

The rule about repeated strings says:

No issue will be raised on:
strings with less than 5 characters
strings with only letters, numbers, underscores, hyphens and periods

I’m getting critical reports on some array keys: ‘_class’, ‘_brand’, ‘_domain’. I’m pretty sure that’s the second exception, “only letters and underscores”?

(off-topic: why is this even Critical? It doesn’t seem anything higher than Major really)

Hello @pablo.videoslots ,

Thanks you for reporting this false positive!

Indeed there is an issue in the implementation of this rule, it is not excluding strings starting with an underscore, which should be the case.
I created a ticket to fix this.

Regarding the level of the issue, I understand your point.
I checked and this is not an error or an exception to the PHP implementation.
Issue level are computed and judged using several criteria.
I agree with you that Critical seems to be a bit severe for this, you have the possibility to modify this setting in SonarQube.

Hope that helps,

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.