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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 23 additions and 31 deletions

View file

@ -36,13 +36,13 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
# 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
# working-directory: somedir
# 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`.
# only-new-issues: true

View file

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

View file

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

View file

@ -4,7 +4,6 @@
package desktop
import (
"io/ioutil"
"os"
"os/exec"
"strings"
@ -19,7 +18,7 @@ func isService() bool {
func isServerDockerized() bool {
_, 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") {
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
// 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 {
return i.getBool(ShowOneTimeMovedNotification)
}

View file

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

View file

@ -487,9 +487,7 @@ func (p *SceneFilenameParser) parseScenes(repo models.ReaderRepository, scenes [
}
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/draw"
"image/png"
"io/ioutil"
"math"
"os"
"sort"
@ -85,7 +84,7 @@ func (g *InteractiveHeatmapSpeedGenerator) Generate() error {
}
func (g *InteractiveHeatmapSpeedGenerator) LoadFunscriptData(path string) (Script, error) {
data, err := ioutil.ReadFile(path)
data, err := os.ReadFile(path)
if err != nil {
return Script{}, err
}

View file

@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime/pprof"
@ -307,7 +306,7 @@ func writeStashIcon() {
}
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 {
logger.Errorf("Couldn't write icon file: %s", err.Error())
}

View file

@ -2,7 +2,6 @@ package scene
import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
@ -68,7 +67,7 @@ func migrateSceneFiles(oldName, newName string) {
// #2481: migrate vtt file contents in addition to renaming
func migrateVttFile(vttPath, oldSpritePath, newSpritePath string) {
contents, err := ioutil.ReadFile(vttPath)
contents, err := os.ReadFile(vttPath)
if err != nil {
logger.Errorf("Error reading %s for vtt migration: %v", vttPath, err)
return
@ -79,7 +78,7 @@ func migrateVttFile(vttPath, oldSpritePath, newSpritePath string) {
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)
return
}

View file

@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
@ -1042,7 +1041,7 @@ func (c *Client) submitDraft(ctx context.Context, query string, input interface{
}
defer resp.Body.Close()
responseBytes, err := ioutil.ReadAll(resp.Body)
responseBytes, err := io.ReadAll(resp.Body)
if err != nil {
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
//
//nolint:unused
func (f *filterBuilder) addRecursiveWith(sql string, args ...interface{}) {
if sql == "" {

View file

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