Hey,
we started using SonarCloud recently. We shouldn’t have commented out code and wanted to sue sonar cloud as the tool to detect that in our code base. We noticed that commented out properties in the jsx/HTML code is not found.
- What language is this for?: Typescript
- Which rule?: typescript:S125
- Why do you believe it’s a false-negative?
- It has weird brackets as comments. It should be recognized as code
- Are you using: SonarCloud & SonarLint VsCode Extension
v4.10.0
happens in both modes
To reproduce it, it was enough for me to just open this code as a index.tsx
:
'use client';
import * as React from 'react';
import { DateCalendar } from "@mui/x-date-pickers";
const Calendar: React.FC = () => {
return (
<DateCalendar
data-testid="header-calendar"
value={1234}
openTo="year"
// views={["year"]}
// maxDate={new Date()}
onChange={date => {
console.log(date);
}}
/>
);
};
export { Calendar };
It even appears, that code that is otherwised found correctly is not found when in proximity to these commented out properties. The first commented out code is recognized, the second not :(.
'use client';
import * as React from 'react';
import { DateCalendar } from "@mui/x-date-pickers";
//const test= 1234;
const Calendar: React.FC = () => {
return (
<DateCalendar
data-testid="header-calendar"
value={1234}
openTo="year"
//const test= 1234;
// views={["year"]}
// maxDate={new Date()}
onChange={date => {
console.log(date);
}}
/>
);
};
export { Calendar };
I know, that this rule works with heuristics, but maybe they can be improved with properties