Giter VIP home page Giter VIP logo

qax-os / goreporter Goto Github PK

View Code? Open in Web Editor NEW
3.1K 100.0 269.0 29.61 MB

A Golang tool that does static analysis, unit testing, code review and generate code quality report.

License: Apache License 2.0

Go 70.46% HTML 29.45% Makefile 0.03% Shell 0.01% Emacs Lisp 0.02% Vim Script 0.01% Dockerfile 0.02%
codereview reporter golang golang-tools test staticcheck linter unit-testing static-analysis unit-test

goreporter's Introduction

goreporter

goreporter Version Status

Current Release Build Status GoDoc License

A Golang tool that does static analysis, unit testing, code review and generate code quality report. This is a tool that concurrently runs a whole bunch of those linters and normalizes their output to a report:

Supported linters

  • gofmt - Checks if the code is properly formatted and could not be further simplified.
  • govet - Reports variables that may have been unintentionally shadowed.
  • golint - Golint is a linter for Go source code.
  • unittest - Golang unit test status.
  • deadcode - Finds unused code.
  • gocyclo - Computes the cyclomatic complexity of functions.
  • varcheck - Find unused global variables and constants.
  • structcheck - Find unused struct fields.
  • aligncheck - Warn about un-optimally aligned structures.
  • errcheck - Check that error return values are used.
  • copycode(dupl) - Reports potentially duplicated code.
  • gosimple - Report simplifications in code.
  • staticcheck - Statically detect bugs, both obvious and subtle ones.
  • godepgraph - Godepgraph is a program for generating a dependency graph of Go packages.
  • misspell - Correct commonly misspelled English words... quickly.
  • countcode - Count lines and files of project.
  • interfacer - Suggest narrower interfaces that can be used.
  • depth - Count the maxdepth of go functions.
  • flen - Flen provides stats on functions/methods lengths in a Golang package.

Template

  • html template file which can be loaded via -t <file>.

Todo List

  • This version will re-design the template.
  • Add interfacer and safesql and gofmt(-s),govet linter.

Installing

Requirements

Quickstart

Install goreporter (see above).

go get -u github.com/360EntSecGroup-Skylar/goreporter

Run it:

NOTE

You have to confirm that your project is operational. In particular, the problem with vendor, when the package is not found in the default path, goreporter will look again from the possible vendor path.

goreporter -p [projectRelativePath] -r [reportPath] -e [exceptPackagesName] -f [json/html/text]  {-t templatePathIfHtml}
  • -version Version of GoReporter.
  • -p Must be a valid Golang project path.
  • -r Save the path to the report.
  • -e Exceptional packages (multiple separated by commas, for example: "linters/aligncheck,linters/cyclo" ).
  • -f report format json, html OR text.
  • -t Template path,if not specified, the default template will be used.

By default, the default template is used to generate reports in html format.

Example

goreporter-display

you can see result detail:online-example-report

Credits

Logo is designed by Ri Xu

goreporter's People

Contributors

98p avatar arthurgustin avatar bhageena avatar edsonmedina avatar fearblackcat avatar jgeiger avatar kentokento avatar mmb avatar vincenthou avatar wgliang avatar xuri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goreporter's Issues

Can't exclude linters/spellcheck and vendor

Looks like -e flag isn't working with linters/spellcheck.

When running goreporter on our project the following way:

$ goreporter -e vendor,linters/spellcheck -f json -p ../thunderbolt 

SpellCheck isn't being ignored. When running ignoring only vendor:

$ goreporter -e vendor -f json -p ../thunderbolt 

It looks like every linter is ignoring vendor, but SpellCheck isn't.

Evidences:

...
        "compress": {
          "name": "github.com/pagarme/thunderbolt/vendor/github.com/klauspost/compress",
          "description": "",
          "errors": [
            {
              "line_number": 23,
              "error_string": "/home/derek/go/src/github.com/pagarme/thunderbolt/vendor/github.com/klauspost/compress/README.md:23:141: \"progresssion\" is a misspelling of \"progressions\""
            },
            {
              "line_number": 200,
              "error_string": "/home/derek/go/src/github.com/pagarme/thunderbolt/vendor/github.com/klauspost/compress/README.md:200:121: \"descibed\" is a misspelling of \"described\""
            }
          ]
        },
...

expects import "mvdan.cc/lint"

Can't get this library, because of:

MacBook-Pro-3:tmp gideon$ mkdir 2
MacBook-Pro-3:tmp gideon$ cd 2
MacBook-Pro-3:2 gideon$ ls
MacBook-Pro-3:2 gideon$ export GOPATH=`pwd`
MacBook-Pro-3:2 gideon$ go get -u github.com/360EntSecGroup-Skylar/goreporter
package github.com/mvdan/lint: code in directory /tmp/2/src/github.com/mvdan/lint expects import "mvdan.cc/lint"

The template path is not specified

Using HEAD...

goreporter -p ./myproject gives
[Apollo]2017/04/11 14:18:39 The template path is not specified

The README.md indicates specifying the template file is optional. I don't have a template file and would prefer it just supply me with a default template file for now. Thanks.

Exclude vendor from tests ?

Hello,

I was actually looking for a tool to generate a code quality report on our PRs, it seems to fit to my needs ! Thank you

But Is there a way not to test the vendor folder ?

Number of lines of code

Hello, first of all your package is awesome, instant fan! One issue I found is, even though I exclude -e vendor, number of lines of code shows including vendor.

checked project should not be in vendor...

goreporter -p go/src/github.com/go-siris/siris/ -r go/src/github.com/go-siris/siris/ -f HTML
E0719 10:05:53.902039   25724 depend.go:81] failed to import go/src/github.com/go-siris/siris/: cannot find package "vendor/go/src/github.com/go-siris/siris/" in any of:
        /usr/local/go/src/vendor/go/src/github.com/go-siris/siris (from $GOROOT)
        /root/go/src/vendor/go/src/github.com/go-siris/siris (from $GOPATH)

Would you mind to change the organisation name to lowercase?

So there was an issue about case-sensitive of the famous library logrus, And it ended up with some updates from it:

Seeing weird case-sensitive problems? It's in the past been possible to
import Logrus as both upper- and lower-case. Due to the Go package environment,
this caused issues in the community and we needed a standard. Some environments
experienced problems with the upper-case variant, so the lower-case was decided.
Everything using logrus will need to use the lower-case:
github.com/sirupsen/logrus. Any package that isn't, should be changed.

So I kindly suggest we'd better to not use uppercase in organisation, as it's part of the go import path. To make the import path consistent with go practices, also to avoid some weird issues in potential.

This suggestion of changing organisation name might be imappropriate, but I hope you guys could consider this for the future of this awesome library.

Detect locks passed by value in goreporter

It’s not good and the root cause is Percentage method passes lock by value so engine.Summaries is actually called on a copy of the lock. It’s very easy to overlook, especially in bigger programs. It isn’t detected by the compiler since this might be an intention of the programmer. This is where vet steps in…
qq20180503-105310
@wgliang
So I will pull request if you concur to fix this problem.

Improvements in code design

Hello,
I've worked on a pull request, and I found it hard to read the code: there are several big functions and a lot of repetitions.
I have identified the strategy pattern to handle the different linters, what do you think about a possible rework of the code base ?

runtime error: slice bounds out of range

[Apollo]2017/04/13 15:01:22 checked spell error
panic: runtime error: slice bounds out of range

goroutine 23 [running]:
panic(0x4b5fc0, 0xc420014100)
/usr/local/go/src/runtime/panic.go:500 +0x1a1
main.PackageAbsPathExceptSuffix(0xc42000c034, 0x27, 0x537d8a, 0x1)
/Users/yongxue/GoglandProjects/src/github.com/wgliang/goreporter/utils.go:87 +0x14d
main.(*Reporter).Engine.func5(0x7fff5fbff986, 0x1, 0xc4201900c0, 0xc42011f340)
/Users/yongxue/GoglandProjects/src/github.com/wgliang/goreporter/engine.go:180 +0x126
created by main.(*Reporter).Engine
/Users/yongxue/GoglandProjects/src/github.com/wgliang/goreporter/engine.go:185 +0x6ec

Failure to go get because of moved gcimporter15

It appears goreporter relies on gcimporter15, which has been moved:
https://go-review.googlesource.com/c/tools/+/105977
https://godoc.org/golang.org/x/tools/go

Code location that imports it:
https://github.com/360EntSecGroup-Skylar/goreporter/blob/master/linters/simplecode/lint/lint.go#L23

Example error when running go get -u github.com/360EntSecGroup-Skylar/goreporter:

package golang.org/x/tools/go/gcimporter15: cannot find package "golang.org/x/tools/go/gcimporter15" in any of:
	/usr/local/go/src/golang.org/x/tools/go/gcimporter15 (from $GOROOT)
	/home/ubuntu/.go_workspace/src/golang.org/x/tools/go/gcimporter15 (from $GOPATH)
	/usr/local/go_workspace/src/golang.org/x/tools/go/gcimporter15

Report is broken

The report generated does not show anything, because of Javascript errors.
Tried creating one for https://github.com/bnkamalesh/webgo
Console messages:

~/work/go/src/github.com/bnkamalesh/webgo$ goreporter -p . -r /Users/kamaleshbn/work/goreports -e vendor -f html

2017/11/22 08:07:54 The template path is not specified,and will use the default template
2017/11/22 08:07:54 Linter:CountCode over,time consuming 0.046931516s
2017/11/22 08:07:54 Linter:Cyclo over,time consuming 0.049227278s
2017/11/22 08:07:54 Linter:Deadcode over,time consuming 0.051225361s
2017/11/22 08:07:54 Linter:DependGraph over,time consuming 0.128242779s
2017/11/22 08:07:54 Linter:Depth over,time consuming 0.131379589s
2017/11/22 08:07:55 Linter:ImportPackages over,time consuming 0.701771379s
2017/11/22 08:07:58 Linter:Interfacer over,time consuming 4.181231735s
2017/11/22 08:07:58 Linter:Simple over,time consuming 4.182170975s
2017/11/22 08:07:58 Linter:SpellCheck over,time consuming 4.252713143s
2017/11/22 08:07:58 Linter:UnitTest over,time consuming 4.252735585s
2017/11/22 08:07:58 Linter:GoLint over,time consuming 4.283109573s
2017/11/22 08:07:58 Linter:GoVet over,time consuming 4.454926856s
2017/11/22 08:07:58 To display report file:///~/work/goreports/webgo-2017-11-22-08-07-58.html in browser
2017/11/22 08:07:59 GoReporter Finished,time consuming 4.628932044s

Generated report file is attached
webgo.zip

function deepness

Hello, I've made a change in the gocyclo github.com/arthurgustin/gocyclo in order to get the max-depth of each function.
The problem is that:

switch a {
    case 1:
    case 2:
    case 3:
    ...
    case N:
}

which is ok to me, has a high cyclomatic complexity and is equivalent to

if true {
    if true{
        if true {
            ...
                if true {
                }
        }
    }
}

which is certainly not ok.

So I added an option in the CLI to do that.
Is there any way to integrate this change ? The user may choose what he wants, depending on the use case ?
I could work on it

Support Windows

goreporter -p /GoProjects/src/github.com/go-siris/siris -r /GoProjects/src/github.com/go-siris/ -f HTML
deadcode: \GoProjects\src\github.com\go-siris\siris\context.go:17:10: expected type, found '=' (and 3 more errors)
2017/07/19 10:46:14 \GoProjects\src\github.com\go-siris\siris\context.go:17:10: expected type, found '=' (and 3 more errors)
E0719 10:46:15.067566   15020 depend.go:81] failed to import /GoProjects/src/github.com/go-siris/siris: cannot find package "vendor\\/GoProjects/src/github.com/go-siris/siris" in any of:
        C:\Go\src\vendor\GoProjects\src\github.com\go-siris\siris (from $GOROOT)
        C:\GoProjects\src\vendor\GoProjects\src\github.com\go-siris\siris (from $GOPATH)

stuck while generate report

In my repo dir:

>> goreporter -r . -p . -f html
2018/11/06 17:59:04 The template path is not specified,and will use the default template
2018/11/06 17:59:04 There are no packages that are excepted, review all items of the package
2018/11/06 17:59:05 Linter:CountCode over,time consuming 1.567595063s
2018/11/06 17:59:05 Linter:Cyclo over,time consuming 1.64384756s
2018/11/06 17:59:05 Linter:Deadcode over,time consuming 1.644238291s
  GOREPORTER  10/100

stuck here forever.

for my env:

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/XXX/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/XXX/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/90/hr1_x8993q9fyw7gf7g_85v80000gp/T/go-build392347019=/tmp/go-build -gno-record-gcc-switches -fno-common"

copycode with Path: null

The generated reports do not have the path filled.
(Windows)

var resData = {
    score:  77 ,
    avgcover: "84.9",
    date:"2017-07-24 12:22:26",
    codelines:  17919 ,
    gosimple_issue:  0 ,
    deadcode_count:  0 ,
    cycol_count:  0 ,
    project: "",
    gotest:{
        res: "[]",
        summary: "84.9",
        noTest: "[]"
    },
    gosimple: "[]",
    gospell:"[]",
    gosimpleLevel: 2,
    deadcode: "[]",
    copycode: "[{\"Files\":\"2\",\"Path\":null},{\"Files\":\"2\",\"Path\":null},{\"Files\":\"2\",\"Path\":null},{\"Files\":\"3\",\"Path\":null},{\"Files\":\"3\",\"Path\":null},{\"Files\":\"2\",\"Path\":null},{\"Files\":\"3\",\"Path\":null},{\"Files\":\"7\",\"Path\":null},{\"Files\":\"2\",\"Path\":null},{\"Files\":\"2\",\"Path\":null},{\"Files\":\"2\",\"Path\":null},{\"Files\":\"2\",\"Path\":null},{\"Files\":\"2\",\"Path\":null},{\"Files\":\"4\",\"Path\":null},{\"Files\":\"3\",\"Path\":null},{\"Files\":\"6\",\"Path\":null}]",
    gocyclo :"[{\"Pkg\":\"\",\"Size\":60,\"Info\":null}]"
}

HTML do so not render... and shows only "Please wait..." is it only works on linux?

How can I install stable version-1.1.1

➜ GoglandProjects go get -u github.com/wgliang/goreporter/tree/version-1.1.1
package github.com/wgliang/goreporter/tree/version-1.1.1: cannot find package "github.com/wgliang/goreporter/tree/version-1.1.1" in any of:
/usr/local/go/src/github.com/wgliang/goreporter/tree/version-1.1.1 (from $GOROOT)
/Users/yongxue/GoglandProjects/src/github.com/wgliang/goreporter/tree/version-1.1.1 (from $GOPATH)

average coverage calculation

I tried to check code coverage with gocov and goreporter. I found that the value of code coverage i get using goreporter differs than the value i get using gocov.

for following stats

package percentage lines-covered
pkg-1 90.57% 48/53
pkg-2 83.08% 54/65
pkg-3 77.59% 135/174

  1. code coverage using goreporter is (90.57+83.08+77.59)/3 = 83.74% (average of percentage code coverage of individual package)
  2. code coverage using gocov is = (237*100)/292 = 81.16% (percentage of line covered in whole project).

My concern is which of the above two is more accurate?

Slice bounds out of range

With HEAD and all previous versions, there are panics.

Here's a possible stack trace:

 ./goreporter -d . -p . -t templates/template.html
[Apollo]2017/04/07 04:48:38 There are no packages that are excepted, review all items of the package
[Apollo]2017/04/07 04:48:38 start code quality assessment...
[Apollo]2017/04/07 04:48:38 computing cyclo...
[Apollo]2017/04/07 04:48:38 running unit test...
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
main.DirList.func1(0xc42025a9d0, 0x9, 0x17aee20, 0xc4202aad00, 0x0, 0x0, 0x0, 0x0)
	/Users/foo/Downloads/goreporter/utils.go:54 +0x219
path/filepath.walk(0xc42025a9d0, 0x9, 0x17aee20, 0xc4202aad00, 0xc42026f3b0, 0x0, 0x0)
	/usr/local/Cellar/go/1.8/libexec/src/path/filepath/path.go:351 +0x81
path/filepath.walk(0x7fff5fbff8cd, 0x1, 0x17aee20, 0xc420286a90, 0xc42026f3b0, 0x0, 0x30)
	/usr/local/Cellar/go/1.8/libexec/src/path/filepath/path.go:376 +0x414
path/filepath.Walk(0x7fff5fbff8cd, 0x1, 0xc42026f3b0, 0x0, 0xc42026f380)
	/usr/local/Cellar/go/1.8/libexec/src/path/filepath/path.go:398 +0x14c
main.DirList(0x7fff5fbff8cd, 0x1, 0x15683b2, 0x3, 0x0, 0x0, 0xc42001bf50, 0x0, 0x0)

Have access to the coverage report

Hello,
In my gitlab-ci pipeline, I currently have 2 jobs before building sources:

  • code_quality: that mainly use goreporter
  • test: that runs all tests and export a html report of the code coverage

My main aim is to merge those 2 jobs into 1.
For this, I would like to have access to the coverage report when I click on the coverage button of the default html template of goreporter.

For instance, this is the code I actually use in my job:

cd MYPROJECT
ginkgo -r -cover
for f in `find . -name "*.coverprofile"`; do cat $f >> coverage/MYPROJECT.coverprofile; done;
sed -i -e '2,${ /^mode.*atomic/d }' coverage/MYPROJECT.coverprofile
go tool cover -func=coverage/MYPROJECT.coverprofile
go tool cover -html=coverage/MYPROJECT.coverprofile -o coverage/MYPROJECT.coverprofile.html

It just merges all coverage report into 1 and then create the html.

goreporter generates runtime error: invalid memory address

Hello,

Attempting to run goreporter on my project but it gets an error.

❯❯❯ goreporter -p . -r . -f html                                                                                                                                                                                                                                  
2018/01/02 11:50:04 The template path is not specified,and will use the default template
2018/01/02 11:50:04 There are no packages that are excepted, review all items of the package
2018/01/02 11:50:04 Linter:CountCode over,time consuming 0.007610744s
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8049e6c]

goroutine 35 [running]:
sync/atomic.AddUint64(0x1a75eb2c, 0xa, 0x0, 0x0, 0x0)
        /home/mjohn/software/go/src/sync/atomic/asm_386.s:112 +0xc
github.com/360EntSecGroup-Skylar/goreporter/engine/processbar.LinterProcessBar(0x1a89a000, 0x1a8152c0)
        /home/mjohn/workspaces/goprojects/src/github.com/360EntSecGroup-Skylar/goreporter/engine/processbar/processbar.go:82 +0x31d
created by main.main
        /home/mjohn/workspaces/goprojects/src/github.com/360EntSecGroup-Skylar/goreporter/main.go:151 +0x803

My project is able to build via go build and there is no vendor directory to exclude. This is with HEAD of goreporter.

❯❯❯ goreporter -version                                                                                                                                                                                                                                           
GoReporter v3.0.0
❯❯❯ go version                                                                                                                                                                                                                                                      
go version go1.9.1 linux/386

Compile error with go1.11

go get -u github.com/360EntSecGroup-Skylar/goreporter
go: finding github.com/360EntSecGroup-Skylar/goreporter latest
go: downloading github.com/360EntSecGroup-Skylar/goreporter v0.0.0-20180523022159-2993f1c8801c
go: finding github.com/facebookgo/inject latest
go: finding github.com/reconquest/barely latest
go: finding github.com/golang/glog latest
go: finding github.com/json-iterator/go v1.1.5
go: finding github.com/reconquest/loreley latest
go: finding golang.org/x/tools/go/gcexportdata latest
go: finding golang.org/x/tools/go/ssa latest
go: finding golang.org/x/tools/go/gcimporter15 latest
go: finding github.com/fatih/color v1.7.0
go: downloading github.com/facebookgo/inject v0.0.0-20180706035515-f23751cae28b
go: downloading github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
go: downloading github.com/reconquest/barely v0.0.0-20160729074550-0f12e3bb2e13
go: downloading github.com/json-iterator/go v1.1.5
go: finding golang.org/x/tools/go/loader latest
go: finding golang.org/x/tools/go latest
go: finding golang.org/x/tools/go/ssa/ssautil latest
go: downloading github.com/reconquest/loreley v0.0.0-20160708080500-2ab6b7470a54
go: finding github.com/kisielk/gotool v1.0.0
go: finding golang.org/x/tools latest
go: downloading golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52
go: downloading github.com/fatih/color v1.7.0
go: downloading github.com/kisielk/gotool v1.0.0
go: finding github.com/mattn/go-isatty v0.0.3
go: finding github.com/modern-go/concurrent latest
go: finding github.com/facebookgo/structtag latest
go: finding github.com/modern-go/reflect2 v1.0.1
go: finding github.com/mattn/go-colorable v0.0.9
go: finding golang.org/x/crypto/ssh/terminal latest
go: downloading github.com/mattn/go-isatty v0.0.3
go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: downloading github.com/modern-go/reflect2 v1.0.1
go: downloading github.com/mattn/go-colorable v0.0.9
go: downloading github.com/facebookgo/structtag v0.0.0-20150214074306-217e25fb9691
go: finding golang.org/x/crypto/ssh latest
go: finding golang.org/x/crypto latest
go: downloading golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac
go: finding golang.org/x/sys/unix latest
go: finding golang.org/x/sys latest
go: downloading golang.org/x/sys v0.0.0-20180828065106-d99a578cf41b
build github.com/360EntSecGroup-Skylar/goreporter: cannot find module for path mvdan.cc/lint
lichaodeMacBook-Pro:cyeam lichao$ go get -u mvdan.cc/lint/cmd/metalint
go get mvdan.cc/lint/cmd/metalint: unrecognized import path "mvdan.cc/lint/cmd/metalint" (https fetch: Get https://mvdan.cc/lint/cmd/metalint?go-get=1: net/http: TLS handshake timeout)

goreporter mac os cannot find err

run command :goreporter -p ./ -r ./goreporter/
we run tools find error :`
.//fmterr.go:6: Printf format %d has arg str of wrong type string
.//log/dev.go
.//log/encode.go
.//log/jsonstring.go
.//log/log.go
.//main.go
.//monitor/monitor.go
.//monitor/monitor_test.go
.//test.go
vet: .//test.go: .//test.go:2:5: expected declaration, found 'IDENT' sfdasfasdfsdfjl

but run : goreporter -p ./ -r ./goreporter/ cannot find :
install command : go get -u github.com/360EntSecGroup-Skylar/goreporter
anything env need ?

Not finding 'github.com/wgliang/barely'

Seems like go get-ing the latest version fails with:

macbook-pro-3:2 gideon$ export GOPATH=`pwd`
macbook-pro-3:2 gideon$ go get -u github.com/360EntSecGroup-Skylar/goreporter
# cd .; git clone https://github.com/wgliang/barely /tmp/2/src/github.com/wgliang/barely
Cloning into '/tmp/2/src/github.com/wgliang/barely'...
remote: Repository not found.
fatal: repository 'https://github.com/wgliang/barely/' not found
package github.com/wgliang/barely: exit status 128

Not finding all of my packages

I have a project located in this path:

$GOPATH/src/github.com/devopsdays/devopsdays-cli

The file structure looks like this:

.
├── cmd
├── create
├── helpers
├── model
└── main.go
└── templates
    └── events

(that is to say, cmd, create, helpers, and model are all packages)

Inside of the $GOPATH/src/github.com/devopsdays/devopsdays-cli directory, I run:
goreporter -p ../devopsdays-cli

The dependency graph doesn't show anything:

depgraph

However, if I go into the helpers directory and run:

goreporter -p ../helpers

I get the dep graph:

helpers

Any ideas on what I might be doing wrong?

Support recursive reports

I wanted to try this out on a project with multiple modules. It doesn't seem to support it, either reporting on the top-level ./ path or the Go-style ./...

➜  project git:(v2) goreporter -p ./ -d ./-t ../../wgliang/goreporter/templates/template.html
[Apollo]2017/04/06 10:44:46 There are no packages that are excepted, review all items of the package
[Apollo]2017/04/06 10:44:46 start code quality assessment...
[Apollo]2017/04/06 10:44:46 computing cyclo...
[Apollo]2017/04/06 10:44:46 running unit test...
[Apollo]2017/04/06 10:44:46 simpling code...
[Apollo]2017/04/06 10:44:46 simpled code!
[Apollo]2017/04/06 10:44:46 checking copy code...
[Apollo]2017/04/06 10:44:46 running staticscan...
[Apollo]2017/04/06 10:44:46 creating depend graph...
[Apollo]2017/04/06 10:44:46 checking dead code...
[Apollo]2017/04/06 10:44:46 checking spell error...
[Apollo]2017/04/06 10:44:46 getting import packages...
[Apollo]2017/04/06 10:44:46 checked dead code
[Apollo]2017/04/06 10:44:46 failed to import ./: no buildable Go source files in /Users/copeet/go/src/github.com/WatchBeam/project

➜  project git:(v2) goreporter -p ./... -d ./-t ../../wgliang/goreporter/templates/template.html
[Apollo]2017/04/06 10:44:57 There are no packages that are excepted, review all items of the package
[Apollo]2017/04/06 10:44:57 start code quality assessment...
[Apollo]2017/04/06 10:44:57 lstat ./...: no such file or directory
[Apollo]2017/04/06 10:44:57 computing cyclo...
[Apollo]2017/04/06 10:44:57 lstat ./...: no such file or directory
[Apollo]2017/04/06 10:44:57 simpling code...
[Apollo]2017/04/06 10:44:57 simpled code!
[Apollo]2017/04/06 10:44:57 checking copy code...
[Apollo]2017/04/06 10:44:57 running staticscan...
[Apollo]2017/04/06 10:44:57 creating depend graph...
[Apollo]2017/04/06 10:44:57 checking dead code...
[Apollo]2017/04/06 10:44:57 checking spell error...
[Apollo]2017/04/06 10:44:57 getting import packages...
[Apollo]2017/04/06 10:44:57 cyclo over!
[Apollo]2017/04/06 10:44:57 running unit test...
[Apollo]2017/04/06 10:44:57 unit test over!
panic: lstat ./...: no such file or directory

goroutine 18 [running]:
panic(0x4ad180, 0xc4201003f0)
	/usr/local/Cellar/go/1.7.1/libexec/src/runtime/panic.go:500 +0x1a1
github.com/wgliang/goreporter/linters/copycheck.crawlPaths.func1(0xc42010c1a0, 0x1, 0x1, 0xc420240000, 0x56d672, 0x8)
	/Users/copeet/go/src/github.com/wgliang/goreporter/linters/copycheck/copycheck.go:97 +0x1fd
created by github.com/wgliang/goreporter/linters/copycheck.crawlPaths
	/Users/copeet/go/src/github.com/wgliang/goreporter/linters/copycheck/copycheck.go:119 +0x93

Race condition

There seems to be a race condition popping up randomly, when I start the HEAD version:

[Apollo]2017/04/06 09:43:54 There are no packages that are excepted, review all items of the package
[Apollo]2017/04/06 09:43:54 start code quality assessment...
[Apollo]2017/04/06 09:43:54 computing cyclo...
[Apollo]2017/04/06 09:43:54 running unit test...
[Apollo]2017/04/06 09:43:54 simpling code...
[Apollo]2017/04/06 09:43:54 simpled code!
[Apollo]2017/04/06 09:43:54 checking copy code...
[Apollo]2017/04/06 09:43:54 running staticscan...
[Apollo]2017/04/06 09:43:54 creating depend graph...
[Apollo]2017/04/06 09:43:54 checking dead code...
[Apollo]2017/04/06 09:43:54 checking spell error...
[Apollo]2017/04/06 09:43:54 getting import packages...
fatal error: concurrent map read and map write

goroutine 37 [running]:
runtime.throw(0x169cb67, 0x21)
/usr/local/go/src/runtime/panic.go:596 +0x95 fp=0xc42003eba8 sp=0xc42003eb88
runtime.mapaccess2_faststr(0x14e5e00, 0xc4201361e0, 0x7fff5fbff7dc, 0x1, 0x0, 0x0)
/usr/local/go/src/runtime/hashmap_fast.go:326 +0x50a fp=0xc42003ec08 sp=0xc42003eba8
flag.(*FlagSet).parseOne(0xc42001e0c0, 0x0, 0x0, 0x0)
/usr/local/go/src/flag/flag.go:865 +0x192 fp=0xc42003ee10 sp=0xc42003ec08
flag.(*FlagSet).Parse(0xc42001e0c0, 0xc4200100a0, 0x8, 0x8, 0x0, 0x0)
/usr/local/go/src/flag/flag.go:913 +0x60 fp=0xc42003ee40 sp=0xc42003ee10
flag.Parse()
/usr/local/go/src/flag/flag.go:941 +0x72 fp=0xc42003ee80 sp=0xc42003ee40
github.com/wgliang/goreporter/linters/copycheck.CopyCheck(0x7fff5fbff7f6, 0x17, 0x15a74d5, 0x8, 0x0, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/copycheck/copycheck.go:42 +0x34 fp=0xc42003ef58 sp=0xc42003ee80
main.(*Reporter).Engine.func4(0x7fff5fbff7f6, 0x17, 0xc4200b6240, 0xc4200f0170)
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:166 +0x4e fp=0xc42003efc0 sp=0xc42003ef58
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc42003efc8 sp=0xc42003efc0
created by main.(*Reporter).Engine
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:170 +0x633

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0xc4200f017c)
/usr/local/go/src/runtime/sema.go:47 +0x34
sync.(*WaitGroup).Wait(0xc4200f0170)
/usr/local/go/src/sync/waitgroup.go:131 +0x7a
main.(*Reporter).Engine(0xc4200b6240, 0x7fff5fbff7f6, 0x17, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:219 +0xb6b
main.main()
/Users/joerg/golang/src/github.com/wgliang/goreporter/main.go:62 +0x1c8

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2197 +0x1

goroutine 34 [semacquire]:
sync.runtime_Semacquire(0xc42001408c)
/usr/local/go/src/runtime/sema.go:47 +0x34
sync.(*WaitGroup).Wait(0xc420014080)
/usr/local/go/src/sync/waitgroup.go:131 +0x7a
main.(*Reporter).Engine.func1(0xc420136270, 0xc4200b6240, 0xc4200f0170)
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:116 +0x349
created by main.(*Reporter).Engine
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:127 +0x226

goroutine 8 [syscall]:
syscall.Syscall6(0xad, 0x1, 0x19bd, 0xc42003d910, 0x24, 0x0, 0x0, 0x1e00000, 0x0, 0xc42000c560)
/usr/local/go/src/syscall/asm_darwin_amd64.s:41 +0x5
os.(*Process).blockUntilWaitable(0xc420136420, 0xc4200e4160, 0xc42000c540, 0x5)
/usr/local/go/src/os/wait_waitid.go:28 +0xa5
os.(*Process).wait(0xc420136420, 0x1010712, 0xc4200e0060, 0xc420018230)
/usr/local/go/src/os/exec_unix.go:22 +0x4d
os.(*Process).Wait(0xc420136420, 0x0, 0x0, 0x16a8ff0)
/usr/local/go/src/os/exec.go:115 +0x2b
os/exec.(*Cmd).Wait(0xc4200e4160, 0x0, 0x0)
/usr/local/go/src/os/exec/exec.go:435 +0x62
os/exec.(*Cmd).Run(0xc4200e4160, 0xc42006e000, 0xc42003db80)
/usr/local/go/src/os/exec/exec.go:280 +0x5c
github.com/wgliang/goreporter/linters/unittest.GoTestWithCoverAndRace(0xc4204119b0, 0x16, 0xc42001a888, 0x16, 0xc42001a7b0, 0x14)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/unittest/unittest.go:73 +0xf0
github.com/wgliang/goreporter/linters/unittest.UnitTest(0xc4204119b0, 0x16, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/unittest/unittest.go:30 +0x10e
main.(*Reporter).Engine.func1.1(0xc420014070, 0xc420014078, 0xc42001a630, 0xc42000c1e0, 0xc42001a690, 0xc42000c260, 0xc420014080, 0xc420411a28, 0x16, 0xc4204119b0, ...)
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:66 +0x4d
created by main.(*Reporter).Engine.func1
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:113 +0x316

goroutine 9 [syscall]:
syscall.Syscall(0x3, 0x3, 0xc420144000, 0x200, 0x1e004b0, 0x19, 0xc420144000)
/usr/local/go/src/syscall/asm_darwin_amd64.s:16 +0x5
syscall.read(0x3, 0xc420144000, 0x200, 0x200, 0xc4200da000, 0x1e004b0, 0x0)
/usr/local/go/src/syscall/zsyscall_darwin_amd64.go:973 +0x55
syscall.Read(0x3, 0xc420144000, 0x200, 0x200, 0x102970f, 0x16a8598, 0xc42043bdc0)
/usr/local/go/src/syscall/syscall_unix.go:162 +0x49
os.(*File).read(0xc4200e0048, 0xc420144000, 0x200, 0x200, 0x10d0eeb, 0x14c1620, 0x200)
/usr/local/go/src/os/file_unix.go:165 +0x6a
os.(*File).Read(0xc4200e0048, 0xc420144000, 0x200, 0x200, 0xc42043bf38, 0x1ec1828, 0xc42043be60)
/usr/local/go/src/os/file.go:101 +0x76
bytes.(*Buffer).ReadFrom(0xc42006e000, 0x18c8200, 0xc4200e0048, 0x1ec1828, 0xc42006e000, 0x1)
/usr/local/go/src/bytes/buffer.go:179 +0x160
io.copyBuffer(0x18c6d00, 0xc42006e000, 0x18c8200, 0xc4200e0048, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/io/io.go:384 +0x2cb
io.Copy(0x18c6d00, 0xc42006e000, 0x18c8200, 0xc4200e0048, 0x0, 0x0, 0x0)
/usr/local/go/src/io/io.go:360 +0x68
os/exec.(*Cmd).writerDescriptor.func1(0xc42001a630, 0xc42000c1e0)
/usr/local/go/src/os/exec/exec.go:254 +0x4d
os/exec.(*Cmd).Start.func1(0xc4200e4160, 0xc42000c540)
/usr/local/go/src/os/exec/exec.go:371 +0x27
created by os/exec.(*Cmd).Start
/usr/local/go/src/os/exec/exec.go:372 +0x4e4

goroutine 35 [semacquire]:
go/scanner.(*Scanner).scanRawString(0xc42033c4a0, 0x100, 0x1f5)
/usr/local/go/src/go/scanner/scanner.go:520 +0xd3
go/scanner.(*Scanner).Scan(0xc42033c4a0, 0xc4203751d0, 0x730d1723, 0x76eb866a4946490c, 0x0)
/usr/local/go/src/go/scanner/scanner.go:654 +0x655
go/parser.(*parser).next0(0xc42033c480)
/usr/local/go/src/go/parser/parser.go:257 +0x5b
go/parser.(*parser).next(0xc42033c480)
/usr/local/go/src/go/parser/parser.go:320 +0x87
go/parser.(*parser).parseIdent(0xc42033c480, 0x20)
/usr/local/go/src/go/parser/parser.go:538 +0x64
go/parser.(*parser).parseTypeName(0xc42033c480, 0x0, 0x0)
/usr/local/go/src/go/parser/parser.go:639 +0x50
go/parser.(*parser).tryIdentOrType(0xc42033c480, 0x11633dc, 0xc42033c480)
/usr/local/go/src/go/parser/parser.go:1022 +0x97
go/parser.(*parser).tryType(0xc42033c480, 0xc420375440, 0x1010712)
/usr/local/go/src/go/parser/parser.go:1051 +0x2b
go/parser.(*parser).parseType(0xc42033c480, 0x0, 0x0)
/usr/local/go/src/go/parser/parser.go:621 +0x50
go/parser.(*parser).parseArrayType(0xc42033c480, 0x0, 0x0)
/usr/local/go/src/go/parser/parser.go:670 +0xd3
go/parser.(*parser).tryIdentOrType(0xc42033c480, 0x10, 0xc420447ff0)
/usr/local/go/src/go/parser/parser.go:1024 +0xfe
go/parser.(*parser).tryVarType(0xc42033c480, 0x0, 0x0, 0x0)
/usr/local/go/src/go/parser/parser.go:796 +0x49
go/parser.(*parser).parseFieldDecl(0xc42033c480, 0xc420375660, 0x0)
/usr/local/go/src/go/parser/parser.go:709 +0x148
go/parser.(*parser).parseStructType(0xc42033c480, 0x0)
/usr/local/go/src/go/parser/parser.go:757 +0x176
go/parser.(*parser).tryIdentOrType(0xc42033c480, 0x0, 0xc4203a9140)
/usr/local/go/src/go/parser/parser.go:1026 +0x258
go/parser.(*parser).tryType(0xc42033c480, 0x30, 0x152aa00)
/usr/local/go/src/go/parser/parser.go:1051 +0x2b
go/parser.(*parser).parseType(0xc42033c480, 0x0, 0x0)
/usr/local/go/src/go/parser/parser.go:621 +0x50
go/parser.(*parser).parseTypeSpec(0xc42033c480, 0x0, 0x54, 0x0, 0x0, 0x0)
/usr/local/go/src/go/parser/parser.go:2331 +0x12e
go/parser.(*parser).(go/parser.parseTypeSpec)-fm(0x0, 0x54, 0x0, 0x0, 0x1)
/usr/local/go/src/go/parser/parser.go:2430 +0x48
go/parser.(*parser).parseGenDecl(0xc42033c480, 0x54, 0xc4203759e0, 0x0)
/usr/local/go/src/go/parser/parser.go:2356 +0x38b
go/parser.(*parser).parseDecl(0xc42033c480, 0x16a8a78, 0x0, 0x0)
/usr/local/go/src/go/parser/parser.go:2442 +0xa4
go/parser.(*parser).parseFile(0xc42033c480, 0x0)
/usr/local/go/src/go/parser/parser.go:2488 +0x3ac
go/parser.ParseFile(0xc4203a2b40, 0xc4200da7b0, 0x2c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/go/parser/interface.go:121 +0x1a5
github.com/wgliang/goreporter/linters/cyclo.analyzeFile(0xc4200da7b0, 0x2c, 0xc4200b4280, 0x7, 0x8, 0xc4200b4280, 0x7, 0x8)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/cyclo/cyclo.go:106 +0x7b
github.com/wgliang/goreporter/linters/cyclo.analyzeDir(0xc4202abe00, 0x1e, 0x1bf7d28, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/cyclo/cyclo.go:116 +0xf1
github.com/wgliang/goreporter/linters/cyclo.analyze(0xc420375dd8, 0x1, 0x1, 0x0, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/cyclo/cyclo.go:91 +0xe7
github.com/wgliang/goreporter/linters/cyclo.Cyclo(0xc4202abe00, 0x1e, 0xc420027f58, 0x0, 0xc4200da6c0, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/cyclo/cyclo.go:67 +0xa9
main.(*Reporter).Engine.func2(0xc4204103f0, 0xc4200b6240, 0xc4200f0170)
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:138 +0xf2
created by main.(*Reporter).Engine
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:147 +0x3c0

goroutine 36 [runnable]:
go/build.(*Context).Import(0xc42034db20, 0x7fff5fbff7f6, 0x16, 0xc42000c0e4, 0x17, 0x1, 0xc4203ba120, 0x0, 0x10)
/usr/local/go/src/go/build/build.go:486 +0x760a
github.com/wgliang/goreporter/linters/staticscan/lint/lintutil.runner.resolveRelative(0x18ca4c0, 0xc4203ba0e0, 0x1bf7d28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, ...)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/staticscan/lint/lintutil/util.go:65 +0x176
github.com/wgliang/goreporter/linters/staticscan/lint/lintutil.ProcessFlagSet(0x18ca4c0, 0xc4203ba0e0, 0xc42033e180, 0x1, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/staticscan/lint/lintutil/util.go:153 +0x4fa
github.com/wgliang/goreporter/linters/simplecode.SimpleCode(0x7fff5fbff7f6, 0x17, 0x0, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/simplecode/simplecode.go:18 +0x179
main.(*Reporter).Engine.func3(0x7fff5fbff7f6, 0x17, 0xc4200b6240, 0xc4200f0170)
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:152 +0x4d
created by main.(*Reporter).Engine
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:160 +0x4b3

goroutine 38 [chan receive]:
golang.org/x/tools/go/loader.(*importer).importAll(0xc420316060, 0x0, 0x0, 0xc42000c0e4, 0x17, 0xc4203221e0, 0x0, 0x1c, 0x23d, 0x16a83ce, ...)
/Users/joerg/golang/src/golang.org/x/tools/go/loader/loader.go:912 +0x453
golang.org/x/tools/go/loader.(*Config).Load(0xc420098d10, 0xc4203221e0, 0xc42004dd60, 0xc4200a0088)
/Users/joerg/golang/src/golang.org/x/tools/go/loader/loader.go:520 +0x3af
github.com/wgliang/goreporter/linters/staticscan/lint/lintutil.ProcessFlagSet(0x18ca580, 0xc420318040, 0xc420316000, 0x1, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/staticscan/lint/lintutil/util.go:182 +0x7a5
github.com/wgliang/goreporter/linters/staticscan.StaticScan(0x7fff5fbff7f6, 0x17, 0x0, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/staticscan/staticscan.go:14 +0x13f
main.(*Reporter).Engine.func5(0x7fff5fbff7f6, 0x17, 0xc4200b6240, 0xc4200f0170)
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:175 +0x4d
created by main.(*Reporter).Engine
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:185 +0x726

goroutine 39 [semacquire]:
os.Lstat(0xc4203b8060, 0x13, 0xc42034ae60, 0x2, 0x2, 0xc4203b8060)
/usr/local/go/src/os/stat_unix.go:45 +0x31
path/filepath.walkLink(0xc4203b8060, 0x13, 0xc42034b048, 0xc4203b8060, 0x13, 0x0, 0x0, 0xc4200bad00)
/usr/local/go/src/path/filepath/symlink.go:40 +0xd5
path/filepath.walkLinks(0xc42000c0e4, 0x13, 0xc42034b048, 0x14, 0xc42000c0e4, 0x0, 0xd)
/usr/local/go/src/path/filepath/symlink.go:77 +0x297
path/filepath.walkLinks(0xc42000c0e4, 0x14, 0xc42034b048, 0x14, 0xc42000c0f8, 0x3, 0x1)
/usr/local/go/src/path/filepath/symlink.go:68 +0x102
path/filepath.walkLinks(0xc42000c0e4, 0x17, 0xc42034b048, 0xd, 0xd, 0x0, 0x0)
/usr/local/go/src/path/filepath/symlink.go:73 +0x1ce
path/filepath.walkSymlinks(0xc42000c0e4, 0x17, 0xc42039e970, 0xd, 0x0, 0x0)
/usr/local/go/src/path/filepath/symlink.go:98 +0x5f
path/filepath.evalSymlinks(0xc42000c0e4, 0x17, 0xc42039e970, 0xd, 0x0, 0x0)
/usr/local/go/src/path/filepath/symlink_unix.go:6 +0x35
path/filepath.EvalSymlinks(0xc42000c0e4, 0x17, 0xc42039e970, 0xd, 0x0, 0x0)
/usr/local/go/src/path/filepath/path.go:227 +0x35
go/build.(*Context).hasSubdir(0x1bdb860, 0x166cbbd, 0xd, 0xc42000c0e4, 0x17, 0x0, 0x10, 0xc42039e920)
/usr/local/go/src/go/build/build.go:147 +0xc9
go/build.(*Context).Import.func3(0x166cbbd, 0xd, 0x1, 0x1)
/usr/local/go/src/go/build/build.go:589 +0xac
go/build.(*Context).Import(0x1bdb860, 0x7fff5fbff7f6, 0x17, 0xc42000c0e4, 0x17, 0x0, 0xb, 0x2, 0x2)
/usr/local/go/src/go/build/build.go:615 +0x7107
github.com/wgliang/goreporter/linters/depend.processPackage(0xc42000c0e4, 0x17, 0x7fff5fbff7f6, 0x17, 0xc4203b8020, 0x2)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/depend/depend.go:157 +0xc2
github.com/wgliang/goreporter/linters/depend.Depend(0x7fff5fbff7f6, 0x17, 0x0, 0x0, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/depend/depend.go:73 +0x268
main.(*Reporter).Engine.func6(0xc4200b6240, 0x7fff5fbff7f6, 0x17, 0x0, 0x0, 0xc4200f0170)
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:190 +0x50
created by main.(*Reporter).Engine
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:193 +0x833

goroutine 40 [semacquire]:
github.com/wgliang/goreporter/linters/deadcode.(*Package).Visit(0xc4203a4d80, 0x1ec1c00, 0xc420015e60, 0x18c7100, 0xc4203a4d80)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/deadcode/deadcode.go:134 +0x3f
go/ast.Walk(0x18c7100, 0xc4203a4d80, 0x1ec1c00, 0xc420015e60)
/usr/local/go/src/go/ast/walk.go:52 +0x66
go/ast.walkStmtList(0x18c7100, 0xc4203a4d80, 0xc420012e00, 0x11, 0x20)
/usr/local/go/src/go/ast/walk.go:32 +0x89
go/ast.Walk(0x18c7100, 0xc4203a4d80, 0x18ca640, 0xc420136f60)
/usr/local/go/src/go/ast/walk.go:224 +0x1f16
go/ast.Walk(0x18c7100, 0xc4203a4d80, 0x18ca8c0, 0xc420136f90)
/usr/local/go/src/go/ast/walk.go:344 +0xf63
go/ast.walkDeclList(0x18c7100, 0xc4203a4d80, 0xc420013000, 0x13, 0x20)
/usr/local/go/src/go/ast/walk.go:38 +0x89
go/ast.Walk(0x18c7100, 0xc4203a4d80, 0x18ca840, 0xc4200b8780)
/usr/local/go/src/go/ast/walk.go:353 +0x2bb1
github.com/wgliang/goreporter/linters/deadcode.doPackage(0xc420016300, 0xc420137650, 0xc420349ec0, 0x16a8960, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/deadcode/deadcode.go:103 +0x457
github.com/wgliang/goreporter/linters/deadcode.doDir(0x7fff5fbff7f6, 0x17, 0x0, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/deadcode/deadcode.go:42 +0x175
github.com/wgliang/goreporter/linters/deadcode.DeadCode(0x7fff5fbff7f6, 0x17, 0x0, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/deadcode/deadcode.go:16 +0x35
main.(*Reporter).Engine.func7(0xc4200b6240, 0x7fff5fbff7f6, 0x17, 0xc4200f0170)
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:198 +0x39
created by main.(*Reporter).Engine
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:201 +0x926

goroutine 41 [semacquire]:
flag.(*FlagSet).Var(0xc42001e0c0, 0x18ca280, 0xc4203ba01b, 0x157428a, 0x5, 0x1698384, 0x19)
/usr/local/go/src/flag/flag.go:798 +0x1a0
flag.(*FlagSet).BoolVar(0xc42001e0c0, 0xc4203ba01b, 0x157428a, 0x5, 0x16a6600, 0x1698384, 0x19)
/usr/local/go/src/flag/flag.go:566 +0x70
flag.(*FlagSet).Bool(0xc42001e0c0, 0x157428a, 0x5, 0x0, 0x1698384, 0x19, 0xc4203ba060)
/usr/local/go/src/flag/flag.go:579 +0x7f
flag.Bool(0x157428a, 0x5, 0x1572400, 0x1698384, 0x19, 0x4b)
/usr/local/go/src/flag/flag.go:586 +0x5e
github.com/wgliang/goreporter/linters/spellcheck.SpellCheck(0x7fff5fbff7f6, 0x17, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/spellcheck/spellcheck.go:103 +0x34b
main.(*Reporter).Engine.func8(0xc4200b6240, 0x7fff5fbff7f6, 0x17, 0x0, 0x0, 0xc4200f0170)
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:206 +0x53
created by main.(*Reporter).Engine
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:209 +0xa33

goroutine 42 [runnable]:
syscall.Syscall(0x3, 0x8, 0xc42032d938, 0x8, 0x0, 0x0, 0x0)
/usr/local/go/src/syscall/asm_darwin_amd64.s:16 +0x5
syscall.readlen(0x8, 0xc42032d938, 0x8, 0x6, 0xc420308300, 0x20)
/usr/local/go/src/syscall/zsyscall_darwin_amd64.go:1393 +0x56
syscall.forkExec(0xc4202d0d20, 0x14, 0xc4202a13b0, 0x5, 0x5, 0xc42032dac8, 0x0, 0x0, 0x0)
/usr/local/go/src/syscall/exec_unix.go:202 +0x3d3
syscall.StartProcess(0xc4202d0d20, 0x14, 0xc4202a13b0, 0x5, 0x5, 0xc42032dac8, 0x2, 0x4, 0x0, 0xc42032da98)
/usr/local/go/src/syscall/exec_unix.go:240 +0x64
os.startProcess(0xc4202d0d20, 0x14, 0xc4202a13b0, 0x5, 0x5, 0xc42032dc70, 0xc420340000, 0x1f, 0x1f)
/usr/local/go/src/os/exec_posix.go:45 +0x1a3
os.StartProcess(0xc4202d0d20, 0x14, 0xc4202a13b0, 0x5, 0x5, 0xc42032dc70, 0x0, 0x0, 0xc42032dc10)
/usr/local/go/src/os/exec.go:94 +0x64
os/exec.(*Cmd).Start(0xc4200ac000, 0xc4202a1301, 0xc4200cc0e0)
/usr/local/go/src/os/exec/exec.go:359 +0x3d2
os/exec.(*Cmd).Run(0xc4200ac000, 0xc4200cc0e0, 0xc42032de28)
/usr/local/go/src/os/exec/exec.go:277 +0x2b
github.com/wgliang/goreporter/linters/unittest.GoListWithImportPackages(0x7fff5fbff7f6, 0x17, 0x0, 0x0, 0x0)
/Users/joerg/golang/src/github.com/wgliang/goreporter/linters/unittest/unittest.go:90 +0x14b
main.(*Reporter).Engine.func9(0xc4202d0c40, 0x7fff5fbff7f6, 0x17, 0xc4200f0170)
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:215 +0x35
created by main.(*Reporter).Engine
/Users/joerg/golang/src/github.com/wgliang/goreporter/engine.go:217 +0xb5a

goroutine 21 [semacquire]:
sync.runtime_Semacquire(0xc4200d890c)
/usr/local/go/src/runtime/sema.go:47 +0x34
sync.(*WaitGroup).Wait(0xc4200d8900)
/usr/local/go/src/sync/waitgroup.go:131 +0x7a
golang.org/x/tools/go/loader.parseFiles(0xc4200dc480, 0xc4203249c0, 0x0, 0xc420322450, 0x2e, 0xc4200d8660, 0x1, 0x1, 0x4, 0xc4200101f8, ...)
/Users/joerg/golang/src/golang.org/x/tools/go/loader/util.go:67 +0x3c9
golang.org/x/tools/go/loader.(*Config).parsePackageFiles(0xc420098d10, 0xc420080a80, 0x67, 0xc420322450, 0x2e, 0xc420098dc0, 0x0, 0x0, 0x0)
/Users/joerg/golang/src/golang.org/x/tools/go/loader/loader.go:753 +0x11f
golang.org/x/tools/go/loader.(*importer).load(0xc420316060, 0xc420080a80, 0x0)
/Users/joerg/golang/src/golang.org/x/tools/go/loader/loader.go:975 +0xa2
golang.org/x/tools/go/loader.(*importer).startLoad.func1(0xc420316060, 0xc420080a80, 0xc420319080)
/Users/joerg/golang/src/golang.org/x/tools/go/loader/loader.go:961 +0x35
created by golang.org/x/tools/go/loader.(*importer).startLoad
/Users/joerg/golang/src/golang.org/x/tools/go/loader/loader.go:963 +0x1e7

goroutine 22 [runnable]:
bytes.makeSlice(0x600, 0x0, 0x0, 0x0)
/usr/local/go/src/bytes/buffer.go:201 +0x77
bytes.(*Buffer).ReadFrom(0xc42013a000, 0x18c8200, 0xc420360090, 0x1ec1828, 0xc42013a000, 0x1)
/usr/local/go/src/bytes/buffer.go:173 +0x2ab
io.copyBuffer(0x18c6d00, 0xc42013a000, 0x18c8200, 0xc420360090, 0x0, 0x0, 0x0, 0x1528840, 0x14e0301, 0xc42013a000)
/usr/local/go/src/io/io.go:384 +0x2cb
io.Copy(0x18c6d00, 0xc42013a000, 0x18c8200, 0xc420360090, 0xc420360090, 0xc420029601, 0x109c5a0)
/usr/local/go/src/io/io.go:360 +0x68
go/parser.readSource(0xc4200dda40, 0x37, 0x1561a40, 0xc420360090, 0x0, 0x0, 0xc420029700, 0x109b1d6, 0xc4200dda40)
/usr/local/go/src/go/parser/interface.go:39 +0x23f
go/parser.ParseFile(0xc4200dc480, 0xc4200dda40, 0x37, 0x1561a40, 0xc420360090, 0x4, 0x0, 0x0, 0x0)
/usr/local/go/src/go/parser/interface.go:90 +0x9d
golang.org/x/tools/go/loader.parseFiles.func2(0xc4200d8900, 0xc4203249c0, 0xc420319100, 0xc4203190e0, 0xc4200dc480, 0xc420360080, 0x4, 0x0, 0xc4200dda40, 0x37)
/Users/joerg/golang/src/golang.org/x/tools/go/loader/util.go:63 +0x1ad
created by golang.org/x/tools/go/loader.parseFiles
/Users/joerg/golang/src/golang.org/x/tools/go/loader/util.go:65 +0x298

Slice bounds out of range when using ./

If I use ./, like this:

goreporter -p ./ -d ./goreporter -r html -t ../../github.com/wgliang/goreporter/templates/template.html
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
main.DirList.func1(0xc4202261f8, 0x7, 0xccff80, 0xc42022b2b0, 0x0, 0x0, 0x0, 0x0)
        /home/nkovacs/progs/go/src/github.com/wgliang/goreporter/utils.go:24 +0x219
path/filepath.walk(0xc4202261f8, 0x7, 0xccff80, 0xc42022b2b0, 0xc420385b00, 0x0, 0x0)
        /usr/local/go/src/path/filepath/path.go:351 +0x81
path/filepath.walk(0x7ffc150c417f, 0x2, 0xccff80, 0xc420380270, 0xc420385b00, 0x0, 0x30)
        /usr/local/go/src/path/filepath/path.go:376 +0x414
path/filepath.Walk(0x7ffc150c417f, 0x2, 0xc420385b00, 0xc4203801a0, 0x0)
        /usr/local/go/src/path/filepath/path.go:398 +0x14c
main.DirList(0x7ffc150c417f, 0x2, 0x97057b, 0x3, 0x0, 0x0, 0xc4200fab70, 0x0, 0x0)
        /home/nkovacs/progs/go/src/github.com/wgliang/goreporter/utils.go:32 +0x16a
main.(*Reporter).Engine(0xc4200b6240, 0x7ffc150c417f, 0x2, 0x0, 0x0)
        /home/nkovacs/progs/go/src/github.com/wgliang/goreporter/engine.go:130 +0x300
main.main()
        /home/nkovacs/progs/go/src/github.com/wgliang/goreporter/main.go:73 +0x2e8

If I cd into the goreporter directory, and use ../, it works.

Running the reporter from another directory

This tool seems very useful and I really wanted to use this. But when trying out this neat tool I ran into a couple of issues.

I had an issue when runningthe reporter from the directory of the project I want to check.
I am using Glide as package manager.

When I executed:
goreporter -p . -r . -t $GOPATH/src/github.com/wgliang/goreporter/templates/template.html

I got:

[Apollo]2017/04/12 16:37:48 The report path is not specified, and the current path is used by default
[Apollo]2017/04/12 16:37:48 There are no packages that are excepted, review all items of the package
[Apollo]2017/04/12 16:37:48 start code quality assessment...
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
main.DirList.func1(0xc4202bb9a0, 0x19, 0x18d4160, 0xc42032fc70, 0x0, 0x0, 0x0, 0x0)
	/Users/anton/development/go/src/github.com/wgliang/goreporter/utils.go:30 +0x216
path/filepath.walk(0xc4202bb9a0, 0x19, 0x18d4160, 0xc42032fc70, 0xc4200f14d0, 0x0, 0x0)
	/usr/local/Cellar/go/1.8/libexec/src/path/filepath/path.go:351 +0x81
path/filepath.walk(0x7fff5fbffa9e, 0x1, 0x18d4160, 0xc420107790, 0xc4200f14d0, 0x0, 0x30)
	/usr/local/Cellar/go/1.8/libexec/src/path/filepath/path.go:376 +0x414
path/filepath.Walk(0x7fff5fbffa9e, 0x1, 0xc4200f14d0, 0xc4201076c0, 0x0)
	/usr/local/Cellar/go/1.8/libexec/src/path/filepath/path.go:398 +0x14c
main.DirList(0x7fff5fbffa9e, 0x1, 0x15a6ea3, 0x8, 0x0, 0x0, 0x1043f85, 0x10, 0x0)
	/Users/anton/development/go/src/github.com/wgliang/goreporter/utils.go:38 +0x1ec
main.(*Reporter).Engine(0xc42015c180, 0x7fff5fbffa9e, 0x1, 0x0, 0x0)
	/Users/anton/development/go/src/github.com/wgliang/goreporter/engine.go:44 +0x10c
main.main()
	/Users/anton/development/go/src/github.com/wgliang/goreporter/main.go:70 +0x378

Another issue I had was when I ran the goreporter from it's project folder (GitHub.com/wgliang/goreporter) and pointed to my project folder like so: goreporter -p ../../../munisense.com/services/result-aggregation-service-go/ -d ../goreporter -t ./templates/template.html it kept saying that I didn't have these dependencies installed (because I used glide) and that I should install them using go get.
Will there be support for vendoring?

Lastly: How can I only check the packages I have built? Not the dependencies? Do I have to list all of the dependencies as exceptions? That seems a bit too much effort.. 😞

Please let me know if I'm doing something wrong here.

EDIT: Using both v1.0.0 and HEAD

Unable to exclude packages (-e exceptPackages flag)

It appears that using the -e flag doesn't currently filter packages.

The only reference to the exceptPackages flag in main.go is here:

https://github.com/360EntSecGroup-Skylar/goreporter/blob/09a24e155e0a58994a8eb2032fa303fd101f353c/main.go#L103-L105

And it appears that setting the option on the Reporter was removed here:

https://github.com/360EntSecGroup-Skylar/goreporter/pull/38/files#diff-7ddfb3e035b42cd70649cc33393fe32cL103

Was this intentionally changed or is this something that can be reverted by passing exceptPackages to NewReporter?

Vendor not excluded from Code Spec processes (go_fmt, go_vet)

I understand that on issue #26 and #27 that vendor was added to the default ignore list however running any of the following commands

goreporter -e vendor -p . -r ../product

goreporter -e "vendor" -p . -r ../product

goreporter -e "vendor" -p .

goreporter -e vendor -p .

and various other iterations I still see the following

Go fmt

...
/Users/rb71121/Projects/src/gitlab.ioneyed.com/product/vendor/github.com/viki-org/dnscache/dnscache.go
warning: file is not gofmted with -s (gofmt)
/Users/rb71121/Projects/src/gitlab.ioneyed.com/product/vendor/github.com/viki-org/dnscache/dnscache_test.go
warning: file is not gofmted with -s (gofmt)
...

Go vet

...
/Users/rb71121/Projects/src/gitlab.ioneyed.com/product/vendor/golang.org/x/text/feature/plural/example_test.go:13
ExampleSelect refers to unknown identifier: Select
/Users/rb71121/Projects/src/gitlab.ioneyed.com/product/vendor/golang.org/x/text/language/examples_test.go:208
ExampleParent refers to unknown identifier: Parent
...

dependency error

Hi I've test github.com/golang to see what would happen, and maybe find dependency error

cd $GOPATH/src

goreporter -p ./github.com/golang -f html
2017/08/11 11:01:03 The template path is not specified,and will use the default template
2017/08/11 11:01:03 The report path is not specified, and the current path is used by default
2017/08/11 11:01:03 There are no packages that are excepted, review all items of the package
2017/08/11 11:01:04 Linter:DeadCode over,time consuming 0.481549428s
2017/08/11 11:01:04 Linter:ImportPackages over,time consuming 0.551166767s
E0811 11:01:05.446199   23440 depend.go:81] failed to import ./github.com/golang: cannot find package "vendor/./github.com/golang" in any of:
    /usr/local/Cellar/go/1.8.3/libexec/src/vendor/github.com/golang (from $GOROOT)
    /Users/nickelchen/work/workspaces/go/src/vendor/github.com/golang (from $GOPATH)
2017/08/11 11:01:05 Linter:DependGraph over,time consuming 1.801601824s
...
...

Then tested several projects and they all report

cannot find package "vendor/./github.com/..."

Invalid javascript in generated html

The generated HTML document (with default template) is generated with an invalid javascript.

Uncaught SyntaxError: Unexpected token N in JSON at position 41
    at JSON.parse (<anonymous>)
    at Object.1../subpage/codeCount.js (dialog-platform-2017-11-09-17-55-01.html:879)
    at s (dialog-platform-2017-11-09-17-55-01.html:877)
    at e (dialog-platform-2017-11-09-17-55-01.html:877)
    at dialog-platform-2017-11-09-17-55-01.html:877

E0719 17:34:33.309647 97171 depend.go:81] failed to import

E0719 17:34:33.309647 97171 depend.go:81] failed to import github.com/yashpal1995/mycode:
cannot find package "vendor/github.com/yashpal1995/mycode/" in any of:
$GOROOT
$GOPATH

$GOPATH/bin/goreporter -p github.com/yashpal1995/mycode -r ~/goreporter

why it's searching in vendor directory of $GOPATH?

Some requirements

  1. not just support vendor dir, should support absolutely dir
  2. set the report default save dir
  3. provide extensive documentation
  4. whether support windows platform or not?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.