diff --git a/.golangci.yml b/.golangci.yml index 389e30d8..32d944f3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,132 +1,9 @@ version: "2" linters: - # inverted configuration with `default: all` and `disable` is not scalable during updates of golangci-lint - default: none - enable: - - bodyclose - - dogsled - - dupl - - errcheck - - errorlint - - exhaustive - - funlen - - gocheckcompilerdirectives - - gochecknoinits - - gocritic - - gocyclo - - godox - - goprintffuncname - - gosec - - govet - - ineffassign - - lll - - misspell - - mnd - - nakedret - - nolintlint - - prealloc - - revive - - rowserrcheck - - staticcheck - - testifylint - - unconvert - - unparam - - unused - - whitespace - settings: - dupl: - threshold: 100 - exhaustive: - default-signifies-exhaustive: false - funlen: - lines: 100 - statements: 100 - gocritic: - disabled-checks: - - dupImport # https://github.com/go-critic/go-critic/issues/845 - - ifElseChain - - octalLiteral - - whyNoLint - - wrapperFunc - enabled-tags: - - diagnostic - - experimental - - opinionated - - performance - - style - gocyclo: - min-complexity: 15 - govet: - enable: - - nilness - - shadow - lll: - line-length: 140 - misspell: - locale: US - mnd: - # don't include the "operation" and "assign" - checks: - - argument - - case - - condition - - return - ignored-numbers: - - "0" - - "1" - - "2" - - "3" - - "0666" - - "0700" - - "0700" - ignored-functions: - - strings.SplitN - - make - nolintlint: - allow-unused: false # report any unused nolint directives - require-explanation: false # require an explanation for nolint directives - require-specific: true # require nolint directives to be specific about which linter is being skipped - staticcheck: - checks: - - "all" - - "-QF*" + default: standard exclusions: - generated: lax presets: - - comments - - common-false-positives - - legacy - std-error-handling - rules: - - linters: - - gochecknoinits - path: cmd/.*.go - - linters: - - dupl - - funlen - - gochecknoinits - - gocyclo - - lll - - scopelint - path: .*_test.go - - linters: - - misspell - text: "[aA]uther" - - linters: - - mnd - text: strconv.Parse - paths: - - frontend/ - -formatters: - enable: - - goimports - settings: - goimports: - local-prefixes: - - github.com/filebrowser/filebrowser - exclusions: - generated: lax paths: - frontend/ diff --git a/cmd/docs.go b/cmd/docs.go index 5f26daf9..90e5a259 100644 --- a/cmd/docs.go +++ b/cmd/docs.go @@ -21,7 +21,7 @@ func init() { func printToc(names []string) { for i, name := range names { name = strings.TrimSuffix(name, filepath.Ext(name)) - name = strings.Replace(name, "-", " ", -1) + name = strings.ReplaceAll(name, "-", " ") names[i] = name } @@ -29,7 +29,7 @@ func printToc(names []string) { toc := "" for _, name := range names { - toc += "* [" + name + "](cli/" + strings.Replace(name, " ", "-", -1) + ".md)\n" + toc += "* [" + name + "](cli/" + strings.ReplaceAll(name, " ", "-") + ".md)\n" } fmt.Println(toc) @@ -84,7 +84,7 @@ func generateDocs(cmd *cobra.Command, dir string) error { } } - basename := strings.Replace(cmd.CommandPath(), " ", "-", -1) + ".md" + basename := strings.ReplaceAll(cmd.CommandPath(), " ", "-") + ".md" filename := filepath.Join(dir, basename) f, err := os.Create(filename) if err != nil { diff --git a/http/preview.go b/http/preview.go index 1abc6019..cb64ba9c 100644 --- a/http/preview.go +++ b/http/preview.go @@ -124,12 +124,12 @@ func createPreview(imgSvc ImgService, fileCache FileCache, options []img.Option ) - switch { - case previewSize == PreviewSizeBig: + switch previewSize { + case PreviewSizeBig: width = 1080 height = 1080 options = append(options, img.WithMode(img.ResizeModeFit), img.WithQuality(img.QualityMedium)) - case previewSize == PreviewSizeThumb: + case PreviewSizeThumb: width = 256 height = 256 options = append(options, img.WithMode(img.ResizeModeFill), img.WithQuality(img.QualityLow), img.WithFormat(img.FormatJpeg)) diff --git a/http/public.go b/http/public.go index 5e9e01ba..92c8102d 100644 --- a/http/public.go +++ b/http/public.go @@ -98,8 +98,8 @@ var publicShareHandler = withHashFile(func(w http.ResponseWriter, r *http.Reques file := d.raw.(*files.FileInfo) if file.IsDir { - file.Listing.Sorting = files.Sorting{By: "name", Asc: false} - file.Listing.ApplySort() + file.Sorting = files.Sorting{By: "name", Asc: false} + file.ApplySort() return renderJSON(w, r, file) } diff --git a/http/raw.go b/http/raw.go index cbddad59..f2548155 100644 --- a/http/raw.go +++ b/http/raw.go @@ -32,7 +32,7 @@ func parseQueryFiles(r *http.Request, f *files.FileInfo, _ *users.User) ([]strin fileSlice = append(fileSlice, f.Path) } else { for _, name := range names { - name, err := url.QueryUnescape(strings.Replace(name, "+", "%2B", -1)) //nolint:govet + name, err := url.QueryUnescape(strings.ReplaceAll(name, "+", "%2B")) if err != nil { return nil, err } diff --git a/http/resource.go b/http/resource.go index 8785c681..fba422df 100644 --- a/http/resource.go +++ b/http/resource.go @@ -37,8 +37,8 @@ var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d } if file.IsDir { - file.Listing.Sorting = d.user.Sorting - file.Listing.ApplySort() + file.Sorting = d.user.Sorting + file.ApplySort() return renderJSON(w, r, file) } diff --git a/search/conditions.go b/search/conditions.go index 970171a1..c7bcd3b9 100644 --- a/search/conditions.go +++ b/search/conditions.go @@ -48,8 +48,8 @@ func parseSearch(value string) *searchOptions { } // removes the options from the value - value = strings.Replace(value, "case:insensitive", "", -1) - value = strings.Replace(value, "case:sensitive", "", -1) + value = strings.ReplaceAll(value, "case:insensitive", "") + value = strings.ReplaceAll(value, "case:sensitive", "") value = strings.TrimSpace(value) types := typeRegexp.FindAllStringSubmatch(value, -1) diff --git a/settings/dir.go b/settings/dir.go index 25289ee4..0e857950 100644 --- a/settings/dir.go +++ b/settings/dir.go @@ -42,7 +42,7 @@ func (s *Settings) MakeUserDir(username, userScope, serverRoot string) (string, func cleanUsername(s string) string { // Remove any trailing space to avoid ending on - s = strings.Trim(s, " ") - s = strings.Replace(s, "..", "", -1) + s = strings.ReplaceAll(s, "..", "") // Replace all characters which not in the list `0-9A-Za-z@_\-.` with a dash s = invalidFilenameChars.ReplaceAllString(s, "-")