How to find an issue in feature branch that has occured in main brach

Hi Team,

I have used issues web api to filter out issues on main branch. I got the required results, 3 issues found on sonar main branch.
Example:
[
“Issue1”:{“key”:“key1”},
“Issue2”:{“key”:“key2”},
“Issue3”:{“key”:“key3”},
]

If I want to find same issues on feature_branch is it possible?
I know sonar has different keys for each issue (its unique identifier).

Thanks,
Pavan

Hi Pavan,

Welcome to the community!

You’re going to need to work based on issue characteristics.

The docs discuss how analysis determines whether an issue is “new” and it should be a good guide for this.

 
Ann

Thank you Ann.
I am trying to search for same issue across 2 or more branches.
Like if I am able to find the issue1 in branch1.
I would like to get the same issue1 in branch2.
Though the issue-key would change across the branch but hash shall remain the same is my understanding.

I am using web api, but searching using hash is returning all the issues matching the hash. I am looking same issue on 2 different branches.

Thanks,
Pavan

Would the below api help me fetch the same issue on different branch.
/api/issues/search?componentKeys=&severities=&statuses=&branch=&hash=&rules=

If the same violation is repeated in same file multiple times this may fail as I am not using line no#

Hi,

Yes, you would need to narrow by &branch= to not get issues from all branches.

 
HTH,
Ann

Thank you.
In the same context of finding same issue in different branches.
How to identify the same issues, if the same rule has been violated in same file (componentKeys=filename)?

Example:
If “file1” has “issue1”, “issue2” on lineno #10 and #15 respectively on “rule1” analysis on “integration” branch.

Now if I want to find same 2 issues on “master”, would the below api help me.

/api/issues/search?componentKeys=project1:file1&severities=BLOCKER&statuses=OPEN&branch=master&hash=issue_hash&rules=rule1

Sonarqube is returning 2 issues with same hash on master. How to know which issue on integration branch corresponds to master? As both would be having same hash.

Like (same hash, different issues)
issue1_on_integration = issue1_on_master
issue2_on_integration = issue2_on_master

Hi,

I recommend working from SonarQube’s own algorithm to determind whether issues are new or a match to an existing issue.

 
HTH,
Ann