我的所有 SonarQube 代码分析 Java 项目都未能遵循此规则。
每个源文件都应以标头开头,说明文件所有权以及分发应用程序必须使用的许可证。
此规则必须包含每个文件开头所需的标题文本。
有一个参数:
headerFormat 预期的版权和许可标头(纯文本)
但没有关于如何配置的示例。默认情况下 headerFormat 为空,我找不到有关配置此规则的文档。
我猜应该有某种可以使用的正则表达式或模板语言?
鱿鱼:S1451“应定义版权和许可证标头” https://rules.sonarsource.com/java/RSPEC-1451有两个参数:
- 标题格式
- 是正则表达式
In 标题格式您定义预期的文本。如果你设置是正则表达式设置为 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:.+$
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)