Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
fix(lint): failing linter for go modules (#620)
Browse files Browse the repository at this point in the history
* fix(lint): failing linter for go modules

* fix: add E2E deps to replace allow list

* fix: rm unnecessary string substitution

* fix: target for fixing linter errors
  • Loading branch information
chrisgacsal authored Sep 4, 2023
1 parent 61b135d commit e266682
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ linters-settings:
# Replace these for trivy
- github.com/docker/docker
- oras.land/oras-go
# End-to-end testing
- github.com/spdx/tools-golang
- go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
- go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
- go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp
- cloud.google.com/go
- github.com/cucumber/godog
- k8s.io/api
- k8s.io/apimachinery
- k8s.io/client-go
- github.com/docker/cli

gosec:
# To specify a set of rules to explicitly exclude.
Expand Down
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,16 @@ bin/golangci-lint-$(GOLANGCI_VERSION): | $(BIN_DIR)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- -b "$(BIN_DIR)" "v$(GOLANGCI_VERSION)"
@mv bin/golangci-lint $@

GOMODULES := $(shell find $(ROOT_DIR) -name 'go.mod')
LINTGOMODULES = $(addprefix lint-, $(GOMODULES))
FIXGOMODULES = $(addprefix fix-, $(GOMODULES))

.PHONY: $(LINTGOMODULES)
$(LINTGOMODULES):
cd $(dir $(@:lint-%=%)) && "$(GOLANGCI_BIN)" run -c "$(GOLANGCI_CONFIG)"

.PHONY: lint-go
lint-go: bin/golangci-lint
find . -name go.mod -execdir "$(GOLANGCI_BIN)" run --tests -c "$(GOLANGCI_CONFIG)" \;
lint-go: bin/golangci-lint $(LINTGOMODULES)

.PHONY: lint-cfn
lint-cfn:
Expand All @@ -168,9 +175,12 @@ lint-cfn:
.PHONY: lint
lint: lint-go lint-cfn ## Run linters

.PHONY: $(FIXGOMODULES)
$(FIXGOMODULES):
cd $(dir $(@:fix-%=%)) && "$(GOLANGCI_BIN)" run -c "$(GOLANGCI_CONFIG)" --fix

.PHONY: fix
fix: bin/golangci-lint ## Fix lint violations
./bin/golangci-lint run --fix
fix: bin/golangci-lint $(FIXGOMODULES) ## Fix lint violations

bin/licensei: bin/licensei-${LICENSEI_VERSION}
@ln -sf licensei-${LICENSEI_VERSION} bin/licensei
Expand Down
2 changes: 1 addition & 1 deletion e2e/basic_scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var _ = ginkgo.Describe("Running a basic scan (only SBOM)", func() {
ginkgo.It("should finish successfully", func(ctx ginkgo.SpecContext) {
ginkgo.By("waiting until test asset is found")
assetsParams := models.GetAssetsParams{
Filter: utils.PointerTo(fmt.Sprintf("%s", DefaultScope)),
Filter: utils.PointerTo(DefaultScope),
}
gomega.Eventually(func() bool {
assets, err := client.GetAssets(ctx, assetsParams)
Expand Down

0 comments on commit e266682

Please sign in to comment.