We are using SonarQube 9.5 Enterprise Edition.
We need to understand, there is one project on SonarQube showing New_Code_Smells as 3(New code period set as last 60 Days). But the code is not modified since 2017.
The project is violating the below rule Java $1192
"Define a constant instead of Duplicating this literal “rs.getString(cusip_id) : " 3 times”
Can I know what is reason for this issue?
The codebase as a whole hasn’t been modified since 2017, or the line where the issue is raised hasn’t been modified. Because this rule isn’t triggered until the third instance of the literal is added to the code. And then the issue is raised on the first instance. So it’s entirely plausible to have a new issue on old code from this rule. Depending on the language, secondary locations may be part of the implementation. If so, you should be able to use them to find the other instances of the literal and see the dates on those lines. One of them will be recent.
Also, make sure you upgrade to SonarQube v9.9 LTS soon, not only to benefit from our Best LTS Ever™, but because soon we will systematically ask users to upgrade when they ask questions about earlier versions of SonarQube, which are now considered unsupported.
Thanks for your response.
The file is not changed since 2017, if the new rules was created after that then it will show under the overall code right?. Because we set New_code period as 60 days only.
If no line in the file has been touched since 2017 then there is something odd going on. But can you check the dates on the lines of the secondary locations the issue lists? I would bet money that at least one of them has been updated in the last 60 days.