mirror of https://github.com/stashapp/stash.git
Remove new-from-rev from the linter (#1783)
* Fix all revive warnings in the code base All of these are of the form ``` var Identifier Type = Expr ``` where the `Type` is known from the output of `Expr` and can be omitted as a result. * Handle unchecked errors * Remove new-from-rev Since the project passes all linter checks now, including older revisions, we can remove new-from-rev. While here, reorder the linter config file, and move the enabled linters up and settings down. * Fix failing test cases Studio & Performer export tests use local time rather than UTC. This fixes the test cases so integration test passes.
This commit is contained in:
parent
b94eecae24
commit
bc6d04dc2a
|
@ -3,10 +3,23 @@ run:
|
|||
timeout: 3m
|
||||
modules-download-mode: vendor
|
||||
|
||||
issues:
|
||||
# Rev at which the linter was introduced. Older bugs are still
|
||||
# present, but should not be considered validation errors for now
|
||||
new-from-rev: b14d5c56504dfcea2f5a7b86706b0ecdafd0b68c
|
||||
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
|
||||
- gofmt
|
||||
- revive
|
||||
|
||||
linters-settings:
|
||||
gofmt:
|
||||
|
@ -52,21 +65,3 @@ linters-settings:
|
|||
- name: unreachable-code
|
||||
- name: redefines-builtin-id
|
||||
|
||||
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
|
||||
- gofmt
|
||||
- revive
|
||||
|
||||
|
|
|
@ -59,7 +59,9 @@ func (rs imageRoutes) Thumbnail(w http.ResponseWriter, r *http.Request) {
|
|||
logger.Errorf("error writing thumbnail for image %s: %s", img.Path, err)
|
||||
}
|
||||
}
|
||||
w.Write(data)
|
||||
if n, err := w.Write(data); err != nil {
|
||||
logger.Errorf("error writing thumbnail response. Wrote %v bytes: %v", n, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,10 @@ const (
|
|||
studioName = "studioName"
|
||||
)
|
||||
|
||||
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
var (
|
||||
createTime = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
updateTime = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
)
|
||||
|
||||
func createFullGallery(id int) models.Gallery {
|
||||
return models.Gallery{
|
||||
|
|
|
@ -39,8 +39,10 @@ const (
|
|||
errChecksum = "errChecksum"
|
||||
)
|
||||
|
||||
var createdAt time.Time = time.Date(2001, time.January, 2, 1, 2, 3, 4, time.Local)
|
||||
var updatedAt time.Time = time.Date(2002, time.January, 2, 1, 2, 3, 4, time.Local)
|
||||
var (
|
||||
createdAt = time.Date(2001, time.January, 2, 1, 2, 3, 4, time.Local)
|
||||
updatedAt = time.Date(2002, time.January, 2, 1, 2, 3, 4, time.Local)
|
||||
)
|
||||
|
||||
func TestImporterName(t *testing.T) {
|
||||
i := Importer{
|
||||
|
|
|
@ -53,8 +53,10 @@ const (
|
|||
//galleryChecksum = "galleryChecksum"
|
||||
)
|
||||
|
||||
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
var (
|
||||
createTime = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
updateTime = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
)
|
||||
|
||||
func createFullImage(id int) models.Image {
|
||||
return models.Image{
|
||||
|
|
|
@ -46,7 +46,9 @@ func (e *ThumbnailEncoder) GetThumbnail(img *models.Image, maxSize int) ([]byte,
|
|||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
buf.ReadFrom(reader)
|
||||
if _, err := buf.ReadFrom(reader); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, format, err := DecodeSourceImage(img)
|
||||
if err != nil {
|
||||
|
|
|
@ -44,18 +44,24 @@ const url = "url"
|
|||
|
||||
const studioName = "studio"
|
||||
|
||||
const frontImage = "ZnJvbnRJbWFnZUJ5dGVz"
|
||||
const backImage = "YmFja0ltYWdlQnl0ZXM="
|
||||
const (
|
||||
frontImage = "ZnJvbnRJbWFnZUJ5dGVz"
|
||||
backImage = "YmFja0ltYWdlQnl0ZXM="
|
||||
)
|
||||
|
||||
var frontImageBytes = []byte("frontImageBytes")
|
||||
var backImageBytes = []byte("backImageBytes")
|
||||
var (
|
||||
frontImageBytes = []byte("frontImageBytes")
|
||||
backImageBytes = []byte("backImageBytes")
|
||||
)
|
||||
|
||||
var studio models.Studio = models.Studio{
|
||||
Name: models.NullString(studioName),
|
||||
}
|
||||
|
||||
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
var (
|
||||
createTime = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
updateTime = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
)
|
||||
|
||||
func createFullMovie(id int, studioID int) models.Movie {
|
||||
return models.Movie{
|
||||
|
|
|
@ -54,8 +54,11 @@ var deathDate = models.SQLiteDate{
|
|||
String: "2021-02-02",
|
||||
Valid: true,
|
||||
}
|
||||
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.Local)
|
||||
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.Local)
|
||||
|
||||
var (
|
||||
createTime = time.Date(2001, 01, 01, 0, 0, 0, 0, time.Local)
|
||||
updateTime = time.Date(2002, 01, 01, 0, 0, 0, 0, time.Local)
|
||||
)
|
||||
|
||||
func createFullPerformer(id int, name string) *models.Performer {
|
||||
return &models.Performer{
|
||||
|
|
|
@ -87,8 +87,10 @@ var imageBytes = []byte("imageBytes")
|
|||
|
||||
const image = "aW1hZ2VCeXRlcw=="
|
||||
|
||||
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
var (
|
||||
createTime = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
updateTime = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
)
|
||||
|
||||
func createFullScene(id int) models.Scene {
|
||||
return models.Scene{
|
||||
|
|
|
@ -105,7 +105,7 @@ type filterBuilder struct {
|
|||
err error
|
||||
}
|
||||
|
||||
var errSubFilterAlreadySet error = errors.New(`sub-filter already set`)
|
||||
var errSubFilterAlreadySet = errors.New(`sub-filter already set`)
|
||||
|
||||
// sub-filter operator values
|
||||
var (
|
||||
|
|
|
@ -41,8 +41,10 @@ var imageBytes = []byte("imageBytes")
|
|||
|
||||
const image = "aW1hZ2VCeXRlcw=="
|
||||
|
||||
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.Local)
|
||||
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.Local)
|
||||
var (
|
||||
createTime = time.Date(2001, 01, 01, 0, 0, 0, 0, time.Local)
|
||||
updateTime = time.Date(2002, 01, 01, 0, 0, 0, 0, time.Local)
|
||||
)
|
||||
|
||||
func createFullStudio(id int, parentID int) models.Studio {
|
||||
ret := models.Studio{
|
||||
|
|
|
@ -23,8 +23,10 @@ const (
|
|||
|
||||
const tagName = "testTag"
|
||||
|
||||
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
var (
|
||||
createTime = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
updateTime = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
)
|
||||
|
||||
func createTag(id int) models.Tag {
|
||||
return models.Tag{
|
||||
|
|
Loading…
Reference in New Issue