Skip to content

isogram: false positive on variable declaration with zero value #76

@tehsphinx

Description

@tehsphinx

False positive on solution: https://exercism.io/mentor/solutions/6356bab9214544fe85b37b0c646c183b?iteration_idx=3

package isogram

import (
	"strings"
	"unicode"
)

//IsIsogram returns true if string is isogram
func IsIsogram(word string) bool {
	wordUpper := strings.ToUpper(word)
	for i := 0; i < len(wordUpper); i++ {
		if unicode.IsLetter(rune(wordUpper[i])) {
			if strings.Count(wordUpper, string(wordUpper[i])) > 1 {
				return false
			}
		}
	}
	return true
}

Wrong output:

  • If you're declaring a variable which can be initialized with its zero value, then var s string is more idiomatic than an assignment: s := "".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions