Skip to content

Commit

Permalink
Merge pull request #2299 from traPtitech/fix/unused-params
Browse files Browse the repository at this point in the history
無名関数のunused-parameters linterに対応
  • Loading branch information
logica0419 authored Feb 14, 2024
2 parents 61c18d3 + 7fc34b5 commit d3fe722
Show file tree
Hide file tree
Showing 25 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion cmd/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func confCommand() *cobra.Command {
return &cobra.Command{
Use: "conf",
Short: "Print loaded config variables",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
bs, err := yaml.Marshal(c)
if err != nil {
log.Fatalf("unable to marshal config to YAML: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions cmd/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func filePruneCommand() *cobra.Command {
cmd := cobra.Command{
Use: "prune",
Short: "delete files which are not used or linked to anywhere",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
// Logger
logger := getCLILogger()
defer logger.Sync()
Expand Down Expand Up @@ -152,7 +152,7 @@ func genMissingThumbnails() *cobra.Command {
return &cobra.Command{
Use: "gen-missing-thumbs",
Short: "Generate missing thumbnails",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
// Logger
logger := getCLILogger()
defer logger.Sync()
Expand Down Expand Up @@ -344,7 +344,7 @@ func genGroupImages() *cobra.Command {
return &cobra.Command{
Use: "gen-group-images",
Short: "Generate missing icons for user groups",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
// Logger
logger := getCLILogger()
defer logger.Sync()
Expand Down
2 changes: 1 addition & 1 deletion cmd/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func healthcheckCommand() *cobra.Command {
return &cobra.Command{
Use: "healthcheck",
Short: "Run healthcheck",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
logger := getCLILogger()
defer logger.Sync()

Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func migrateCommand() *cobra.Command {
cmd := cobra.Command{
Use: "migrate",
Short: "Execute database schema migration only",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
engine, err := c.getDatabase()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate_v2_to_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func migrateV2ToV3Command() *cobra.Command {
cmd := cobra.Command{
Use: "migrate-v2-to-v3",
Short: "migrate from v2 to v3 (messages, files)",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
// Logger
logger := getCLILogger()
defer logger.Sync()
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var (
var rootCommand = &cobra.Command{
Use: "traQ",
// 全コマンド共通の前処理
PersistentPreRun: func(cmd *cobra.Command, args []string) {
PersistentPreRun: func(_ *cobra.Command, _ []string) {
// enable pprof http handler
if c.Pprof {
go func() { _ = http.ListenAndServe("0.0.0.0:6060", nil) }()
Expand Down
2 changes: 1 addition & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func serveCommand() *cobra.Command {
cmd := cobra.Command{
Use: "serve",
Short: "Serve traQ API",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
// Logger
logger := getLogger()
defer logger.Sync()
Expand Down
2 changes: 1 addition & 1 deletion cmd/stamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func stampInstallEmojisCommand() *cobra.Command {
cmd := cobra.Command{
Use: "install-emojis",
Short: "download and install Unicode emojiMeta stamps",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
// Logger
logger := getCLILogger()
defer logger.Sync()
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func versionCommand() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Print version information",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
fmt.Printf("traQ %s (revision %s)\n", Version, Revision)
},
}
Expand Down
2 changes: 1 addition & 1 deletion router/extension/precond_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestCheckPreconditions(t *testing.T) {
Client: &http.Client{
Jar: nil, // クッキーは保持しない
Timeout: time.Second * 30,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse // リダイレクトを自動処理しない
},
},
Expand Down
26 changes: 13 additions & 13 deletions router/middlewares/param_retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,87 +92,87 @@ func (pr *ParamRetriever) error(err error) error {

// GroupID リクエストURLの`groupID`パラメータからGroupを取り出す
func (pr *ParamRetriever) GroupID() echo.MiddlewareFunc {
return pr.byUUID(consts.ParamGroupID, consts.KeyParamGroup, func(c echo.Context, v uuid.UUID) (interface{}, error) {
return pr.byUUID(consts.ParamGroupID, consts.KeyParamGroup, func(_ echo.Context, v uuid.UUID) (interface{}, error) {
return pr.repo.GetUserGroup(v)
})
}

// MessageID リクエストURLの`messageID`パラメータからMessageを取り出す
func (pr *ParamRetriever) MessageID() echo.MiddlewareFunc {
return pr.byUUID(consts.ParamMessageID, consts.KeyParamMessage, func(c echo.Context, v uuid.UUID) (interface{}, error) {
return pr.byUUID(consts.ParamMessageID, consts.KeyParamMessage, func(_ echo.Context, v uuid.UUID) (interface{}, error) {
return pr.mm.Get(v)
})
}

// ClientID リクエストURLの`clientID`パラメータからOAuth2Clientを取り出す
func (pr *ParamRetriever) ClientID() echo.MiddlewareFunc {
return pr.byString(consts.ParamClientID, consts.KeyParamClient, func(c echo.Context, v string) (interface{}, error) {
return pr.byString(consts.ParamClientID, consts.KeyParamClient, func(_ echo.Context, v string) (interface{}, error) {
return pr.repo.GetClient(v)
})
}

// BotID リクエストURLの`botID`パラメータからBotを取り出す
func (pr *ParamRetriever) BotID() echo.MiddlewareFunc {
return pr.byUUID(consts.ParamBotID, consts.KeyParamBot, func(c echo.Context, v uuid.UUID) (interface{}, error) {
return pr.byUUID(consts.ParamBotID, consts.KeyParamBot, func(_ echo.Context, v uuid.UUID) (interface{}, error) {
return pr.repo.GetBotByID(v)
})
}

// ChannelID リクエストURLの`channelID`パラメータからChannelを取り出す
func (pr *ParamRetriever) ChannelID() echo.MiddlewareFunc {
return pr.byUUID(consts.ParamChannelID, consts.KeyParamChannel, func(c echo.Context, v uuid.UUID) (interface{}, error) {
return pr.byUUID(consts.ParamChannelID, consts.KeyParamChannel, func(_ echo.Context, v uuid.UUID) (interface{}, error) {
return pr.cm.GetChannel(v)
})
}

// FileID リクエストURLの`fileID`パラメータからFileを取り出す
func (pr *ParamRetriever) FileID() echo.MiddlewareFunc {
return pr.byUUID(consts.ParamFileID, consts.KeyParamFile, func(c echo.Context, v uuid.UUID) (interface{}, error) {
return pr.byUUID(consts.ParamFileID, consts.KeyParamFile, func(_ echo.Context, v uuid.UUID) (interface{}, error) {
return pr.fm.Get(v)
})
}

// WebhookID リクエストURLの`webhookID`パラメータからBotを取り出す
func (pr *ParamRetriever) WebhookID() echo.MiddlewareFunc {
return pr.byUUID(consts.ParamWebhookID, consts.KeyParamWebhook, func(c echo.Context, v uuid.UUID) (interface{}, error) {
return pr.byUUID(consts.ParamWebhookID, consts.KeyParamWebhook, func(_ echo.Context, v uuid.UUID) (interface{}, error) {
return pr.repo.GetWebhook(v)
})
}

// StampID リクエストURLの`stampID`パラメータからStampを取り出します
func (pr *ParamRetriever) StampID(checkOnly bool) echo.MiddlewareFunc {
if checkOnly {
return pr.checkOnlyByUUID(consts.ParamStampID, func(c echo.Context, v uuid.UUID) (bool, error) {
return pr.checkOnlyByUUID(consts.ParamStampID, func(_ echo.Context, v uuid.UUID) (bool, error) {
return pr.repo.StampExists(v)
})
}
return pr.byUUID(consts.ParamStampID, consts.KeyParamStamp, func(c echo.Context, v uuid.UUID) (interface{}, error) {
return pr.byUUID(consts.ParamStampID, consts.KeyParamStamp, func(_ echo.Context, v uuid.UUID) (interface{}, error) {
return pr.repo.GetStamp(v)
})
}

// StampPalettesID リクエストURLの`paletteID`パラメータからStampPaletteを取り出す
func (pr *ParamRetriever) StampPalettesID() echo.MiddlewareFunc {
return pr.byUUID(consts.ParamStampPaletteID, consts.KeyParamStampPalette, func(c echo.Context, v uuid.UUID) (interface{}, error) {
return pr.byUUID(consts.ParamStampPaletteID, consts.KeyParamStampPalette, func(_ echo.Context, v uuid.UUID) (interface{}, error) {
return pr.repo.GetStampPalette(v)
})
}

// UserID リクエストURLの`userID`パラメータからUserを取り出す
func (pr *ParamRetriever) UserID(checkOnly bool) echo.MiddlewareFunc {
if checkOnly {
return pr.checkOnlyByUUID(consts.ParamUserID, func(c echo.Context, v uuid.UUID) (bool, error) {
return pr.checkOnlyByUUID(consts.ParamUserID, func(_ echo.Context, v uuid.UUID) (bool, error) {
return pr.repo.UserExists(v)
})
}
return pr.byUUID(consts.ParamUserID, consts.KeyParamUser, func(c echo.Context, v uuid.UUID) (interface{}, error) {
return pr.byUUID(consts.ParamUserID, consts.KeyParamUser, func(_ echo.Context, v uuid.UUID) (interface{}, error) {
return pr.repo.GetUser(v, true)
})
}

// ClipFolderID リクエストURLの`folderID`パラメータからClipFolderを取り出す
func (pr *ParamRetriever) ClipFolderID() echo.MiddlewareFunc {
return pr.byUUID(consts.ParamClipFolderID, consts.KeyParamClipFolder, func(c echo.Context, v uuid.UUID) (interface{}, error) {
return pr.byUUID(consts.ParamClipFolderID, consts.KeyParamClipFolder, func(_ echo.Context, v uuid.UUID) (interface{}, error) {
return pr.repo.GetClipFolder(v)
})
}
2 changes: 1 addition & 1 deletion router/oauth2/oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (env *Env) R(t *testing.T) *httpexpect.Expect {
Client: &http.Client{
Jar: nil, // クッキーは保持しない
Timeout: time.Second * 30,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse // リダイレクトを自動処理しない
},
},
Expand Down
2 changes: 1 addition & 1 deletion router/v1/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (h *Handlers) Setup(e *echo.Group) {

requiresFileAccessPerm := middlewares.CheckFileAccessPerm(h.FileManager)

gone := func(c echo.Context) error {
gone := func(_ echo.Context) error {
return herror.HTTPError(http.StatusGone, "This API has been deleted. Please migrate to v3 or newer API.")
}

Expand Down
2 changes: 1 addition & 1 deletion router/v1/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (env *Env) makeExp(t *testing.T) *httpexpect.Expect {
Client: &http.Client{
Jar: nil, // クッキーは保持しない
Timeout: 10 * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse // リダイレクトを自動処理しない
},
},
Expand Down
2 changes: 1 addition & 1 deletion router/v3/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (env *Env) R(t *testing.T) *httpexpect.Expect {
Client: &http.Client{
Jar: nil, // クッキーは保持しない
Timeout: time.Second * 30,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse // リダイレクトを自動処理しない
},
},
Expand Down
2 changes: 1 addition & 1 deletion service/bot/event/dispatcher_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func newHTTPDispatcher(logger *zap.Logger) *httpDispatcher {
client: http.Client{
Jar: nil,
Timeout: 5 * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
},
},
Expand Down
2 changes: 1 addition & 1 deletion service/bot/ws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ var (
upgrader = &websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
CheckOrigin: func(r *http.Request) bool { return true },
CheckOrigin: func(_ *http.Request) bool { return true },
}
)
2 changes: 1 addition & 1 deletion service/channel/manager_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestInitChannelManager(t *testing.T) {
func TestManagerImpl_GetChannel(t *testing.T) {
t.Parallel()

must := func(c *model.Channel, err error) *model.Channel { return c }
must := func(c *model.Channel, _ error) *model.Channel { return c }

t.Run("success", func(t *testing.T) {
t.Parallel()
Expand Down
Loading

0 comments on commit d3fe722

Please sign in to comment.