diff --git a/core/http/request.go b/core/http/request.go index 0fdde8a..9fd9ce7 100644 --- a/core/http/request.go +++ b/core/http/request.go @@ -83,13 +83,13 @@ func UnwrapWebAPIRequest(context context.Context, URL, token string) (string, er return "", errors.New(resp.Message) } if !gjson.Valid(resp.Body) { - return "", fmt.Errorf("invalid json: %v", resp.Body) + return "", fmt.Errorf("Invalid JSON: %v", resp.Body) } err := gjson.Get(resp.Body, "error") if !err.Exists() { - return "", errors.New("incompatible request body") + return "", errors.New("Incompatible request body") } if err.Bool() { diff --git a/core/webapi/discovery.go b/core/webapi/discovery.go index 8ce5c7b..12e16f8 100644 --- a/core/webapi/discovery.go +++ b/core/webapi/discovery.go @@ -23,7 +23,7 @@ func GetDiscoveryArtwork(c *fiber.Ctx, mode string) ([]ArtworkBrief, error) { } resp = session.ProxyImageUrl(c, resp) if !gjson.Valid(resp) { - return nil, fmt.Errorf("invalid json: %v", resp) + return nil, fmt.Errorf("Invalid JSON: %v", resp) } data := gjson.Get(resp, "thumbnails.illust").String() @@ -48,7 +48,7 @@ func GetDiscoveryNovels(c *fiber.Ctx, mode string) ([]NovelBrief, error) { } resp = session.ProxyImageUrl(c, resp) if !gjson.Valid(resp) { - return nil, fmt.Errorf("invalid json: %v", resp) + return nil, fmt.Errorf("Invalid JSON: %v", resp) } data := gjson.Get(resp, "thumbnails.novel").String() diff --git a/core/webapi/index.go b/core/webapi/index.go index 3377e97..6240a0f 100644 --- a/core/webapi/index.go +++ b/core/webapi/index.go @@ -60,7 +60,7 @@ func GetLanding(c *fiber.Ctx, mode string) (*LandingArtworks, error) { resp = session.ProxyImageUrl(c, resp) if !gjson.Valid(resp) { - return nil, fmt.Errorf("invalid json: %v", resp) + return nil, fmt.Errorf("Invalid JSON: %v", resp) } artworks := map[string]ArtworkBrief{} diff --git a/pages/actions.go b/pages/actions.go index 25dbc14..decd75b 100644 --- a/pages/actions.go +++ b/pages/actions.go @@ -41,7 +41,7 @@ func pixivPostRequest(c *fiber.Ctx, url, payload, token, csrf string) error { } body_s := string(body) if !gjson.Valid(body_s) { - return fmt.Errorf("invalid json: %v", body_s) + return fmt.Errorf("Invalid JSON: %v", body_s) } errr := gjson.Get(body_s, "error") diff --git a/pages/artwork-multi.go b/pages/artwork-multi.go index 643a01c..33c5ec4 100644 --- a/pages/artwork-multi.go +++ b/pages/artwork-multi.go @@ -1,7 +1,6 @@ package pages import ( - "errors" "fmt" "strconv" "strings" @@ -12,8 +11,8 @@ import ( ) func ArtworkMultiPage(c *fiber.Ctx) error { - param_ids := c.Params("ids") - ids := strings.Split(param_ids, ",") + ids_ := c.Params("ids") + ids := strings.Split(ids_, ",") artworks := make([]*core.Illust, len(ids)) @@ -21,7 +20,7 @@ func ArtworkMultiPage(c *fiber.Ctx) error { wg.Add(len(ids)) for i, id := range ids { if _, err := strconv.Atoi(id); err != nil { - return errors.New("invalid id") + return fmt.Errorf("Invalid ID: %s", id) } go func(i int, id string) { diff --git a/pages/artwork.go b/pages/artwork.go index 679fc9d..5e8446d 100644 --- a/pages/artwork.go +++ b/pages/artwork.go @@ -1,7 +1,7 @@ package pages import ( - "errors" + "fmt" "strconv" core "codeberg.org/vnpower/pixivfe/v2/core/webapi" @@ -9,12 +9,12 @@ import ( ) func ArtworkPage(c *fiber.Ctx) error { - param_id := c.Params("id") - if _, err := strconv.Atoi(param_id); err != nil { - return errors.New("invalid id") + id := c.Params("id") + if _, err := strconv.Atoi(id); err != nil { + return fmt.Errorf("Invalid ID: %s", id) } - illust, err := core.GetArtworkByID(c, param_id, true) + illust, err := core.GetArtworkByID(c, id, true) if err != nil { return err } @@ -34,12 +34,12 @@ func ArtworkPage(c *fiber.Ctx) error { } func ArtworkEmbedPage(c *fiber.Ctx) error { - param_id := c.Params("id") - if _, err := strconv.Atoi(param_id); err != nil { - return errors.New("invalid id") + id := c.Params("id") + if _, err := strconv.Atoi(id); err != nil { + return fmt.Errorf("Invalid ID: %s", id) } - illust, err := core.GetArtworkByID(c, param_id, false) + illust, err := core.GetArtworkByID(c, id, false) if err != nil { return err } diff --git a/pages/novel.go b/pages/novel.go index e1390b2..2349059 100644 --- a/pages/novel.go +++ b/pages/novel.go @@ -1,7 +1,7 @@ package pages import ( - "errors" + "fmt" "strconv" core "codeberg.org/vnpower/pixivfe/v2/core/webapi" @@ -9,12 +9,12 @@ import ( ) func NovelPage(c *fiber.Ctx) error { - param_id := c.Params("id") - if _, err := strconv.Atoi(param_id); err != nil { - return errors.New("invalid id") + id := c.Params("id") + if _, err := strconv.Atoi(id); err != nil { + return fmt.Errorf("Invalid ID: %s", id) } - novel, err := core.GetNovelByID(c, param_id) + novel, err := core.GetNovelByID(c, id) if err != nil { return err } diff --git a/pages/settings.go b/pages/settings.go index 6ef0c5f..b5cce24 100644 --- a/pages/settings.go +++ b/pages/settings.go @@ -116,7 +116,7 @@ func SettingsPost(c *fiber.Ctx) error { case "reset-all": err = resetAll(c) default: - err = errors.New("no such setting available") + err = errors.New("No such setting is available.") } if err != nil { diff --git a/staticcheck.conf b/staticcheck.conf new file mode 100644 index 0000000..ebb3e0d --- /dev/null +++ b/staticcheck.conf @@ -0,0 +1 @@ +checks = ["inherit", "-ST1005"] # no "error strings should not be capitalized" \ No newline at end of file