首页 > 解决方案 > SonarCloud 分支没有代码行 - bitbucket 管道 - sonarsource/sonarcloud-scan

问题描述

我正在尝试将 sonarcloud 与 Bitbucket 管道集成。我有一个简单的测试项目,其中包含几行名为 index.php 的单个文件。

我完全不确定我应该遵循什么方法。

我创建了包含以下几行的 sonar-project.properties 文件。

sonar.sourceEncoding=UTF-8
sonar.host.url=https://sonarcloud.io/dashboard?id=first_ftp
sonar.projectKey=first_ftp

这是我的 yml 文件

image: aariacarterweir/lamp-gitftp:latest

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
  steps:
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
        caches:
          - node
          - sonar
        script:
          - npm install --quiet
          - npm run test -- --code-coverage --no-watch --no-progress --browsers=ChromeHeadlessNoSandbox  
          - pipe: sonarsource/sonarcloud-scan:0.1.5
            variables:
              SONAR_TOKEN: ${SONAR_TOKEN}
              EXTRA_ARGS: '-Dsonar.sources=src -Dsonar.tests=src -Dsonar.test.inclusions="**/testing/**,**/*.spec.ts" -Dsonar.typescript.lcov.reportPaths=coverage/lcov.info'

当我查看 sonarcloud 网站时,它告诉

The main branch has no lines of code

任何人都可以帮助我如何使用 bitbucket 为 php 项目正确配置 sonarcloud。

标签: phpbitbucket-pipelinessonarcloud

解决方案


我遇到了同样的问题——在我的情况下是因为项目的名称——它被称为---------Test,显然,默认情况下,Sonar 会将其视为测试程序集并将其排除在分析之外。


推荐阅读