exercism / exalysis

Mentoring tool for the Go track on Exercism. Downloads students code, checks it and provides suggestions.
33 stars 13 forks source link

gofmt failure reported as golint failure #91

Closed dysolution closed 5 years ago

dysolution commented 5 years ago

Solution: https://exercism.io/mentor/solutions/c210bad335ce46f3b3b1cbaf50901736

$ exalysis -watch -output
Watching for Exercism download links on the clipboard...
<-- Exalysis: /Users/jordan.peterson/Exercism/users/Hellcoder/go/difference-of-squares -->
I know the "diffsquares" exercise, so I'll try to make some specific suggestions about it, as well as the general code checks:
go test:         OK
go test -race:   SKIPPED
golint:          OK
gofmt:           FAIL
--- Current
+++ Formatted
@@ -4 +4 @@
-func SquareOfSum(n int) int{
+func SquareOfSum(n int) int {
@@ -9,2 +9,2 @@
-func SumOfSquares(n int) int{
-       return (n * (n + 1) * (2 * n + 1)) / 6
+func SumOfSquares(n int) int {
+       return (n * (n + 1) * (2*n + 1)) / 6
@@ -13 +13 @@
-/*Difference return difference between the square of the sum of the first n natural numbers
+/*Difference return difference between the square of the sum of the first n natural numbers
@@ -15,2 +15,2 @@
-func Difference(n int) int{
-       return SquareOfSum(n)-SumOfSquares(n)
+func Difference(n int) int {
+       return SquareOfSum(n) - SumOfSquares(n)

go vet:          OK
golangci-lint:   OK
benchmarks:      SKIPPED

Hi Hellcoder!

This looks very good!

Could you have a look at the following point so I can approve the solution?
- There's a great tool called [`golint`](https://github.com/golang/lint) which will examine your code for common problems and style issues. Try running `golint` on your code, e.g.: `golint two_fer.go`; it will make some useful suggestions for you.

    It's a good idea to always check your code with `golint` (or configure your editor to do it for you). When you're writing Go software for production, many build pipelines will automatically fail if the code doesn't pass `golint` (and `gofmt`). You can avoid this by linting code yourself prior to submitting it.

Here's something you might find interesting. It's not necessarily related to this exercise, but it will help you develop your general Go knowledge:

- At some point in your Go journey you'll find yourself needing to use a debugger. But what is a debugger and how does it work? Liz Rice's talk [A Debugger From Scratch](https://www.youtube.com/watch?v=ZrpkrMKYvqQ) walks you through the process of writing one in Go!

Feel free to ask if you have questions or want to know more. I'd love to help!

Rating Suggestion
Todos:          1
Suggestions:    0
Comments:       0
Suggestion:     NO APPROVAL
tehsphinx commented 5 years ago

Thanks! I will have a look at it.

bitfield commented 5 years ago

Same issue with 56b5e2a3532e4388bc861460bd6af8ef:

// Package scrabble computes scrabble score
// This is the prettier (much slower) version (iteration 2)
package scrabble

import (
    "regexp"
    "strings"
)

// letterPoints specifies regexes to chars and how many points they're worth
var letterPoints = map[string]int{
    "A|E|I|O|U|L|N|R|S|T": 1,
    "D|G":       2,
    "B|C|M|P":   3,
    "F|H|V|W|Y": 4,
    "K":         5,
    "J|X":       8,
    "Q|Z":       10,
}

// Score function to calculate the score of a given word
func Score(word string) int {
    var totalPoints int
    word = strings.ToUpper(word)
    for letters, points := range letterPoints {
        lettersRegex := regexp.MustCompile(letters)
        totalPoints += len(lettersRegex.FindAllStringIndex(word, -1)) * points
    }
    return totalPoints
}
tehsphinx commented 5 years ago

fixed with v0.4.3