New violations for unmodified lines in Pull Request need to be reported

We want to create issues using custom plugin.
Steps which we are following

  1. Scan master branch
  2. Create feature branch from master branch
  3. Make changes in feature branch
  4. Scan feature branch
  5. During scan we create issues using below sonar API
    org.sonar.api.batch.sensor.issue.NewIssue

If line# fall under modified code then only issues are created, if line# does not fall under modified code then issues are not created.

We want to create issue in unchanged lines in sonar Pull Request(line# does not fall under modified code), is there a way to support this ?

Thanks in advance !

Hey there.

This is not supported – even for our own analysis engine. Pull Requests only report issues on changed files / lines.

Can you provide some more context about the kind of rules you’re developing that would raise issues on old code, that you believe should be raised on pull requests?

Thanks @Colin.

We have issues generated from other static analysis tool same we want to create in SQ using custom plugin, here we had that requirement.

We had one more query if you could clarify.

If we add a new rule in Quality profile after master scan, will pull request with no file change show issue for newly added rule in Quality profile or it will only report for new rule of QP in changed code but not in old code.

This is correct.