Skip to content

Commit 757a638

Browse files
authored
chore: improve linting, testing, and GitHub Actions setup (#3583)
- Update golangci-lint version from `v1.48.0` to `v1.52.2` - Remove Gitter notifications from GitHub Actions workflow - Add gosec linter settings and include specific rules - Exclude revive linter for test files - Remove Gitter badge from README.md - Delete codecov.yml file - Change function parameter name in fs.go - Remove unused parameter in defaultHandleRecovery function Signed-off-by: appleboy <[email protected]>
1 parent fe989b6 commit 757a638

File tree

6 files changed

+23
-24
lines changed

6 files changed

+23
-24
lines changed

.github/workflows/gin.yml

+1-15
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup golangci-lint
2525
uses: golangci/[email protected]
2626
with:
27-
version: v1.48.0
27+
version: v1.52.2
2828
args: --verbose
2929
test:
3030
needs: lint
@@ -75,17 +75,3 @@ jobs:
7575
- name: Format
7676
if: matrix.go-version == '1.20.x'
7777
run: diff -u <(echo -n) <(gofmt -d .)
78-
notification-gitter:
79-
needs: test
80-
runs-on: ubuntu-latest
81-
steps:
82-
- name: Notification failure message
83-
if: failure()
84-
run: |
85-
PR_OR_COMPARE="$(if [ "${{ github.event.pull_request }}" != "" ]; then echo "${{ github.event.pull_request.html_url }}"; else echo "${{ github.event.compare }}"; fi)"
86-
curl -d message="GitHub Actions [$GITHUB_REPOSITORY]($PR_OR_COMPARE) ($GITHUB_REF) [normal]($GITHUB_API_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) ($GITHUB_RUN_NUMBER)" -d level=error https://webhooks.gitter.im/e/7f95bf605c4d356372f4
87-
- name: Notification success message
88-
if: success()
89-
run: |
90-
PR_OR_COMPARE="$(if [ "${{ github.event.pull_request }}" != "" ]; then echo "${{ github.event.pull_request.html_url }}"; else echo "${{ github.event.compare }}"; fi)"
91-
curl -d message="GitHub Actions [$GITHUB_REPOSITORY]($PR_OR_COMPARE) ($GITHUB_REF) [normal]($GITHUB_API_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) ($GITHUB_RUN_NUMBER)" https://webhooks.gitter.im/e/7f95bf605c4d356372f4

.golangci.yml

+19
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ linters:
1919
- nolintlint
2020
- revive
2121
- wastedassign
22+
23+
linters-settings:
24+
gosec:
25+
# To select a subset of rules to run.
26+
# Available rules: https://github.com/securego/gosec#available-rules
27+
# Default: [] - means include all rules
28+
includes:
29+
- G102
30+
- G106
31+
- G108
32+
- G109
33+
- G111
34+
- G112
35+
- G201
36+
- G203
37+
2238
issues:
2339
exclude-rules:
2440
- linters:
@@ -37,3 +53,6 @@ issues:
3753
- path: _test\.go
3854
linters:
3955
- gosec # security is not make sense in tests
56+
- linters:
57+
- revive
58+
path: _test\.go

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
[![codecov](https://codecov.io/gh/gin-gonic/gin/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-gonic/gin)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/gin-gonic/gin)](https://goreportcard.com/report/github.com/gin-gonic/gin)
88
[![GoDoc](https://pkg.go.dev/badge/github.com/gin-gonic/gin?status.svg)](https://pkg.go.dev/github.com/gin-gonic/gin?tab=doc)
9-
[![Join the chat at https://gitter.im/gin-gonic/gin](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gin-gonic/gin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
109
[![Sourcegraph](https://sourcegraph.com/github.com/gin-gonic/gin/-/badge.svg)](https://sourcegraph.com/github.com/gin-gonic/gin?badge)
1110
[![Open Source Helpers](https://www.codetriage.com/gin-gonic/gin/badges/users.svg)](https://www.codetriage.com/gin-gonic/gin)
1211
[![Release](https://img.shields.io/github/release/gin-gonic/gin.svg?style=flat-square)](https://github.com/gin-gonic/gin/releases)
@@ -176,4 +175,4 @@ Awesome project lists using [Gin](https://github.com/gin-gonic/gin) web framewor
176175

177176
Gin is the work of hundreds of contributors. We appreciate your help!
178177

179-
Please see [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the contribution workflow.
178+
Please see [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the contribution workflow.

codecov.yml

-5
This file was deleted.

fs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (fs onlyFilesFS) Open(name string) (http.File, error) {
3939
}
4040

4141
// Readdir overrides the http.File default implementation.
42-
func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) {
42+
func (f neuteredReaddirFile) Readdir(_ int) ([]os.FileInfo, error) {
4343
// this disables directory listing
4444
return nil, nil
4545
}

recovery.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc {
103103
}
104104
}
105105

106-
func defaultHandleRecovery(c *Context, err any) {
106+
func defaultHandleRecovery(c *Context, _ any) {
107107
c.AbortWithStatus(http.StatusInternalServerError)
108108
}
109109

0 commit comments

Comments
 (0)