gojp / goreportcard

A report card for your Go application
https://goreportcard.com
Apache License 2.0
2k stars 250 forks source link

enhancement: add client9/misspell #52

Closed client9 closed 8 years ago

client9 commented 8 years ago

Not sure I would give or deduct points, but nice to see.

https://github.com/client9/misspell

client9 commented 8 years ago

I'll attempt to add this to gometalinter

dmitshur commented 8 years ago

That would be really nice to see! :+1:

client9 commented 8 years ago

hi @shurcooL in the meantime.. you can manually use it with gometalinter See https://github.com/client9/misspell#does-this-work-with-gometalinter for details.

shawnps commented 8 years ago

@client9 thanks, I'm looking at this now. I can't get the stdout for whatever reason. I made a small script to try to figure it out:

package main

import (
    "bufio"
    "fmt"
    "log"
    "os/exec"
    "syscall"
)

func main() {
    dir := "/Users/shawn/mygo/src/github.com/gojp/goreportcard/repos/src/github.com/ugorji/go"
    command := []string{"gometalinter", "--deadline=180s", "--disable-all", "--linter='misspell:misspell ./*.go:PATH:LINE:MESSAGE'", "--enable=misspell"}
    params := command[1:]
    params = append(params, dir+"/...")

    cmd := exec.Command(command[0], params...)
    stdout, err := cmd.StdoutPipe()
    if err != nil {
        log.Fatal(err)
    }

    err = cmd.Start()
    if err != nil {
        log.Fatal(err)
    }

    out := bufio.NewScanner(stdout)

    for out.Scan() {
        fmt.Println(out.Text())
    }
    if err := out.Err(); err != nil {
        log.Fatal(err)
    }

    err = cmd.Wait()
    if exitErr, ok := err.(*exec.ExitError); ok {
        // The program has exited with an exit code != 0

        if status, ok := exitErr.Sys().(syscall.WaitStatus); ok {
            // some commands exit 1 when files fail to pass (for example go vet)
            if status.ExitStatus() != 1 {
                log.Fatal(err)
            }
        }
    }
}

it prints nothing, but if I run the command manually I get a bunch of results. Not sure if something in there is glaringly wrong.

shawnps commented 8 years ago

(Not sure if getting misspell into gometalinter would fix this)

shawnps commented 8 years ago

I think I got it.

[]string{"gometalinter", "--deadline=180s", "--disable-all", "--linter", "misspell:misspell ./*.go:PATH:LINE:MESSAGE", "--enable=misspell"}

shawnps commented 8 years ago

This is in now with 0 weight. Added a couple of issues and a PR to misspell:

https://github.com/client9/misspell/pull/10 https://github.com/client9/misspell/issues/7 https://github.com/client9/misspell/issues/8