goreporter

一个 Golang 工具,做静态分析、单元测试、代码审查和生成代码质量报告。「 A Golang tool that does static analysis, unit testing, code review and generate code quality report. 」

Github stars Tracking Chart

goreporter

Golang 工具,用于执行静态分析,单元测试,代码审查和生成代码质量报告。 这是一个工具,它可以并发地运行一大堆这样的 linters,并将它们的输出规范化为一个报告。

支持的 linters

  • gofmt -- 检查代码是否正确格式化,并且无法进一步简化。
  • govet -- 报告可能无意中隐藏的变量。
  • golint -- Golint 是 Go 源代码的 linter
  • unittest -- Golang 单元测试状态。
  • deadcode -- 发现未使用的代码。
  • gocyclo -- 计算函数的圈复杂度。
  • varcheck -- 查找未使用的全局变量和常量。
  • structcheck -- 查找未使用的结构字段。
  • aligncheck -- 警告非最佳对齐结构。
  • errcheck -- 检查是否使用了错误返回值。
  • copycode(dupl) - Reports potentially duplicated code.
  • gosimple -- 报告代码的简化。
  • staticcheck -- 静态地检测 bug,包括明显的和细微的 bug。
  • godepgraph -- Godepgraph 是一个生成 Go 包依赖关系图的程序。
  • misspell -- 纠正英语中常见的拼写错误…很快。
  • countcode -- 计算项目行数和文件数。
  • interfacer -- 建议使用更窄的接口。
  • depth -- 计算 go 函数的 maxdepth。
  • flen -- Flen 在 Golang 包中提供了 functions methods 长度的统计信息。

模板

可以通过 -t 加载 html 模板文件。

待办事项清单

  • 此版本将重新设计模板。
  • 添加 interfacer 和 safesql 和 gofmt(-s),govet linter。

安装

要求

快速开始

安装 goreporter(见上文)。

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

运行:

注意

您必须确认您的项目是否正常运行。 特别是 vendor 的问题,当在默认路径中找不到包时,goreporter 将再次从可能的 vendor 路径中查找。

goreporter -p [projectRelativePath] -r [reportPath] -e [exceptPackagesName] -f [json/html/text]  {-t templatePathIfHtml}
  • -version GoReporter 的版本。
  • -p 必须是一个有效的 Golang 项目路径。
  • -r 保存到报表的路径。
  • -e 异常包(多个包之间用逗号分隔,例如:"linters/aligncheck,linters/cyclo")。
  • -f 报告格式 json、html 或 text。
  • -t 模板路径,如果没有指定,将使用默认模板。

默认情况下,默认模板用于生成 html 格式的报告。

你可以看到结果细节:在线示例报告

致谢

徽标由 Ri Xu 设计。

(First edition: vz edited at 2019.08.23)

Main metrics

Overview
Name With Ownerqax-os/goreporter
Primary LanguageGo
Program languageGo (Language Count: 7)
PlatformLinux, Mac, Windows
License:Apache License 2.0
所有者活动
Created At2017-03-27 08:46:38
Pushed At2018-10-27 22:30:57
Last Commit At2018-09-02 19:56:03
Release Count18
Last Release Nameversion3.0.2 (Posted on )
First Release Nameversion-1.0.0 (Posted on )
用户参与
Stargazers Count3.1k
Watchers Count100
Fork Count268
Commits Count230
Has Issues Enabled
Issues Count66
Issue Open Count29
Pull Requests Count17
Pull Requests Open Count1
Pull Requests Close Count4
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

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