Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ GOLANGCILINTER_BINARY=$(TOOLS_BIN_DIR)/golangci-lint
GOSEC_BINARY=$(TOOLS_BIN_DIR)/gosec
GOSYCLO_BINARY=$(TOOLS_BIN_DIR)/gocyclo
SWAGGO_BINARY=$(TOOLS_BIN_DIR)/swag
TOOLING=$(GOLANGCILINTER_BINARY) $(GOSEC_BINARY) $(GOSYCLO_BINARY) $(SWAGGO_BINARY)
ADDLICENSE_BINARY=$(TOOLS_BIN_DIR)/addlicense
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应更新工具变量以包含新添加的addlicense二进制文件。

🟢 Minor | 🧹 Code Smells

📋 问题详情

在Makefile中,TOOLING变量未包含新增的ADDLICENSE_BINARY,这可能导致依赖管理不完整或构建过程中遗漏该工具。为确保所有工具都被正确引用和使用,应当将ADDLICENSE_BINARY加入到TOOLING变量中。

💡 解决方案

ADDLICENSE_BINARY添加到TOOLING变量中以确保它被包含在内。

- TOOLING=$(GOLANGCILINTER_BINARY) $(GOSEC_BINARY) $(GOSYCLO_BINARY) $(SWAGGO_BINARY)
+ TOOLING=$(GOLANGCILINTER_BINARY) $(GOSEC_BINARY) $(GOSYCLO_BINARY) $(SWAGGO_BINARY) $(ADDLICENSE_BINARY)

您的反馈对我们很重要!(建议右键在新标签页中打开以下链接)

有用意见👍无用意见👎错误意见❌

TOOLING=$(GOLANGCILINTER_BINARY) $(GOSEC_BINARY) $(GOSYCLO_BINARY) $(SWAGGO_BINARY) $(ADDLICENSE_BINARY)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The addlicense binary is added to the TOOLING variable, but the installation mechanism for tools is missing the entry for addlicense. The $(TOOLING) target parses scripts/tools.go to install binaries, but github.com/google/addlicense has not been added to that file. This will cause make addlicense or make all to fail because the addlicense binary cannot be installed. Please add _ "github.com/google/addlicense" to scripts/tools.go to fix this.


GO_PKG=github.com/kubeservice-stack/$(SERVER_NAME)
COMMON_PKG ?= $(GO_PKG)/pkg
Expand All @@ -62,7 +63,7 @@ GO_BUILD_RECIPE=\
pkgs = $(shell go list ./... | grep -v /test/ | grep -v /vendor/)

.PHONY: all
all: swag format test build e2e # format test build e2e type.
all: swag addlicense format test build e2e # format test build e2e type.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应在all目标中调用addlicense任务以执行许可证检查。

🟡 Major | 🧹 Code Smells

📋 问题详情

当前all目标没有调用addlicense任务,这意味着在运行完整构建流程时不会自动进行许可证检查。为了保证代码合规性,在all目标中应该包含对addlicense的调用。

💡 解决方案

all目标中增加addlicense以确保其被执行。

- all: swag format test build e2e # format test build e2e type.
+ all: swag addlicense format test build e2e # format test build e2e type.
🔧 建议代码

[!NOTE]
AI 生成代码 - 请在应用前检查逻辑、规范并测试

Suggested change
all: swag addlicense format test build e2e # format test build e2e type.
all: swag addlicense format test build e2e # format test build e2e type.

您的反馈对我们很重要!(建议右键在新标签页中打开以下链接)

有用意见👍无用意见👎错误意见❌


.PHONY: clean
clean: # Remove all files and directories ignored by git.
Expand Down Expand Up @@ -97,6 +98,9 @@ golangci-lint: $(GOLANGCILINTER_BINARY) # golangci-lint
swag: $(SWAGGO_BINARY) # swag
$(SWAGGO_BINARY) init -g ./cmd/main.go

.PHONY: addlicense
addlicense: $(ADDLICENSE_BINARY) # addlicense
$(ADDLICENSE_BINARY) -f scripts/boilerplate.txt -ignore "{vendor/**,docs/**}" **/*.go
###########
# Testing #
###########
Expand Down
14 changes: 14 additions & 0 deletions pkg/metrics/metrics_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2024 The KubeService-Stack 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.

package metrics

import (
Expand Down
14 changes: 14 additions & 0 deletions pkg/middleware/metrics_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2024 The KubeService-Stack 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.

package middleware

import (
Expand Down
13 changes: 13 additions & 0 deletions scripts/boilerplate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2024 The KubeService-Stack 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.
2 changes: 2 additions & 0 deletions scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/bwplotka/mdox v0.9.1-0.20240703112857-a1dbd5b28516
github.com/fzipp/gocyclo v0.6.0
github.com/golangci/golangci-lint/v2 v2.6.2
github.com/google/addlicense v1.2.0
github.com/securego/gosec/v2 v2.22.10
github.com/swaggo/swag v1.16.4
)
Expand Down Expand Up @@ -61,6 +62,7 @@ require (
github.com/bep/golibsass v1.1.1 // indirect
github.com/bkielbasa/cyclop v1.2.3 // indirect
github.com/blizzy78/varnamelen v0.8.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.0.2 // indirect
github.com/bombsimon/wsl/v4 v4.7.0 // indirect
github.com/bombsimon/wsl/v5 v5.3.0 // indirect
github.com/breml/bidichk v0.3.3 // indirect
Expand Down
4 changes: 4 additions & 0 deletions scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ github.com/bkielbasa/cyclop v1.2.3 h1:faIVMIGDIANuGPWH031CZJTi2ymOQBULs9H21HSMa5
github.com/bkielbasa/cyclop v1.2.3/go.mod h1:kHTwA9Q0uZqOADdupvcFJQtp/ksSnytRMe8ztxG8Fuo=
github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ089M=
github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k=
github.com/bmatcuk/doublestar/v4 v4.0.2 h1:X0krlUVAVmtr2cRoTqR8aDMrDqnB36ht8wpWTiQ3jsA=
github.com/bmatcuk/doublestar/v4 v4.0.2/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/bombsimon/wsl/v4 v4.7.0 h1:1Ilm9JBPRczjyUs6hvOPKvd7VL1Q++PL8M0SXBDf+jQ=
github.com/bombsimon/wsl/v4 v4.7.0/go.mod h1:uV/+6BkffuzSAVYD+yGyld1AChO7/EuLrCF/8xTiapg=
github.com/bombsimon/wsl/v5 v5.3.0 h1:nZWREJFL6U3vgW/B1lfDOigl+tEF6qgs6dGGbFeR0UM=
Expand Down Expand Up @@ -309,6 +311,8 @@ github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e h1:ai0EfmVYE2b
github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e/go.mod h1:Vrn4B5oR9qRwM+f54koyeH3yzphlecwERs0el27Fr/s=
github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e h1:gD6P7NEo7Eqtt0ssnqSJNNndxe69DOQ24A5h7+i3KpM=
github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e/go.mod h1:h+wZwLjUTJnm/P2rwlbJdRPZXOzaT36/FwnPnY2inzc=
github.com/google/addlicense v1.2.0 h1:W+DP4A639JGkcwBGMDvjSurZHvaq2FN0pP7se9czsKA=
github.com/google/addlicense v1.2.0/go.mod h1:Sm/DHu7Jk+T5miFHHehdIjbi4M5+dJDRS3Cq0rncIxA=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
Expand Down
1 change: 1 addition & 0 deletions scripts/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
_ "github.com/bwplotka/mdox"
_ "github.com/fzipp/gocyclo/cmd/gocyclo"
_ "github.com/golangci/golangci-lint/v2/cmd/golangci-lint"
_ "github.com/google/addlicense"
_ "github.com/securego/gosec/v2/cmd/gosec"
_ "github.com/swaggo/swag/cmd/swag"
)