Validate whole file on pull request

Env: Azure pipelines, SonnarScanner plugin
Version: 4.10.0.

On pull request, Sonar scans only changed lines, but there some cases, when need to be checked the whole file, code example:
Before PR

import {lib} from 'a'
lib.init()

In PR:

import {lib} from 'a'
function init() {}
init()

In pull request, it will not show this error, (something like value is declared but its value is never read.)

Is it possible force Sonnar to scan whole file where was made at least one line of change?

Hello @georgelviv,

Code analysis are always made on the entire codebase, even though there is only one line changed in a PR. It is not only changed lines that are analyzed, not even changed files, but the entire codebase of the PR.
Then, when reported to SQ, issues which are not in a file changed for a PR are ignored to avoid noise.

So the fact that you don’t see the issue you expect has likely another explanation:

  • is the rule enabled?
  • is there really an issue here?
  • is the analysis running well?

An easy check would be to analyze your PR as it was a brand new project (with a new projectKey, so that you could easily remove it after) and see if the issue is raised or not.

I hope this will help.

I found the reason, actually sonar fails on scanning ts lint files, with next error

eslint-bridge Node.js process is unresponsive. This is most likely caused by process running out of memory. Consider setting sonar.javascript.node.maxspace to higher value (e.g. 4096).

Fixed with sonar.javascript.node.maxspace

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