Update check_license_header rule with new year

It was inserting comments with 2020 in. I've updated it to figure out
the current year. This theoretically could cause problems if people are
either side of a year on New Years eve, but I'm hoping people are busy
not working then :D

Bug: none
Change-Id: I9f6cc9329189d89e6994cc0963fa70617cb446c3
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2696660
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
This commit is contained in:
Jack Franklin
2021-02-16 12:53:28 +00:00
committed by Commit Bot
parent a86d1166dc
commit 5bb7528e13
2 changed files with 10 additions and 8 deletions
@@ -12,8 +12,9 @@ const path = require('path');
const FRONT_END_FOLDER = path.join(__filename, '..', '..', '..', '..', 'front_end');
const CURRENT_YEAR = new Date().getFullYear();
const LINE_LICENSE_HEADER = [
'Copyright 2020 The Chromium Authors. All rights reserved.',
`Copyright ${CURRENT_YEAR} The Chromium Authors. All rights reserved.`,
'Use of this source code is governed by a BSD-style license that can be',
'found in the LICENSE file.',
];
@@ -48,7 +49,8 @@ const BLOCK_LICENSE_HEADER = [
'OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.',
];
const LINE_REGEXES = LINE_LICENSE_HEADER.map(line => new RegExp('[ ]?' + line.replace('2020', '(\\(c\\) )?\\d{4}')));
const LINE_REGEXES =
LINE_LICENSE_HEADER.map(line => new RegExp('[ ]?' + line.replace(CURRENT_YEAR, '(\\(c\\) )?\\d{4}')));
const BLOCK_REGEX = new RegExp('[\\s\\\\n\\*]*' + BLOCK_LICENSE_HEADER.join('[\\s\\\\n\\*]*'), 'm');
const LICENSE_HEADER_ADDITION = LINE_LICENSE_HEADER.map(line => `// ${line}`).join('\n') + '\n\n';
@@ -104,7 +104,7 @@ import * as Common from '../common/common.js';
code: 'import * as Action from \'./Action.js\';',
filename: 'front_end/ui/ui.js',
errors: [{message: 'Missing license header'}],
output: `// Copyright 2020 The Chromium Authors. All rights reserved.
output: `// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -119,7 +119,7 @@ import * as Action from './Action.js';
filename: 'front_end/ui/ui.js',
errors: [{message: 'Incorrect line license header'}],
output: `
// Copyright 2020 The Chromium Authors. All rights reserved.
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -135,7 +135,7 @@ import * as Action from './Action.js';
(async function() {})();`,
filename: 'test/webtests/http/tests/devtools/a11y-axe-core/sources/call-stack-a11y-test.js',
errors: [{message: 'Incorrect line license header'}],
output: `// Copyright 2020 The Chromium Authors. All rights reserved.
output: `// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -156,7 +156,7 @@ import * as Action from './Action.js';
filename: 'front_end/ui/ui.js',
errors: [{message: 'Incorrect line license header'}],
output: `
// Copyright 2020 The Chromium Authors. All rights reserved.
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -179,7 +179,7 @@ import * as Action from './Action.js';
filename: 'front_end/ui/ui.js',
errors: [{message: 'Incorrect block license header'}],
output: `
// Copyright 2020 The Chromium Authors. All rights reserved.
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -213,7 +213,7 @@ interface String {
filename: 'front_end/legacy/legacy-defs.d.ts',
errors: [{message: 'Missing license header'}],
output: `
// Copyright 2020 The Chromium Authors. All rights reserved.
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.