Make linter happy and move to os from io/ioutil for reading/writing.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-08-14 15:49:05 +05:00
parent df5671586e
commit 2ec0e28243
28 changed files with 99 additions and 99 deletions

View File

@@ -92,7 +92,7 @@ func pasteGETWebInterface(ectx echo.Context) error {
errtpl := templater.GetErrorTemplate(ectx, "Paste #"+pasteIDStr+" not found")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, errtpl)
}
@@ -114,7 +114,7 @@ func pasteGETWebInterface(ectx echo.Context) error {
if err == pasteExpired || err == pasteNotFound || err == pasteTimestampInvalid {
errtpl := templater.GetErrorTemplate(ectx, "Paste #"+pasteIDRaw+" not found")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusNotFound, errtpl)
}
@@ -123,7 +123,7 @@ func pasteGETWebInterface(ectx echo.Context) error {
if err == pasteCookieInvalid {
ctx.Logger.Info().Int("paste ID", pasteID).Msg("Invalid cookie, redirecting to auth page")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.Redirect(http.StatusMovedPermanently, "/paste/"+pasteIDStr+"/"+ectx.Param("timestamp")+"/verify")
}
@@ -181,7 +181,7 @@ func pasteGETWebInterface(ectx echo.Context) error {
// Get template and format it.
pasteHTML := templater.GetTemplate(ectx, "paste.html", pasteData)
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusOK, pasteHTML)
}
@@ -200,7 +200,7 @@ func pastePasswordedVerifyGet(ectx echo.Context) error {
errtpl := templater.GetErrorTemplate(ectx, "Paste #"+pasteIDRaw+" not found")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, errtpl)
}
@@ -216,7 +216,7 @@ func pastePasswordedVerifyGet(ectx echo.Context) error {
if cookieValue == cookie.Value {
ctx.Logger.Info().Msg("Valid cookie, redirecting to paste page...")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.Redirect(http.StatusMovedPermanently, "/paste/"+pasteIDRaw+"/"+ectx.Param("timestamp"))
}
@@ -230,7 +230,7 @@ func pastePasswordedVerifyGet(ectx echo.Context) error {
verifyHTML := templater.GetTemplate(ectx, "passworded_paste_verify.html", htmlData)
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusOK, verifyHTML)
}
@@ -240,7 +240,7 @@ func pastePasswordedVerifyPost(ectx echo.Context) error {
dbConn := ctx.Database.GetDatabaseConnection()
if ctx.Config.Database.Type != flatfiles.FlatFileDialect && dbConn == nil {
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.Redirect(http.StatusFound, "/database_not_available")
}
@@ -257,7 +257,7 @@ func pastePasswordedVerifyPost(ectx echo.Context) error {
ctx.Logger.Error().Err(err1).Int("paste ID", pasteID).Msg("Failed to get paste")
errtpl := templater.GetErrorTemplate(ectx, "Paste #"+strconv.Itoa(pasteID)+" not found")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, errtpl)
}
@@ -267,7 +267,7 @@ func pastePasswordedVerifyPost(ectx echo.Context) error {
errtpl := templater.GetErrorTemplate(ectx, "Paste #"+strconv.Itoa(pasteID)+" not found")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, errtpl)
}
@@ -280,13 +280,13 @@ func pastePasswordedVerifyPost(ectx echo.Context) error {
cookie.Expires = time.Now().Add(24 * time.Hour)
ectx.SetCookie(cookie)
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.Redirect(http.StatusFound, "/paste/"+strconv.Itoa(pasteID)+"/"+timestampRaw)
}
errtpl := templater.GetErrorTemplate(ectx, "Invalid password. Please, try again.")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, errtpl)
}
@@ -296,7 +296,7 @@ func pasteRawGETWebInterface(ectx echo.Context) error {
// We should check if database connection available.
dbConn := ctx.Database.GetDatabaseConnection()
if ctx.Config.Database.Type != flatfiles.FlatFileDialect && dbConn == nil {
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.Redirect(http.StatusFound, "/database_not_available/raw")
}
@@ -311,14 +311,14 @@ func pasteRawGETWebInterface(ectx echo.Context) error {
if err1 != nil {
ctx.Logger.Error().Err(err1).Int("paste ID", pasteID).Msg("Failed to get paste from database")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, "Paste #"+pasteIDRaw+" does not exist.")
}
if paste.IsExpired() {
ctx.Logger.Error().Int("paste ID", pasteID).Msg("Paste is expired")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, "Paste #"+pasteIDRaw+" does not exist.")
}
@@ -330,7 +330,7 @@ func pasteRawGETWebInterface(ectx echo.Context) error {
if err2 != nil {
ctx.Logger.Error().Err(err2).Int("paste ID", pasteID).Str("provided timestamp", tsProvidedStr).Msg("Invalid timestamp provided for getting private paste")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.String(http.StatusBadRequest, "Paste #"+pasteIDRaw+" not found")
}
@@ -338,12 +338,12 @@ func pasteRawGETWebInterface(ectx echo.Context) error {
if tsProvided != pasteTS {
ctx.Logger.Error().Int("paste ID", pasteID).Int64("provided timestamp", tsProvided).Int64("paste timestamp", pasteTS).Msg("Incorrect timestamp provided for private paste")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.String(http.StatusBadRequest, "Paste #"+pasteIDRaw+" not found")
}
}
// nolint
//nolint
// ToDo: figure out how to handle passworded pastes here.
// Return error for now.
if paste.Password != "" {
@@ -351,6 +351,6 @@ func pasteRawGETWebInterface(ectx echo.Context) error {
return ectx.String(http.StatusBadRequest, "Paste #"+pasteIDRaw+" not found")
}
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.String(http.StatusOK, paste.Data)
}

View File

@@ -24,7 +24,7 @@ func pastePOSTWebInterface(ectx echo.Context) error {
// We should check if database connection available.
dbConn := ctx.Database.GetDatabaseConnection()
if ctx.Config.Database.Type != flatfiles.FlatFileDialect && dbConn == nil {
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.Redirect(http.StatusFound, "/database_not_available")
}
@@ -34,7 +34,7 @@ func pastePOSTWebInterface(ectx echo.Context) error {
errtpl := templater.GetErrorTemplate(ectx, "Cannot create empty paste")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, errtpl)
}
@@ -46,7 +46,7 @@ func pastePOSTWebInterface(ectx echo.Context) error {
errtpl := templater.GetErrorTemplate(ectx, "Empty pastes aren't allowed.")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, errtpl)
}
@@ -55,7 +55,7 @@ func pastePOSTWebInterface(ectx echo.Context) error {
errtpl := templater.GetErrorTemplate(ectx, "Invalid 'Paste should be available for' parameter passed. Please do not try to hack us ;).")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, errtpl)
}
@@ -65,11 +65,11 @@ func pastePOSTWebInterface(ectx echo.Context) error {
errtpl := templater.GetErrorTemplate(ectx, "Invalid captcha solution.")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, errtpl)
}
// nolint:exhaustruct
//nolint:exhaustruct
paste := &structs.Paste{
Title: params["paste-title"][0],
Data: params["paste-contents"][0],
@@ -103,7 +103,7 @@ func pastePOSTWebInterface(ectx echo.Context) error {
errtpl := templater.GetErrorTemplate(ectx, "Invalid 'Paste should be available for' parameter passed. Please do not try to hack us ;).")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, errtpl)
}
}
@@ -144,7 +144,7 @@ func pastePOSTWebInterface(ectx echo.Context) error {
errtpl := templater.GetErrorTemplate(ectx, "Failed to save paste. Please, try again later.")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusBadRequest, errtpl)
}
@@ -153,10 +153,10 @@ func pastePOSTWebInterface(ectx echo.Context) error {
// Private pastes have it's timestamp in URL.
if paste.Private {
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.Redirect(http.StatusFound, "/paste/"+newPasteIDAsString+"/"+strconv.FormatInt(paste.CreatedAt.Unix(), 10))
}
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.Redirect(http.StatusFound, "/paste/"+newPasteIDAsString)
}

View File

@@ -41,7 +41,7 @@ func pastesGET(ectx echo.Context) error {
// We should check if database connection available.
dbConn := ctx.Database.GetDatabaseConnection()
if ctx.Config.Database.Type != flatfiles.FlatFileDialect && dbConn == nil {
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.Redirect(http.StatusFound, "/database_not_available")
}
@@ -68,7 +68,7 @@ func pastesGET(ectx echo.Context) error {
noPastesToShowTpl := templater.GetErrorTemplate(ectx, "No pastes to show.")
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusOK, noPastesToShowTpl)
}
@@ -106,6 +106,6 @@ func pastesGET(ectx echo.Context) error {
pasteListTpl := templater.GetTemplate(ectx, "pastelist_list.html", map[string]string{"pastes": pastesString, "pagination": paginationHTML})
// nolint:wrapcheck
//nolint:wrapcheck
return ectx.HTML(http.StatusOK, pasteListTpl)
}