Enable golangci linter gomnd (#3171)

This commit is contained in:
Robert Kaussow
2024-03-15 18:00:25 +01:00
committed by GitHub
parent 9bbd30fa1e
commit a779eed3df
50 changed files with 262 additions and 176 deletions

View File

@@ -61,7 +61,7 @@ func setupRouter(tokenReceived chan string) *gin.Engine {
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT")
if c.Request.Method == "OPTIONS" {
c.AbortWithStatus(204)
c.AbortWithStatus(http.StatusNoContent)
return
}
@@ -76,7 +76,7 @@ func setupRouter(tokenReceived chan string) *gin.Engine {
err := c.BindJSON(&data)
if err != nil {
log.Debug().Err(err).Msg("Failed to bind JSON")
c.JSON(400, gin.H{
c.JSON(http.StatusBadRequest, gin.H{
"error": "invalid request",
})
return
@@ -84,7 +84,7 @@ func setupRouter(tokenReceived chan string) *gin.Engine {
tokenReceived <- data.Token
c.JSON(200, gin.H{
c.JSON(http.StatusOK, gin.H{
"ok": "true",
})
})
@@ -111,7 +111,10 @@ func openBrowser(url string) error {
}
func randomPort() int {
s1 := rand.NewSource(time.Now().UnixNano())
r1 := rand.New(s1)
return r1.Intn(10000) + 20000
const minPort = 10000
const maxPort = 65535
source := rand.NewSource(time.Now().UnixNano())
rand := rand.New(source)
return rand.Intn(maxPort-minPort+1) + minPort
}