From 9d0327e7eb7b518267b582670ab59e298b5458de Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Tue, 16 Nov 2021 14:42:13 +0100 Subject: [PATCH] :green_heart: [CI] Lint the copyright headers. Signed-off-by: Oliver Tale-Yazdi --- .github/workflows/ci.yml | 2 -- .golangci.yml | 5 +++++ .scripts/check-copyright-notice.sh | 25 ------------------------- .scripts/copyright-notice | 25 ++++++++++++------------- 4 files changed, 17 insertions(+), 40 deletions(-) delete mode 100755 .scripts/check-copyright-notice.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b09b24c2..144d6d5e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,8 +18,6 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 - - name: License header - run: .scripts/check-copyright-notice.sh - name: Authors run: .scripts/check-notice-authors.sh origin/main diff --git a/.golangci.yml b/.golangci.yml index be8998b1..455c7261 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -40,6 +40,11 @@ linters-settings: cyclop: # 15 is used by go-report-card as well. max-complexity: 15 + goheader: + values: + regexp: + ANY_YEAR: "20(19|20|21)" # 2019-2021 + template-path: ".scripts/copyright-notice" forbidigo: forbid: # Forbidigo functions to start with "get" or "Get". diff --git a/.scripts/check-copyright-notice.sh b/.scripts/check-copyright-notice.sh deleted file mode 100755 index 3331b808..00000000 --- a/.scripts/check-copyright-notice.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -cn="$(dirname $(readlink -f $0))/copyright-notice" -n=$(wc -l $cn | cut -d ' ' -f 1) - -function check_cr() { - diff $cn <(head -n${n} $1 | sed -e 's/20\(19\|2[0-9]\)/20XX/') -q > /dev/null - if [ $? -ne 0 ]; then - echo $1 - diff $cn <(head -n${n} $1) - fi -} - -if [ $# -ne 0 ]; then - code=0 - for f in "$@"; do - check_cr $f - [ $? -ne 0 ] && code=1 - done - exit $code -fi - -find . \ - -path "./backend/ethereum/bindings/*" -prune \ - -o -name "*.go" -exec $0 {} + diff --git a/.scripts/copyright-notice b/.scripts/copyright-notice index e260ed04..a6ff7275 100644 --- a/.scripts/copyright-notice +++ b/.scripts/copyright-notice @@ -1,14 +1,13 @@ -// Copyright 20XX - See NOTICE file for copyright holders. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +Copyright {{ ANY_YEAR }} - See NOTICE file for copyright holders. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.