SonarCloud w/ BitBucket

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

As so many others, Sensor JavaScript/TypeScript analysis [javascript], is taking incredibly long. It takes 3 minutes on an 87 line file.

Then, I end up getting:

INFO: 118 source files to be analyzed
INFO: 30/118 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/dto/Mode.ts
INFO: 31/118 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/dto/HealthState.ts
INFO: 32/118 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/components/Harvest/HarvestSetupDialog/styles.tsx
INFO: 38/118 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/services/api/vision/GatewayService.ts
INFO: 38/118 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/services/api/vision/GatewayService.ts
INFO: 38/118 files analyzed, current file: /opt/atlassian/pipelines/agent/build/src/services/api/vision/GatewayService.ts
INFO: Time spent writing ucfgs 930ms
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 43307 127.0.0.1 /opt/atlassian/pipelines/agent/build/.scannerwork true false /opt/atlassian/pipelines/agent/build/.scannerwork/.sonartmp/eslint-bridge-bundle/package/custom-rules14932366831793197581/package
java.lang.IllegalStateException: eslint-bridge server is not answering

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

Here are is my pipeline yaml:

image: node:18

clone:
  depth: full

options:
  size: 2x

definitions:
  caches:
    sonar: ~/.sonar/cache
  steps:
    - step: &test-ci
        name: Run unit tests (linting - warnings allowed)
        caches:
          - node
          - sonar
        script:
          - yarn install
          - yarn lint:ci
          - yarn test:ci
          - pipe: sonarsource/sonarcloud-scan:1.4.0
            variables:
              SONAR_TOKEN: ${SONAR_TOKEN}
              SONAR_SCANNER_OPTS: -Xmx256m
              EXTRA_ARGS: '-Dsonar.sources=src -Dsonar.tests=src -Dsonar.test.inclusions="src/**/*.test.tsx" -Dsonar.typescript.lcov.reportPaths=coverage/lcov.info -Dsonar.eslint.reportPaths=result-lint.json -Dsonar.javascript.node.maxspace=8192'
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.6
          - mkdir ./test-results && cp junit.xml ./test-results/junit.xml
        artifacts:
          - coverage/**

pipelines:
  branches:
    "feature/*":
      - step: *test-ci
    "hotfix/*":
      - step: *test-ci
    "main":
      - step: *test-ci

Hey there.

We’re aware of performance issues impacting our Javascript/Typescript analyzer. A fix should be deployed soon (this week or early next week).

In the meantime, take a look at this post for a workaround:

1 Like

Hi Colin, do you have any news related to this fix? For me I’m not using the TypeScript, so this workaround don’t work for me.

@andre_s_ferreira can you create a new topic describing your issue?

Yes I can, but it’s the same issue.

Hi Colin! I created here:

I have it working. The catch is to set a memory limit for docker. Otherwise, docker uses too much memory and the pipeline locks up. Since I’m using a 2x machine (which will be required for this), I’ve set docker’s memory limit to 6MB.

See the updated script below:

image: node:18

clone:
  depth: full

options:
  size: 2x

definitions:
  caches:
    sonar: ~/.sonar/cache
  services:
    docker:
      memory: 6144
  steps:
    - step: &test-ci
        name: Run unit tests (linting - warnings allowed)
        services:
          - docker
        caches:
          - node
          - sonar
        script:
          - yarn install
          - yarn lint:ci
          - yarn test:ci
          - pipe: sonarsource/sonarcloud-scan:1.4.0
            variables:
              SONAR_TOKEN: ${SONAR_TOKEN}
              SONAR_SCANNER_OPTS: -Xmx256m
              EXTRA_ARGS: '-Dsonar.sources=src -Dsonar.tests=src -Dsonar.test.inclusions="src/**/*.test.tsx" -Dsonar.typescript.lcov.reportPaths=coverage/lcov.info -Dsonar.eslint.reportPaths=result-lint.json -Dsonar.javascript.node.maxspace=8192'
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.6
          - mkdir ./test-results && cp junit.xml ./test-results/junit.xml
        artifacts:
          - coverage/**

pipelines:
  branches:
    "feature/*":
      - step: *test-ci
    "hotfix/*":
      - step: *test-ci
    "main":
      - step: *test-ci