It would be nice to have the ability in the SonarLint IDE plugin to analyze a file and only show newly introduced issues (or add a filter that only displays newly introduced sonar issues). Line changes can possibly be identified by checking whether this line of code was changed by version control.
Your request make sense, because we are indeed encouraging people to only look at issues they have on code they are touching. That’s why we encourage people to only rely on “on-the-fly” analysis (analysis of files you open/modify) and not use full project analysis.
But I agree the granularity is a bit coarse, and opening a file doesn’t necessarily mean you are about to modify it.
To implement a “new issues” filter, one option would be to report only issues on changed lines.
In order to detect changed lines, we would need a baseline. Assuming nowadays everybody is using Git, we would have to compute the diff with some parent commit (repo main branch/fork point/…). This is what is done on SonarQube/SonarCloud scanners to implement PR analysis, and I can tell you it has a lot of corner cases.
But in practice, we can’t limit analysis to modified lines. Changing a line can produce an issue on another line, in the same file, or even in a different file.
The other option is to rely on connected mode, and only report issues that are detected locally and not found on the server. We already experimented this strategy in the past, and it also have some drawbacks, the main one being to require to use connected mode, while most of SonarLint users are not using connected mode.