SonarCloud don't check new code from Pull Requests Azure DevOps

SonarCloud is integrated with Azure DevOps

yml file:

name: Azure Static Web Apps CI/CD
pr:
  branches:
    include:
      - dev
trigger:
  branches:
    include:
      - dev
jobs:
- job: build_and_deploy_job
  displayName: Build and Deploy Job
  condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
  pool:
    vmImage: ubuntu-latest
  variables:
  - group: Azure-Static-Web-Apps-delightful-beach-016f25c03-variable-group
  steps:
  - checkout: self
    submodules: true
  - task: SonarCloudPrepare@1
    inputs:
      SonarCloud: 'SonarCloud'
      organization: 'xxxxxxx'
      scannerMode: 'CLI'
      configMode: 'manual'
      cliProjectKey: 'xxxxx'
      cliProjectName: 'xxxx'
      cliProjectVersion: '2.0'
      cliSources: 
  - task: AzureStaticWebApp@0
    inputs:
      azure_static_web_apps_api_token: $(xxxxxxx)
      app_location: "_static" # App source code path
      api_location: "" # Api source code path - optional
      output_location: "" # Built app content directory - optional
  - task: SonarCloudAnalyze@1
  - task: SonarCloudPublish@1
    inputs:
      pollingTimeoutSec: '300'
  • Languages of the repository Javascript, HTML, CSS

  • Steps to reproduce

1 - I created a new pull request with code errors

2 - SonarCloud doesn’t find any errors:

New Code settings - Specific date (from Jan 01 2022)

Overall code reviews have errors, but neither new code nor pull requests don’t

Please help to fix this issue.

Hi,

Welcome to the community!

Could you be explicit about what issues you’re expecting to be raised on your PR?

 
Ann

Hi Ann,
Expected result - receive review of pull request code from SonarCloud.

So I’m looking for solution - how to reach expected result.

Generally issue is that SonarCloud doesn’t review pull requests at all and always says that code is fine.
But code has with errors and bugs.

Probably the reason is somewhere in difference between new code and old code.

I will be very glad to receive a help.

Regards,
Bogdan

Hi Bogdan,

Yeah, I got that part already.

What I want to know is what “errors and bugs” you expect to see PR analysis flagging.

 
Ann

Hi Ann,
Bugs, Vulnerabilities, and Code Smell according to SonarCloud rules:

For example, I take the wrong code from SonarCloud rules example and SonarCloud after checking the Pull Request said this code if fine

Hi,

Thanks. This is in the direction of what I’m after. And could you be more specific? Like, could you provide the specific rule you expected to see an issue from? Because I’d like to verify that the rules in question are in the default profile.

 
Ann

Hi Ann,
Here’s an example from the last SonarClour run:
I take bad code from https://rules.sonarsource.com/javascript/type/Bug/RSPEC-4275 and put it into 2 different files.

On one page SonarCloud finds it as a bad code.
On another page - as good code

Page with errors

Page without errors

Especially these 3 lines of code:

const datePattern = /\d{4}-\d{2}-\d{2}/g;
datePattern.test('2020-08-06');
datePattern.test('2019-10-10');

On page with errors, they are on lines 189-191
On page without errors, they are on lines 318-322

Regards,
Bogdan

Hi Bogdan,

Thanks for this. Would it be possible to provide the file where no issue was raised? Also, are there any errors in your analysis log about parsing?

 
Ann

Hi Ann,
I had a few errors with parsing files. Like that:
##[error]ERROR: Failed to parse file [src/pages/xxxt.js] at line 107: Unexpected token (107:25)
But it’s other files that are in no way connected with files from my issue.

There are no errors in files from my issue.
I can share both files (where errors were detected and where - don’t, but only through private messages, as it’s not a public project)

Bogdan

Hi Bogdan,

I’ve referred this to the experts. Hopefully they’ll be a long soon & initiate that private thread.

 
Thx,
Ann

1 Like

closing topic as user bypassed the issue by creating a new project