SonarQube "Track copyright and license heading deficiencies" options

SonarQube has a rule to verify that each file is copyright and / or licensed. However, I am not sure how to indicate the copyright for a variable year.

For example, here is their compatible solution:

/*
 * SonarQube, open source software quality management tool.
 * Copyright (C) 2008-2013 SonarSource
 * mailto:contact AT sonarsource DOT com
 *
 * SonarQube is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * SonarQube is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

Requested Parameters:

isRegularExpression 
    Whether the headerFormat is a regular expression (Default Value: false)

.

headerFormat    
    Expected copyright and license header

If "2008-2013" was instead of one year, how could I provide a format that would allow, for example, 2015 and 2016?

+4
source share
1 answer

Our style requires a specific header for Java sources:

/*
 * [optional text] <CreationDate> [optional text]
 * <Copyright (c) yyyy FOO-COMPANY. All Rights Reserved.>
 */
Parentheses

[] means that this is optional, <> means that it must be present, i.e.

valid

/*
 *  03.05.2016
 *  Copyright (c) 2016 FOO-COMPANY. All Rights Reserved.  
 */

also valid

/*
 *  just some text 03.05.2016 Fred Fart
 *  Copyright (c) 2016 FOO-COMPANY. All Rights Reserved.  
 */

, , , ..

/*
 *  23.09.2016
 *  Copyright (c) 2013-2016 FOO-COMPANY. All Rights Reserved.  
 */

/*
 *  23.09.2016
 *  Copyright (c) 2013,2014,2016 FOO-COMPANY. All Rights Reserved.  
 */

headerFormat isRegularExpression=true
:

^.+(?:0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012])\.(19[7-9]\d|20[0-2]\d).+?Copyright \(c\) ((\b19[7-9]\d|20[0-2]\d)([,|-])?\b)* FOO-COMPANY\. All Rights Reserved\..+
+1

Source: https://habr.com/ru/post/1664446/


All Articles