0

当 CodeSniffer 分析返回一些错误但没有运气时,我尝试将 Scrutinizer 配置为失败。

这是我到目前为止所尝试的:

V1:

build:
  tests:
    override:
        command: './vendor/bin/phpcs ./src --report=checkstyle --report-file=cs-data'
        analysis:
          file: 'cs-data'
          format: 'php-cs-checkstyle'

V2:

build:
  tests:
    override:
      - 'phpcs-run'

我的工具和build_failure_conditions

tools:
  php_code_sniffer:
    config:
      standard: "PSR2"
checks:
  php:
    code_rating: true
    duplication: true
build_failure_conditions:
  - 'issues.label("coding-style").new.exists'

少了什么东西?

4

1 回答 1

2

TLDR;您似乎没有指定要扫描哪些文件夹以查找错误。

尝试使用以下内容:

build:
  tests:
    override:
      - 'phpcs-run --standard=custom/standard/ruleset.xml --ignore=app/*/*/Test/ app/dir1/ app/dir2/ app/other/folder'

一些需要我澄清的事情:

  • scrutinizer 目前不支持 phpcs 命令失败(类似于 phpunit),因为这会阻止问题在 UI 中显示。
  • 解决方法是设置一个失败条件(你已经做过),例如是否存在编码风格问题,那么这将使构建失败。

我目前正在使用:

build_failure_conditions:
  - 'issues.label("coding-style").new.exists'

这使得检查看起来像这样

有关如何设置故障条件的更多信息: https ://scrutinizer-ci.com/docs/configuration/build_status

于 2017-09-01T23:50:54.390 回答