Fixed a few linter hints
This commit is contained in:
parent
0e4f7fe6ec
commit
f464e830bf
@ -1,3 +1,18 @@
|
||||
run:
|
||||
skip-dirs:
|
||||
components
|
||||
components
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- dupl
|
||||
- errcheck
|
||||
- lll
|
||||
- goconst
|
||||
- gochecknoglobals
|
||||
- gochecknoinits
|
||||
- gocyclo
|
||||
- maligned
|
||||
- scopelint
|
||||
- stylecheck
|
||||
- unparam
|
@ -189,7 +189,8 @@ func (post *Post) Edit(ctx aero.Context, key string, value reflect.Value, newVal
|
||||
consumed := false
|
||||
user := GetUserFromContext(ctx)
|
||||
|
||||
// nolint:gocritic (because this should stay a switch statement)
|
||||
// This should stay a switch statement.
|
||||
// nolint:gocritic
|
||||
switch key {
|
||||
case "ParentID":
|
||||
var newParent PostParent
|
||||
|
@ -21,7 +21,8 @@ func (settings *Settings) Authorize(ctx aero.Context, action string) error {
|
||||
|
||||
// Edit updates the settings object.
|
||||
func (settings *Settings) Edit(ctx aero.Context, key string, value reflect.Value, newValue reflect.Value) (bool, error) {
|
||||
// nolint:gocritic (because this should stay as a switch statement)
|
||||
// This should stay as a switch statement.
|
||||
// nolint:gocritic
|
||||
switch key {
|
||||
case "Theme":
|
||||
if settings.User().IsPro() {
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/akyoto/color"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/kitsu"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"errors"
|
||||
"flag"
|
||||
|
||||
"github.com/animenotifier/notify.moe/arn/stringutils"
|
||||
"github.com/animenotifier/kitsu"
|
||||
"github.com/animenotifier/notify.moe/arn/stringutils"
|
||||
)
|
||||
|
||||
// Shell parameters
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/akyoto/color"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/kitsu"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/akyoto/color"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/mal"
|
||||
malparser "github.com/animenotifier/mal/parser"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
// Read anime file
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/akyoto/color"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
malparser "github.com/animenotifier/mal/parser"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
// Read character file
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/akyoto/color"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/mal"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
const imageWidthThreshold = 225
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
|
||||
"github.com/aerogo/http/client"
|
||||
"github.com/akyoto/color"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/mal"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
// Sync titles
|
||||
|
@ -110,7 +110,7 @@ func TestQuotePages(t *testing.T) {
|
||||
// }
|
||||
// }
|
||||
|
||||
func testRoute(t *testing.T, app *aero.Application, route string) {
|
||||
func testRoute(t *testing.T, app http.Handler, route string) {
|
||||
request := httptest.NewRequest("GET", strings.ReplaceAll(route, " ", "%20"), nil)
|
||||
response := httptest.NewRecorder()
|
||||
app.ServeHTTP(response, request)
|
||||
|
@ -15,5 +15,5 @@ func Redirect(ctx aero.Context) error {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||
}
|
||||
|
||||
return ctx.Redirect(http.StatusTemporaryRedirect, "/+" + user.Nick + ctx.Path())
|
||||
return ctx.Redirect(http.StatusTemporaryRedirect, "/+"+user.Nick+ctx.Path())
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package editor
|
||||
|
||||
import (
|
||||
"github.com/akyoto/hash"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/mal"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
"github.com/animenotifier/notify.moe/utils/animediff"
|
||||
)
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/kitsu"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"github.com/animenotifier/notify.moe/utils/animediff"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/mal"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
@ -122,7 +122,8 @@ func compare(animes []*arn.Anime) []*utils.MALComparison {
|
||||
|
||||
// diff returns all the differences between an anime and its MAL counterpart.
|
||||
func diff(anime *arn.Anime, malAnime *mal.Anime) []animediff.Difference {
|
||||
// nolint (prealloc linter would complain, but this is best left as nil by default)
|
||||
// Prealloc linter would complain, but this is best left as nil by default.
|
||||
// nolint:prealloc
|
||||
var differences []animediff.Difference
|
||||
|
||||
// We'll use the following diffs
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/kitsu"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/mal"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
@ -47,11 +47,12 @@ func Anime(ctx aero.Context) error {
|
||||
continue
|
||||
}
|
||||
|
||||
if anime.Type == "tv" {
|
||||
switch anime.Type {
|
||||
case "tv":
|
||||
tv = append(tv, anime)
|
||||
} else if anime.Type == "movie" {
|
||||
case "movie":
|
||||
movies = append(movies, anime)
|
||||
} else {
|
||||
default:
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package upload
|
||||
|
||||
// We need these to decode uploaded images.
|
||||
import (
|
||||
// We need these to decode uploaded images.
|
||||
_ "image/gif"
|
||||
_ "image/jpeg"
|
||||
_ "image/png"
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/akyoto/color"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
"github.com/animenotifier/mal"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
var malDB = arn.Node.Namespace("mal").RegisterTypes((*mal.Anime)(nil))
|
||||
|
@ -2,6 +2,7 @@ package editform
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -185,7 +186,7 @@ func RenderField(b *strings.Builder, v *reflect.Value, field reflect.StructField
|
||||
}
|
||||
|
||||
// String field
|
||||
func renderStringField(b *strings.Builder, v *reflect.Value, field reflect.StructField, idPrefix string, fieldValue reflect.Value) {
|
||||
func renderStringField(b io.StringWriter, v *reflect.Value, field reflect.StructField, idPrefix string, fieldValue reflect.Value) {
|
||||
idType := field.Tag.Get("idType")
|
||||
|
||||
// Try to infer the ID type by the field name
|
||||
@ -205,20 +206,23 @@ func renderStringField(b *strings.Builder, v *reflect.Value, field reflect.Struc
|
||||
b.WriteString("<div class='widget-section-with-preview'>")
|
||||
}
|
||||
|
||||
// Input field
|
||||
if field.Tag.Get("datalist") != "" {
|
||||
switch {
|
||||
case field.Tag.Get("datalist") != "":
|
||||
dataList := field.Tag.Get("datalist")
|
||||
values := arn.DataLists[dataList]
|
||||
b.WriteString(components.InputSelection(idPrefix+field.Name, fieldValue.String(), field.Name, field.Tag.Get("tooltip"), values))
|
||||
} else if field.Tag.Get("type") == "textarea" {
|
||||
|
||||
case field.Tag.Get("type") == "textarea":
|
||||
b.WriteString(components.InputTextArea(idPrefix+field.Name, fieldValue.String(), field.Name, field.Tag.Get("tooltip")))
|
||||
} else if field.Tag.Get("type") == "upload" {
|
||||
|
||||
case field.Tag.Get("type") == "upload":
|
||||
endpoint := field.Tag.Get("endpoint")
|
||||
id := v.FieldByName("ID").String()
|
||||
endpoint = strings.Replace(endpoint, ":id", id, 1)
|
||||
|
||||
b.WriteString(components.InputFileUpload(idPrefix+field.Name, field.Name, field.Tag.Get("filetype"), endpoint))
|
||||
} else {
|
||||
|
||||
default:
|
||||
b.WriteString(components.InputText(idPrefix+field.Name, fieldValue.String(), field.Name, field.Tag.Get("tooltip")))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user