SonarQube规则squid:S1451应定义版权和许可证标题

SonarQube规则squid:S1451应定义版权和许可证标题,sonarqube,sonarqube5.1,Sonarqube,Sonarqube5.1,我所有的SonarQube代码分析Java项目都在这条规则上失败 每个源文件都应该以一个标题开头,说明文件所有权和分发应用程序必须使用的许可证。 此规则必须在每个文件的开头输入预期的标题文本 有一个参数: headerFormat预期版权和许可标题(纯文本) 但是没有关于如何配置的示例。默认情况下,headerFormat为空,我找不到有关配置此规则的文档 我猜应该有某种正则表达式或模板语言可以使用?有两个参数: 头饰 isRegularExpression 在headerFormat中定义预期

我所有的SonarQube代码分析Java项目都在这条规则上失败

每个源文件都应该以一个标题开头,说明文件所有权和分发应用程序必须使用的许可证。 此规则必须在每个文件的开头输入预期的标题文本

有一个参数:

headerFormat预期版权和许可标题(纯文本)

但是没有关于如何配置的示例。默认情况下,headerFormat为空,我找不到有关配置此规则的文档

我猜应该有某种正则表达式或模板语言可以使用?

有两个参数:

  • 头饰
  • isRegularExpression
  • headerFormat中定义预期文本。如果将isRegularExpression设置为true,则文本将被视为正则表达式

    如果您使用普通文本,则需要输入完整许可证,例如:

    /*
     * Maven Plugin Utils
     * http://www.gabrys.biz/projects/maven-plugin-utils/
     *
     * Copyright (c) 2015 Adam Gabryś
     *
     * This file is licensed under the BSD 3-Clause (the "License").
     * You may not use this file except in compliance with the License.
     * You may obtain a copy of the License at:
     *
     *      https://raw.githubusercontent.com/gabrysbiz/maven-plugin-utils/master/src/main/resources/license.txt
     */
    
    如果使用正则表达式,则可以省略某些部分,例如:

    ^\/\*.+www\.gabrys\.biz\/projects\/.+Copyright \(c\) [0-9]{4}.+This file is licensed under the.+\(the "License"\)\..+You may not use this file except in compliance with the License\..+You may obtain a copy of the License at:.+$
    

    仅更改SonarQube服务器上“headerFormat”的默认文本:


    我运行的是SonarQube 5.1,只有一个参数。这里是直接从规则中剪切粘贴的:参数头在预期的版权和许可标题(纯文本)处。您应该将Java插件升级到3.4(请参阅)还有人能告诉我在哪里可以设置这些参数吗?打开
    http://sonar-host/coding_rules#rule_key=squid%3AS1451
    → 单击
    Activate
    并填写参数Sonarqube->login->Rules->查找规则S1451->单击Qulaity profile部分中的“更改”->更改headerFormat。注意:我们修复了HeadPerformat的“文本区域”而不是“文本字段”,因此对于C#来说,UI现在更好了:)