Skip to content

Commit

Permalink
Ensure lint runs correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
amwat committed Jul 28, 2020
1 parent 789f8ad commit c09ca70
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
3 changes: 1 addition & 2 deletions hack/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-
*/
package tools


import (
// linter(s)
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"

// test runner
_ "gotest.tools/gotestsum"
)
)
24 changes: 24 additions & 0 deletions hack/update/gofmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Copyright 2018 The Kubernetes Authors.
#
# 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.

# script to run gofmt over our code (not vendor)
set -o errexit -o nounset -o pipefail

# cd to the repo root
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "${REPO_ROOT}"

hack/go_container.sh sh -c "find . -name '*.go' -type f -print0 | xargs -0 gofmt -s -w"
13 changes: 12 additions & 1 deletion hack/verify/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ cd "${REPO_ROOT}"
SOURCE_DIR="${REPO_ROOT}/hack/tools" GOOS="linux" hack/go_container.sh \
go build -o /out/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint


# run golangci-lint
LINTS=(
# default golangci-lint lints
deadcode errcheck gosimple govet ineffassign staticcheck \
structcheck typecheck unused varcheck \
# additional lints
golint gofmt misspell unparam scopelint gosec
)
LINTS_JOINED="$(IFS=','; echo "${LINTS[*]}")"

# first for the repo in general
SOURCE_DIR="${REPO_ROOT}" hack/go_container.sh \
/out/golangci-lint -v --enable-all --timeout=2m run .
/out/golangci-lint --disable-all --enable="${LINTS_JOINED}" --timeout=2m run ./...

0 comments on commit c09ca70

Please sign in to comment.