SonarCloud w/ Bitbucket (VueJS)

  • ALM: Bitbucket Cloud
  • CI: Bitbucket Cloud
  • Languages: Javascript

As so many others, Sensor JavaScript/TypeScript analysis [javascript], is taking incredibly long. It takes more than 120 minutes(timeout) on an 116 files to analyse.

Then, I end up getting:

INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms
INFO: Sensor JavaScript/TypeScript analysis [javascript]
INFO: Found 0 tsconfig.json file(s): []
INFO: Analyzing 116 files using tsconfig: /tmp/tmp-107-3E38jyIFnJeJ
INFO: 116 source files to be analyzed
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
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).
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
INFO: 0/116 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/utils/time.js
ERROR: Failure during analysis, Node.js command to start eslint-bridge was: node --max-old-space-size=8192 /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/eslint-bridge-bundle/package/bin/server 38407 127.0.0.1 /opt/atlassian/pipelines/agent/build/.scannerwork true false /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/eslint-bridge-bundle/package/custom-rules6294091448580558242/package
java.lang.IllegalStateException: eslint-bridge is unresponsive
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.request(EslintBridgeServerImpl.java:393)
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.analyzeJavaScript(EslintBridgeServerImpl.java:342)
	at org.sonar.plugins.javascript.eslint.AnalysisWithWatchProgram.analyze(AnalysisWithWatchProgram.java:152)
	at org.sonar.plugins.javascript.eslint.AnalysisWithWatchProgram.analyzeTsConfig(AnalysisWithWatchProgram.java:124)
	at org.sonar.plugins.javascript.eslint.AnalysisWithWatchProgram.analyzeFiles(AnalysisWithWatchProgram.java:80)
	at org.sonar.plugins.javascript.eslint.JsTsSensor.analyzeFiles(JsTsSensor.java:124)
	at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:74)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:66)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:48)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:468)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:464)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:420)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:57)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:51)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.net.http.HttpTimeoutException: request timed out
	at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:559)
	at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:119)
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.request(EslintBridgeServerImpl.java:384)
	... 36 common frames omitted
INFO: Hit the cache for 0 out of 1
INFO: Miss the cache for 1 out of 1: FILE_CHANGED [1/1]
INFO: Sensor JavaScript/TypeScript analysis [javascript] (done) | time=2087575ms
INFO: Sensor CSS Rules [javascript]

I’ve seen so many people have issues with eslint-bridge.
Has anyone actually gotten this working?!?!

Here are is my pipeline yaml:

# Check our guides at https://confluence.atlassian.com/x/14UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----

image: node:18.16.1

clone:
  depth: full # SonarCloud scanner needs the full history to assign issues properly

definitions:
  caches:
    sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
  docker:
    memory: 4096

options:
  docker: true
  size: 2x

commonTestStep: &commonTestStep
  step:
    name: Test step
    caches:
      - node
    script:
      - npm install
      - npm run test:unit
    artifacts:
      - coverage/**

commonLintStep: &commonLintStep
  step:
    name: Lint step
    caches:
      - node
    script:
      - npm install
      - npm run lint

commonReportStep: &commonReportStep
  step:
    name: Report step
    size: 2x
    services:
      - docker
    caches:
      - node
      - sonar
    script:
      - pipe: sonarsource/sonarcloud-scan:1.4.0

commonReportQualityGateStep: &commonReportQualityGateStep
  step:
    name: Check the Quality Gate on SonarCloud
    size: 2x
    caches:
      - node
      - sonar
    script:
      - pipe: sonarsource/sonarcloud-quality-gate:0.1.6

commonBuildStep: &commonBuildStep
  step:
    name: Build step
    caches:
      - node
    script:
      - npm install
      - npm run build
    artifacts:
      - dist/**

commonBuildProdStep: &commonBuildProdStep
  step:
    name: Build Production step
    caches:
      - node
    script:
      - npm install
      - npm run build:production
    artifacts:
      - dist/**

commonBuildStagingStep: &commonBuildStagingStep
  step:
    name: Build Staging step
    caches:
      - node
    script:
      - npm install
      - npm run build:staging
    artifacts:
      - dist/**

commonBuildDevStep: &commonBuildDevStep
  step:
    name: Build Dev step
    caches:
      - node
    script:
      - npm install
      - npm run build:development
    artifacts:
      - dist/**

commonBuildBetaStep: &commonBuildBetaStep
  step:
    name: Build Beta step
    caches:
      - node
    script:
      - npm install
      - npm run build:beta
    artifacts:
      - dist/**

commonDeployStep: &commonDeployStep
  name: Deploy step
  image: amazon/aws-cli:latest
  script:
    - aws s3 sync --delete dist/ s3://$BUCKET
    - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths $(pwd)/* /index.html

commonDeployStagingStep: &commonDeployStagingStep
  name: Deploy staging step
  image: amazon/aws-cli:latest
  script:
    - aws s3 sync --delete dist/ s3://$BUCKET_STAGING
    - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID_STAGING --paths $(pwd)/* /index.html

commonDeployProdStep: &commonDeployProdStep
  name: Deploy step
  image: amazon/aws-cli:latest
  script:
    - aws s3 sync ./dist s3://$BUCKET_PROD --metadata-directive REPLACE --cache-control max-age=0

pipelines:
  tags:
    '**':
      - parallel:
          - <<: *commonTestStep
          - <<: *commonLintStep
          - <<: *commonBuildDevStep
      - <<: *commonReportStep
      - <<: *commonReportQualityGateStep

  pull-requests:
    '**':
      - parallel:
          - <<: *commonTestStep
          - <<: *commonLintStep
          - <<: *commonBuildDevStep
      - <<: *commonReportStep
      - <<: *commonReportQualityGateStep

  branches:
    beta:
      - parallel:
          - <<: *commonTestStep
          - <<: *commonBuildBetaStep
      - step:
          <<: *commonDeployStep
          deployment: beta

    dev:
      - parallel:
          - <<: *commonTestStep
          - <<: *commonBuildDevStep
      - <<: *commonReportStep
      - <<: *commonReportQualityGateStep
      - step:
          <<: *commonDeployStep
          deployment: development

    staging:
      - parallel:
          - <<: *commonTestStep
          - <<: *commonBuildStagingStep
      - <<: *commonReportStep
      - <<: *commonReportQualityGateStep
      - step:
          <<: *commonDeployStep
          deployment: staging

    master:
      - parallel:
          - <<: *commonTestStep
          - <<: *commonBuildStep
      - <<: *commonReportStep
      - <<: *commonReportQualityGateStep
      - step:
          <<: *commonDeployProdStep
          deployment: production

Hi @andre_s_ferreira,

can you enable debug logs please? (-X parameter or sonar.verbose=true in sonar.properties)

Answering your question, yes, it’s possible to have a better performance but depending on your project tsconfigs some tweaking might be needed. Once you provide the debug logs we can see which tsconfig files are picked for the scan and parameterize the scanner as needed to only pick the needed ones.

Cheers,
Victor

Hi Victor!!

Of course!!

I enabled and change the sonar image from 1.4.0 to 2.0.0

It’s the log with verbose.

About the tsconfig, my project don’t have the tsconfig because we are using only javascript.

The log with verbose it’s in this link:

1 Like

Hello @andre_s_ferreira,

can you create a tsconfig.sonar.json file in the root of the project with these contents?

{
  "compilerOptions": {
    "module": "ESNext",
    "target": "ESNext",
    "lib": ["DOM", "ESNext"],
    "strict": true,
    "noImplicitAny": false,
    "esModuleInterop": true,
    "jsx": "preserve",
    "skipLibCheck": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "noUnusedLocals": true,
    "strictNullChecks": true,
    "allowJs": true,
  },
  "include": [
    "src/**/*",
    "src/**/*.vue",
    "src/**/*.js",
  ]
}

Then add in your sonar.properties:

sonar.typescript.tsconfigPaths=tsconfig.sonar.json

Please let me know if that helps
Victor

1 Like

Hi Victor! Yes! I created and add, but still not working. In this pipeline the sonar it took 25 minutes to run and fail.

The log is here:

Hello @andre_s_ferreira,

seems .js files are not taken by the tsconfig.sonar.json:

14:54:19.238 DEBUG: /opt/atlassian/pipelines/agent/build/src/assets/image/ic_checkbox_filled.vue matched /opt/atlassian/pipelines/agent/build/tsconfig.sonar.json
14:54:19.238 DEBUG: /opt/atlassian/pipelines/agent/build/src/components/team_management/team/Team.vue matched /opt/atlassian/pipelines/agent/build/tsconfig.sonar.json
14:54:19.238 DEBUG: /opt/atlassian/pipelines/agent/build/src/components/shared/switch_language/SwitchLanguage.vue matched /opt/atlassian/pipelines/agent/build/tsconfig.sonar.json
14:54:19.238 DEBUG: /opt/atlassian/pipelines/agent/build/src/pages/accessManagement/Index.vue matched /opt/atlassian/pipelines/agent/build/tsconfig.sonar.json
14:54:19.238 DEBUG: /opt/atlassian/pipelines/agent/build/src/mixins/timeBoxes.js matched NO_CONFIG
14:54:19.238 DEBUG: /opt/atlassian/pipelines/agent/build/src/utils/historyState.js matched NO_CONFIG

.vue files are correctly picked up. Can you please make sure your include contains this?

  "include": [
    "src/**/*",
    "src/**/*.vue",
    "src/**/*.js",
  ]

Also, try increasing maximum memory for node process with this property in your sonar.properties:

sonar.javascript.node.maxspace=4096

Cheers,
Victor

Hi Victor, sorry my delay! Yes I added, this but still not working:

The sonar.javascript.node.maxspace=4096 I already changed to 4096 and 8192 but still not working.

Do you have any update @victor.diez?

Hello @andre_s_ferreira,

can you share the new logs?

Cheers,
Victor