exercism / exercism/exalysis

scrabble: false positive 'LoopRuneNotByte' suggestion

Open
#87 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
33
Forks
13
PR merge metrics
No merged PRs in 30d

Description

[Solution 59997d1a390d44568ad4664a7ea13d9e](https://exercism.io/mentor/solutions/59997d1a390d44568ad4664a7ea13d9e) produces this suggestion:

> Iterating over a string produces runes. A rune represents a Unicode character and can consist of multiple bytes. Try using runes instead of bytes.

But the solution does use runes:

```go
// Package scrabble provides functions to play the game scrabble.
package scrabble

import "strings"

// Score takes a string and returns its scrabble score as an integer.
func Score(word string) int {
scores := map[string]int{
"aeioulnrst": 1,
"dg": 2,
"bcmp": 3,
"fhvwy": 4,
"k": 5,
"jx": 8,
"qz": 10,
}

var ret int

word = strings.ToLower(word)

for _, j := range word {
for k := range scores {
if strings.ContainsRune(k, j) {
ret += scores[k]
}
}
}

return ret
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the LoopRuneNotByte suggestion using the linked Scrabble solution and the code shown in the issue. Trace the analyzer rule that emits this message; done means rune iteration using strings.ContainsRune is not reported while genuine byte/rune mistakes still are, with a regression test covering this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.