Fix golangci OOM (#2889)

* Fix golangci OOM

* Fix all lints
This commit is contained in:
kermieisinthehouse
2022-09-05 22:12:59 -07:00
committed by GitHub
parent 90baf7a469
commit 30879389ec
13 changed files with 23 additions and 31 deletions

View File

@@ -36,13 +36,13 @@ jobs:
uses: golangci/golangci-lint-action@v2 uses: golangci/golangci-lint-action@v2
with: with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.45.2 version: latest
# Optional: working directory, useful for monorepos # Optional: working directory, useful for monorepos
# working-directory: somedir # working-directory: somedir
# Optional: golangci-lint command line arguments. # Optional: golangci-lint command line arguments.
args: --modules-download-mode=vendor --timeout=3m args: --modules-download-mode=vendor --timeout=5m
# Optional: show only new issues if it's a pull request. The default value is `false`. # Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true # only-new-issues: true

View File

@@ -1,22 +1,19 @@
# options for analysis running # options for analysis running
run: run:
timeout: 3m timeout: 5m
modules-download-mode: vendor modules-download-mode: vendor
linters: linters:
disable-all: true disable-all: true
enable: enable:
# Default set of linters from golangci-lint # Default set of linters from golangci-lint
- deadcode
- errcheck - errcheck
- gosimple - gosimple
- govet - govet
- ineffassign - ineffassign
- staticcheck - staticcheck
- structcheck
- typecheck - typecheck
- unused - unused
- varcheck
# Linters added by the stash project. # Linters added by the stash project.
# - contextcheck # - contextcheck
- dogsled - dogsled

View File

@@ -1,7 +1,6 @@
package desktop package desktop
import ( import (
"io/ioutil"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@@ -93,7 +92,7 @@ func writeStashIcon(faviconProvider FaviconProvider) {
c := config.GetInstance() c := config.GetInstance()
if !c.IsNewSystem() { if !c.IsNewSystem() {
iconPath := path.Join(c.GetConfigPath(), "icon.png") iconPath := path.Join(c.GetConfigPath(), "icon.png")
err := ioutil.WriteFile(iconPath, faviconProvider.GetFaviconPng(), 0644) err := os.WriteFile(iconPath, faviconProvider.GetFaviconPng(), 0644)
if err != nil { if err != nil {
logger.Errorf("Couldn't write icon file: %s", err.Error()) logger.Errorf("Couldn't write icon file: %s", err.Error())
} }

View File

@@ -4,7 +4,6 @@
package desktop package desktop
import ( import (
"io/ioutil"
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
@@ -19,7 +18,7 @@ func isService() bool {
func isServerDockerized() bool { func isServerDockerized() bool {
_, dockerEnvErr := os.Stat("/.dockerenv") _, dockerEnvErr := os.Stat("/.dockerenv")
cgroups, _ := ioutil.ReadFile("/proc/self/cgroup") cgroups, _ := os.ReadFile("/proc/self/cgroup")
if !os.IsNotExist(dockerEnvErr) || strings.Contains(string(cgroups), "docker") { if !os.IsNotExist(dockerEnvErr) || strings.Contains(string(cgroups), "docker") {
return true return true
} }

View File

@@ -310,7 +310,8 @@ func (i *Instance) GetNotificationsEnabled() bool {
// GetShowOneTimeMovedNotification shows whether a small notification to inform the user that Stash // GetShowOneTimeMovedNotification shows whether a small notification to inform the user that Stash
// will no longer show a terminal window, and instead will be available in the tray, should be shown. // will no longer show a terminal window, and instead will be available in the tray, should be shown.
// It is true when an existing system is started after upgrading, and set to false forever after it is shown. //
// It is true when an existing system is started after upgrading, and set to false forever after it is shown.
func (i *Instance) GetShowOneTimeMovedNotification() bool { func (i *Instance) GetShowOneTimeMovedNotification() bool {
return i.getBool(ShowOneTimeMovedNotification) return i.getBool(ShowOneTimeMovedNotification)
} }

View File

@@ -32,14 +32,14 @@ func toSnakeCase(v string) string {
func fromSnakeCase(v string) string { func fromSnakeCase(v string) string {
var buf bytes.Buffer var buf bytes.Buffer
cap := false capvar := false
for i, c := range v { for i, c := range v {
switch { switch {
case c == '_' && i > 0: case c == '_' && i > 0:
cap = true capvar = true
case cap: case capvar:
buf.WriteRune(unicode.ToUpper(c)) buf.WriteRune(unicode.ToUpper(c))
cap = false capvar = false
default: default:
buf.WriteRune(c) buf.WriteRune(c)
} }

View File

@@ -487,9 +487,7 @@ func (p *SceneFilenameParser) parseScenes(repo models.ReaderRepository, scenes [
} }
p.setParserResult(repo, *sceneHolder, r) p.setParserResult(repo, *sceneHolder, r)
if r != nil { ret = append(ret, r)
ret = append(ret, r)
}
} }
} }

View File

@@ -6,7 +6,6 @@ import (
"image" "image"
"image/draw" "image/draw"
"image/png" "image/png"
"io/ioutil"
"math" "math"
"os" "os"
"sort" "sort"
@@ -85,7 +84,7 @@ func (g *InteractiveHeatmapSpeedGenerator) Generate() error {
} }
func (g *InteractiveHeatmapSpeedGenerator) LoadFunscriptData(path string) (Script, error) { func (g *InteractiveHeatmapSpeedGenerator) LoadFunscriptData(path string) (Script, error) {
data, err := ioutil.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
return Script{}, err return Script{}, err
} }

View File

@@ -4,7 +4,6 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"runtime/pprof" "runtime/pprof"
@@ -307,7 +306,7 @@ func writeStashIcon() {
} }
iconPath := filepath.Join(instance.Config.GetConfigPath(), "icon.png") iconPath := filepath.Join(instance.Config.GetConfigPath(), "icon.png")
err := ioutil.WriteFile(iconPath, p.GetFaviconPng(), 0644) err := os.WriteFile(iconPath, p.GetFaviconPng(), 0644)
if err != nil { if err != nil {
logger.Errorf("Couldn't write icon file: %s", err.Error()) logger.Errorf("Couldn't write icon file: %s", err.Error())
} }

View File

@@ -2,7 +2,6 @@ package scene
import ( import (
"bytes" "bytes"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@@ -68,7 +67,7 @@ func migrateSceneFiles(oldName, newName string) {
// #2481: migrate vtt file contents in addition to renaming // #2481: migrate vtt file contents in addition to renaming
func migrateVttFile(vttPath, oldSpritePath, newSpritePath string) { func migrateVttFile(vttPath, oldSpritePath, newSpritePath string) {
contents, err := ioutil.ReadFile(vttPath) contents, err := os.ReadFile(vttPath)
if err != nil { if err != nil {
logger.Errorf("Error reading %s for vtt migration: %v", vttPath, err) logger.Errorf("Error reading %s for vtt migration: %v", vttPath, err)
return return
@@ -79,7 +78,7 @@ func migrateVttFile(vttPath, oldSpritePath, newSpritePath string) {
contents = bytes.ReplaceAll(contents, []byte(oldSpriteBasename), []byte(newSpriteBasename)) contents = bytes.ReplaceAll(contents, []byte(oldSpriteBasename), []byte(newSpriteBasename))
if err := ioutil.WriteFile(vttPath, contents, 0644); err != nil { if err := os.WriteFile(vttPath, contents, 0644); err != nil {
logger.Errorf("Error writing %s for vtt migration: %v", vttPath, err) logger.Errorf("Error writing %s for vtt migration: %v", vttPath, err)
return return
} }

View File

@@ -6,7 +6,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"mime/multipart" "mime/multipart"
"net/http" "net/http"
"os" "os"
@@ -1042,7 +1041,7 @@ func (c *Client) submitDraft(ctx context.Context, query string, input interface{
} }
defer resp.Body.Close() defer resp.Body.Close()
responseBytes, err := ioutil.ReadAll(resp.Body) responseBytes, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -219,6 +219,7 @@ func (f *filterBuilder) addWith(sql string, args ...interface{}) {
} }
// addRecursiveWith adds a with clause and arguments to the filter, and sets it to recursive // addRecursiveWith adds a with clause and arguments to the filter, and sets it to recursive
//
//nolint:unused //nolint:unused
func (f *filterBuilder) addRecursiveWith(sql string, args ...interface{}) { func (f *filterBuilder) addRecursiveWith(sql string, args ...interface{}) {
if sql == "" { if sql == "" {

View File

@@ -12,10 +12,11 @@ type StrFormatMap map[string]interface{}
// StrFormatMap. // StrFormatMap.
// //
// For example, // For example,
// StrFormat("{foo} bar {baz}", StrFormatMap{ //
// "foo": "bar", // StrFormat("{foo} bar {baz}", StrFormatMap{
// "baz": "abc", // "foo": "bar",
// }) // "baz": "abc",
// })
// //
// would return: "bar bar abc" // would return: "bar bar abc"
func StrFormat(format string, m StrFormatMap) string { func StrFormat(format string, m StrFormatMap) string {