Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure DevOps files comments not appear #715

Open
daominhsangvn opened this issue Jan 5, 2023 · 6 comments
Open

Azure DevOps files comments not appear #715

daominhsangvn opened this issue Jan 5, 2023 · 6 comments
Labels
bug Something isn't working question Further information is requested

Comments

@daominhsangvn
Copy link

Describe the bug
Azure DevOps files comment not appear

To Reproduce
Steps to reproduce the behavior:

  1. Create a Pull Request with the code smell changes

Expected behavior
Code smells comments from the SonarQube should be added to the Azure DevOps

Screenshots
image
image
image

Software Versions

  • SonarQube Version: 9.8
  • Plugin Version: 1.14

Additional context

  • SonarQube running on K8s
  • Scanner running by Azure Pipeline with manual mode
@daominhsangvn daominhsangvn added the bug Something isn't working label Jan 5, 2023
@mareksabo
Copy link

mareksabo commented Jan 20, 2023

We had similar issue in our project, only summary without individual comments. The problem was in the setup, Administration -> ALM Integrations -> GitLab URL (sonar.auth.gitlab.url) needs to be https://gitlab.com/, not https://gitlab.com/api/v4/.

I was able to make it work on older sonar version 8.9.6. with plugin version 1.8.1

@robbertvanstaveren
Copy link

I am having the same issue. I am using the latest community LTS version of SonarQube (9.9) and plugin version 1.14. I am getting the summary but no comments on the PR in Azure DevOps.

@mc1arke
Copy link
Owner

mc1arke commented Apr 22, 2023

Please provide a copy of your compute engine logs for a scan that fails to add file comments if you're encountering this issue, obfuscating any sensitive file names or code, and any URLs, but ensuring the general message structure remains in place.

@mc1arke mc1arke added the question Further information is requested label Apr 22, 2023
@bambuca
Copy link

bambuca commented Aug 18, 2023

2023.08.18 09:50:56 INFO  ce[AYoIDhBXCt_uzGaS79uf][c.g.m.s.p.c.p.PullRequestPostAnalysisTask] Using pull request decorator com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.AzureDevOpsPullRequestDecorator
2023.08.18 09:50:56 ERROR ce[AYoIDhBXCt_uzGaS79uf][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Execution of task class com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask failed
java.lang.IllegalArgumentException: Cannot format given Object as a Number
	at java.base/java.text.DecimalFormat.format(Unknown Source)
	at java.base/java.text.Format.format(Unknown Source)
	at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.report.AnalysisSummary.format(AnalysisSummary.java:212)
	at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.AzureDevOpsPullRequestDecorator.submitSummaryNote(AzureDevOpsPullRequestDecorator.java:177)
	at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.AzureDevOpsPullRequestDecorator.submitSummaryNote(AzureDevOpsPullRequestDecorator.java:63)
	at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.DiscussionAwarePullRequestDecorator.decorateQualityGateStatus(DiscussionAwarePullRequestDecorator.java:105)
	at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask.finished(PullRequestPostAnalysisTask.java:138)
	at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.executeTask(PostProjectAnalysisTasksExecutor.java:102)
	at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.finished(PostProjectAnalysisTasksExecutor.java:93)
	at org.sonar.ce.task.step.ComputationStepExecutor.executeListener(ComputationStepExecutor.java:89)
	at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:61)
	at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:75)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(CeWorkerImpl.java:212)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.run(CeWorkerImpl.java:194)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:160)
	at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(CeWorkerImpl.java:135)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:87)
	at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:53)
	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
2023.08.18 09:50:56 INFO  ce[AYoIDhBXCt_uzGaS79uf][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Pull Request Decoration | status=FAILED | time=407ms
2023.08.18 09:50:56 INFO  ce[AYoIDhBXCt_uzGaS79uf][o.s.c.t.CeWorkerImpl] Executed task | project=ServiceRequest | type=REPORT | pullRequest=26997 | id=AYoIDhBXCt_uzGaS79uf | submitter=jan-nielsen75892 | status=SUCCESS | time=1585ms

@bambuca
Copy link

bambuca commented Aug 18, 2023

My error was caused by "The main branch has no lines of code.". I have fixed it by adding

  <PropertyGroup>
    <!-- Project is not a test project -->
    <SonarQubeTestProject>false</SonarQubeTestProject>
  </PropertyGroup>

to all csproj files (see https://improveandrepeat.com/2023/02/how-to-fix-a-project-with-0-lines-of-code-in-sonarqube/).

@ThomGeG
Copy link

ThomGeG commented Oct 30, 2023

I was having the same problem with Azure DevOps (Sonar leaving a summary comment, but no individual comments per issue) but I figured it out and thought I'd leave a comment.

In my case I was doing an analysis myself on some additional changes I hadn't committed & pushed yet. The logs didn't contain any errors and the debug logging wasn't indicating any attempt to leave individual comments. After trawling through the source code I found found this:

List<Pair<PostAnalysisIssueVisitor.ComponentIssue, String>> uncommentedIssues = findIssuesWithoutComments(openSonarqubeIssues,
commentKeysForOpenComments)
.stream()
.map(DiscussionAwarePullRequestDecorator::loadScmPathsForIssues)
.filter(Optional::isPresent)
.map(Optional::get)
.filter(issue -> isIssueFromCommitInCurrentRequest(issue.getLeft(), commitIds, scmInfoRepository))
.collect(Collectors.toList());

The plugin won't actually leave comments on issues that don't belong to commits reachable from the pull request. Sonar will happily report on them itself if they meet whatever you've configured 'New Code' to mean, however there's filtering logic in the plugin that prevents them carrying through into the PR decoration.

Hope that helps any future travellers who were similarly confused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants