diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2022-01-24 03:16:38 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2022-01-24 03:16:38 +0300 |
commit | 0c3c88164b81239b1160abe065890401ff21c817 (patch) | |
tree | 531a5e438970137d93c0d7484c107c956758df4d | |
parent | bd9fc868bca3e85ba976778f0ccc6e2e28a8c2ca (diff) | |
parent | a9388ec5a852a55ee853ee1536996ebdd2514563 (diff) |
Merge branch 'ci/exclude-rules' into 'master'
ci: only skip golangci for internal/mocks
See merge request gitlab-org/gitlab-pages!661
-rw-r--r-- | .golangci.yml | 41 | ||||
-rw-r--r-- | internal/serving/disk/symlink/symlink.go | 2 | ||||
-rw-r--r-- | internal/vfs/serving/main_test.go | 6 | ||||
-rw-r--r-- | internal/vfs/serving/serving.go | 12 | ||||
-rw-r--r-- | internal/vfs/serving/serving_test.go | 16 |
5 files changed, 39 insertions, 38 deletions
diff --git a/.golangci.yml b/.golangci.yml index 6c239d92..5916cb9b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,15 +1,26 @@ run: - concurrency: 8 - deadline: 1m - issues-exit-code: 1 - modules-download-mode: readonly - tests: true + # which dirs to skip: issues from them won't be reported; + # can use regexp here: generated.*, regexp is applied on full path; + # default value is empty list, but default dirs are skipped independently + # from this option's value (see skip-dirs-use-default). + # "/" will be replaced by current OS file path separator to properly work + # on Windows. skip-dirs: - - vendor - - internal/httputil # from github.com/golang/gddo - - internal/serving/disk/symlink - skip-files: - - mock_*.go + - internal/mocks + + # default is true. Enables skipping of directories: + # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ + skip-dirs-use-default: false + + # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": + # If invoked with -mod=readonly, the go command is disallowed from the implicit + # automatic updating of go.mod described above. Instead, it fails when any changes + # to go.mod are needed. This setting is most useful to check that go.mod does + # not need updates, such as in a continuous integration and testing system. + # If invoked with -mod=vendor, the go command assumes that the vendor + # directory holds the correct copies of dependencies and ignores + # the dependency descriptions in go.mod. + modules-download-mode: readonly output: format: colored-line-number @@ -53,9 +64,9 @@ linters: fast: false issues: -# # Excluding configuration per-path, per-linter, per-text and per-source + # Excluding configuration per-path, per-linter, per-text and per-source exclude-rules: - - path: ".*_test.go" + - path: _test\.go linters: - bodyclose - gosec @@ -63,3 +74,9 @@ issues: - path: "internal/fixture/fixtures.go" linters: - gosec + + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. + max-issues-per-linter: 0 + + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. + max-same-issues: 0 diff --git a/internal/serving/disk/symlink/symlink.go b/internal/serving/disk/symlink/symlink.go index be9a87e0..c9ad0191 100644 --- a/internal/serving/disk/symlink/symlink.go +++ b/internal/serving/disk/symlink/symlink.go @@ -14,6 +14,7 @@ import ( "gitlab.com/gitlab-org/gitlab-pages/internal/vfs" ) +// nolint: gocyclo // this is vendored code func walkSymlinks(ctx context.Context, root vfs.Root, path string) (string, error) { volLen := volumeNameLen(path) pathSeparator := string(os.PathSeparator) @@ -24,6 +25,7 @@ func walkSymlinks(ctx context.Context, root vfs.Root, path string) (string, erro vol := path[:volLen] dest := vol linksWalked := 0 + // nolint: ineffassign // this is vendored code for start, end := volLen, volLen; start < len(path); start = end { for start < len(path) && os.IsPathSeparator(path[start]) { start++ diff --git a/internal/vfs/serving/main_test.go b/internal/vfs/serving/main_test.go index 56babdc8..c0c2c29f 100644 --- a/internal/vfs/serving/main_test.go +++ b/internal/vfs/serving/main_test.go @@ -2,13 +2,10 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//nolint package serving_test import ( "fmt" - "io" - "log" "net/http" "os" "runtime" @@ -18,8 +15,6 @@ import ( "time" ) -var quietLog = log.New(io.Discard, "", 0) - func TestMain(m *testing.M) { v := m.Run() if v == 0 && goroutineLeaked() { @@ -28,6 +23,7 @@ func TestMain(m *testing.M) { os.Exit(v) } +// nolint: gocyclo // this is vendored code func interestingGoroutines() (gs []string) { buf := make([]byte, 2<<20) buf = buf[:runtime.Stack(buf, true)] diff --git a/internal/vfs/serving/serving.go b/internal/vfs/serving/serving.go index 6da2c6ed..6f45e1d5 100644 --- a/internal/vfs/serving/serving.go +++ b/internal/vfs/serving/serving.go @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//nolint package serving import ( @@ -50,7 +49,7 @@ func serveContent(w http.ResponseWriter, r *http.Request, modtime time.Time, con w.WriteHeader(code) - if r.Method != "HEAD" { + if r.Method != http.MethodHead { io.Copy(w, content) } } @@ -185,7 +184,7 @@ func checkIfNoneMatch(w http.ResponseWriter, r *http.Request) condResult { } func checkIfModifiedSince(r *http.Request, modtime time.Time) condResult { - if r.Method != "GET" && r.Method != "HEAD" { + if r.Method != http.MethodGet && r.Method != http.MethodHead { return condNone } ims := r.Header.Get("If-Modified-Since") @@ -247,13 +246,12 @@ func checkPreconditions(w http.ResponseWriter, r *http.Request, modtime time.Tim } switch checkIfNoneMatch(w, r) { case condFalse: - if r.Method == "GET" || r.Method == "HEAD" { + if r.Method == http.MethodGet || r.Method == http.MethodHead { writeNotModified(w) return true - } else { - w.WriteHeader(http.StatusPreconditionFailed) - return true } + w.WriteHeader(http.StatusPreconditionFailed) + return true case condNone: if checkIfModifiedSince(r, modtime) == condFalse { writeNotModified(w) diff --git a/internal/vfs/serving/serving_test.go b/internal/vfs/serving/serving_test.go index 01ce60fc..f7bfc2e9 100644 --- a/internal/vfs/serving/serving_test.go +++ b/internal/vfs/serving/serving_test.go @@ -2,15 +2,12 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//nolint package serving_test import ( "io" - "io/fs" "net/http" "net/http/httptest" - "os" "strings" "testing" "time" @@ -25,6 +22,7 @@ var ( lastMod = time.Now() ) +// nolint: gocyclo // this is vendored code func TestServeContent(t *testing.T) { defer afterTest(t) type serveParam struct { @@ -218,7 +216,7 @@ func TestServeContent(t *testing.T) { }, } for testName, tt := range tests { - for _, method := range []string{"GET", "HEAD"} { + for _, method := range []string{http.MethodGet, http.MethodHead} { servec <- serveParam{ file: tt.file, modtime: tt.modtime, @@ -256,8 +254,6 @@ func TestServeContent(t *testing.T) { } } -type panicOnSeek struct{ io.ReadSeeker } - func Test_scanETag(t *testing.T) { tests := []struct { in string @@ -280,11 +276,3 @@ func Test_scanETag(t *testing.T) { } } } - -func mustStat(t *testing.T, fileName string) fs.FileInfo { - fi, err := os.Stat(fileName) - if err != nil { - t.Fatal(err) - } - return fi -} |