Golang開源:goreporter-Golang 代碼靜態分析工具

fogu 7年前發布 | 26K 次閱讀 Go語言 Google Go/Golang開發

goreporter

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 normalises their output to a report:

  • Supported linters
  • Supported template
  • Installing
  • Credits
  • Quickstart
  • Example
    • Summary
    • UnitTest
    • SimpleCode
    • DeadCode & CopyCode
  • Credits

Supported linters

  • 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.

Supported template

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

Installing

There are two options for installing goreporter.

    1. Install a stable version, eg. go get -u github.com/wgliang/goreporter/tree/version-1.0.0 . I will generally only tag a new stable version when it has passed the Travis regression tests. The downside is that the binary will be called goreporter.version-1.0.0 .
    1. Install from HEAD with: go get -u github.com/wgliang/goreporter . This has the downside that changes to goreporter may break.

Quickstart

Install goreporter (see above).

Run it:

$ goreporter -p [projtectRelativelyPath] -d [reportPath] -e [exceptPackagesName] -r [json/html]  {-t templatePathIfHtml}

Example

$ goreporter -p ../goreporter -d ../goreporter -t ./templates/template.html

Summary

UnitTest

SimpleCode

DeadCode & CopyCode

Credits

Templates is designed by liufeifei

Logo is desigend by xuri

 

項目主頁:http://www.baiduhome.net/lib/view/home/1491530851262

 

 本文由用戶 fogu 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!