Skip to content

Commit

Permalink
Fix linter emptyStringTest rule
Browse files Browse the repository at this point in the history
by replacing the length check with a string comparison.
This rule got introduced with the new GolangCI lint version.
  • Loading branch information
mpass99 committed Feb 27, 2024
1 parent 895dd88 commit 939904d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func configureV1Router(router *mux.Router,
// It responds the release information stored in the configuration.
func Version(writer http.ResponseWriter, request *http.Request) {
release := config.Config.Sentry.Release
if len(release) > 0 {
if release != "" {
sendJSON(writer, release, http.StatusOK, request.Context())
} else {
writer.WriteHeader(http.StatusNotFound)
Expand Down
2 changes: 1 addition & 1 deletion internal/api/environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func parseEnvironmentID(request *http.Request) (dto.EnvironmentID, error) {

func parseFetchParameter(request *http.Request) (fetch bool, err error) {
fetchString := request.FormValue(fetchEnvironmentKey)
if len(fetchString) > 0 {
if fetchString != "" {
fetch, err = strconv.ParseBool(fetchString)
if err != nil {
return false, fmt.Errorf("could not parse fetch parameter: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func loadValue(prefix string, value reflect.Value, logEntry *logrus.Entry) {
}
value.SetBool(boolean)
case reflect.Slice:
if len(content) > 0 && content[0] == '"' && content[len(content)-1] == '"' {
if content != "" && content[0] == '"' && content[len(content)-1] == '"' {
content = content[1 : len(content)-1] // remove wrapping quotes
}
parts := strings.Fields(content)
Expand Down

0 comments on commit 939904d

Please sign in to comment.