From 6e9eafe2d5ffffbd3a7c19354d63ccff6239f2d5 Mon Sep 17 00:00:00 2001 From: Michal Kuritka Date: Thu, 12 Sep 2024 10:23:06 +0200 Subject: [PATCH] enable linters --- .github/workflows/golagci.yaml | 4 ++-- .golangci.toml | 15 ++++++++++++ .golic.yaml | 15 ------------ .yamllint | 34 +++++++++++++++++++++++++++ main.go | 3 ++- taskfile.yaml | 42 ++++++++++++++++++++++++++++++++++ 6 files changed, 95 insertions(+), 18 deletions(-) create mode 100644 .golangci.toml create mode 100644 .yamllint create mode 100644 taskfile.yaml diff --git a/.github/workflows/golagci.yaml b/.github/workflows/golagci.yaml index 9bf4d79..f74df69 100644 --- a/.github/workflows/golagci.yaml +++ b/.github/workflows/golagci.yaml @@ -33,5 +33,5 @@ jobs: - name: GolangCI uses: golangci/golangci-lint-action@v3 with: - version: v1.55.2 - args: --timeout=3m + version: v1.61.0 + args: --timeout=3m -c .golangci.toml diff --git a/.golangci.toml b/.golangci.toml new file mode 100644 index 0000000..14b9b50 --- /dev/null +++ b/.golangci.toml @@ -0,0 +1,15 @@ +[run] +timeout = "120s" + +[output] +formats = "colored-line-number" + +[linters] +enable = [ + "gocyclo", "unconvert", "goimports", "unused", + "misspell", "nakedret", "errcheck", "ineffassign", + "goconst", "govet", "unparam", "gofmt" +] + +[issues] +exclude-use-default = false diff --git a/.golic.yaml b/.golic.yaml index 5f5d6ea..bd7a287 100644 --- a/.golic.yaml +++ b/.golic.yaml @@ -13,21 +13,6 @@ # limitations under the License. # # Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic -# Copyright 2022 The k8gb Contributors. -# -# 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. -# -# Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic golic: licenses: apache2: | diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..ba85159 --- /dev/null +++ b/.yamllint @@ -0,0 +1,34 @@ +--- +yaml-files: + - '*.yaml' + - '.yamllint' + +rules: + braces: + level: warning + max-spaces-inside: 1 + brackets: enable + colons: enable + commas: enable + comments: + level: warning + comments-indentation: + level: warning + document-end: disable + document-start: disable + empty-lines: enable + empty-values: disable + hyphens: enable + indentation: disable + key-duplicates: enable + key-ordering: disable + line-length: disable + new-line-at-end-of-file: enable + new-lines: enable + octal-values: disable + quoted-strings: disable + trailing-spaces: enable + truthy: disable + +ignore: +- ".golic.yaml" diff --git a/main.go b/main.go index c6a6d45..a51c445 100644 --- a/main.go +++ b/main.go @@ -19,9 +19,10 @@ Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic */ import ( - epclient "github.com/absaoss/cap-infra-dns/pkg/client" "os" + epclient "github.com/absaoss/cap-infra-dns/pkg/client" + "github.com/absaoss/cap-infra-dns/pkg/controller" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" diff --git a/taskfile.yaml b/taskfile.yaml new file mode 100644 index 0000000..e399fbf --- /dev/null +++ b/taskfile.yaml @@ -0,0 +1,42 @@ +# Copyright 2024 The external-dns-infoblox-webhook Contributors. +# +# 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. +# +# Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic +# https://taskfile.dev/usage/ +--- +version: '3' + +env: + TFENV_TERRAFORM_VERSION: 1.5.7 + +dotenv: ['.env'] + +tasks: + lint: + cmds: + - gitleaks detect . --no-git --verbose --config=.gitleaks.toml + - yamllint . + - goimports -w ./ + - golangci-lint run + - golic inject -t apache2 + + lint-init: + cmds: + - brew install gitleaks + - brew install yamllint + # - brew install golangci-lint + # the program is in GO 1.23, whether you use `go install` or `brew install`, + # make sure that golangci-lint is >= v1.6.0 + - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 + - go install github.com/AbsaOSS/golic@v0.7.2