Documentation ¶
Index ¶
- Constants
- func SaveAsHtml(htmlData HtmlData, projectPath, savePath, timestamp, tpl string)
- type CodeCount
- type CodeOptimization
- type CodeSmell
- type CodeSmellItem
- type CodeStyle
- type CodeTest
- type CopyItem
- type Copycode
- type Cyclo
- type CycloInfo
- type Cycloi
- type Deadcode
- type Depth
- type DepthInfo
- type Error
- type File
- type HtmlData
- type Interfacer
- type Item
- type Metric
- type PackageTest
- type Race
- type Reporter
- type Scan
- type Simple
- type Spell
- type StrategyCopyCheck
- func (s *StrategyCopyCheck) Compute(parameters StrategyParameter) (summaries *Summaries)
- func (s *StrategyCopyCheck) GetDescription() string
- func (s *StrategyCopyCheck) GetName() string
- func (s *StrategyCopyCheck) GetWeight() float64
- func (s *StrategyCopyCheck) Percentage(summaries *Summaries) float64
- type StrategyCountCode
- func (s *StrategyCountCode) Compute(parameters StrategyParameter) (summaries *Summaries)
- func (s *StrategyCountCode) GetDescription() string
- func (s *StrategyCountCode) GetName() string
- func (s *StrategyCountCode) GetWeight() float64
- func (s *StrategyCountCode) Percentage(summaries *Summaries) float64
- type StrategyCyclo
- type StrategyDeadCode
- type StrategyDependGraph
- func (s *StrategyDependGraph) Compute(parameters StrategyParameter) (summaries *Summaries)
- func (s *StrategyDependGraph) GetDescription() string
- func (s *StrategyDependGraph) GetName() string
- func (s *StrategyDependGraph) GetWeight() float64
- func (s *StrategyDependGraph) Percentage(summaries *Summaries) float64
- type StrategyDepth
- type StrategyGoFmt
- type StrategyGoVet
- type StrategyImportPackages
- func (s *StrategyImportPackages) Compute(parameters StrategyParameter) (summaries *Summaries)
- func (s *StrategyImportPackages) GetDescription() string
- func (s *StrategyImportPackages) GetName() string
- func (s *StrategyImportPackages) GetWeight() float64
- func (s *StrategyImportPackages) Percentage(summaries *Summaries) float64
- type StrategyInterfacer
- func (s *StrategyInterfacer) Compute(parameters StrategyParameter) (summaries *Summaries)
- func (s *StrategyInterfacer) GetDescription() string
- func (s *StrategyInterfacer) GetName() string
- func (s *StrategyInterfacer) GetWeight() float64
- func (s *StrategyInterfacer) Percentage(summaries *Summaries) float64
- type StrategyLint
- type StrategyLinter
- type StrategyParameter
- type StrategySimpleCode
- func (s *StrategySimpleCode) Compute(parameters StrategyParameter) (summaries *Summaries)
- func (s *StrategySimpleCode) GetDescription() string
- func (s *StrategySimpleCode) GetName() string
- func (s *StrategySimpleCode) GetWeight() float64
- func (s *StrategySimpleCode) Percentage(summaries *Summaries) float64
- type StrategySpellCheck
- func (s *StrategySpellCheck) Compute(parameters StrategyParameter) (summaries *Summaries)
- func (s *StrategySpellCheck) GetDescription() string
- func (s *StrategySpellCheck) GetName() string
- func (s *StrategySpellCheck) GetWeight() float64
- func (s *StrategySpellCheck) Percentage(summaries *Summaries) float64
- type StrategyUnitTest
- type StyleItem
- type Summaries
- type Summary
- type Synchronizer
- type Test
- type UnitTest
- type WaitGroupWrapper
Constants ¶
const DefaultTpl = `` /* 722592-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func SaveAsHtml ¶
SaveAsHtml is a function that save HtmlData as a html report.And will receive htmlData, projectPath, savePath and tpl parameters.
Types ¶
type CodeCount ¶
type CodeCount struct { Summary struct { LineCount int `json:"line_count"` CommentCount int `json:"comment_count"` FunctionCount int `json:"function_count"` FileCount int `json:"file_count"` } `json:"summary"` Content struct { Pkg []string `json:"pkg"` PkgLineCount []int `json:"pkg_line_count"` PkgCommentCount []int `json:"pkg_comment_count"` PkgFunctionCount []int `json:"pkg_function_count"` File []string `json:"file"` FileLineCount []int `json:"file_line_count"` FileCommentCount []int `json:"file_comment_count"` FileFunctionCount []int `json:"file_function_count"` } `json:"content"` }
CodeCount is a struct that contains Summary and Content. t represents the code statistics of the data, you can understand the project from the perspective of the number of lines.
type CodeOptimization ¶
type CodeOptimization struct { Summary struct { IssuesNum int `json:"issue_num"` FilesNum int `json:"file_num"` Quality string `json:"quality"` } `json:"summary"` Content struct { DeadCode StyleItem `json:"dead_code"` SimpleCode StyleItem `json:"simple_code"` StaticCode StyleItem `json:"static_code"` CopyCode CopyItem `json:"copy_code"` InterfacerCode StyleItem `json:"interfacer_code"` } `json:"content"` }
CodeTest is a struct that contains Summary and Content. It represents the result data of the project unit test.
type CodeSmell ¶
type CodeSmell struct { Summary struct { CycloAvg int `json:"cyclo_avg"` CycloHigh int `json:"cyclo_high"` CycloGrave int `json:"cyclo_grave"` } `json:"summary"` Content struct { Percentage map[string]int `json:"percentage"` Pkg []string `json:"pkg"` Cyclo []int `json:"cyclo"` List []CodeSmellItem `json:"list"` } `json:"content"` }
CodeSmell is a struct that contains Summary and Content. It represents the taste of the code data, you can understand the project from the perspective of complexity.
type CodeSmellItem ¶
CodeSmellItem is a struct that contains path and cyclo.
type CodeStyle ¶
type CodeStyle struct { Summary struct { IssuesNum int `json:"issue_num"` FilesNum int `json:"file_num"` Quality string `json:"quality"` } `json:"summary"` Content struct { GoFmt StyleItem `json:"go_fmt"` GoVet StyleItem `json:"go_vet"` GoLint StyleItem `json:"go_lint"` MissSpell StyleItem `json:"miss_spell"` } `json:"content"` }
CodeTest is a struct that contains Summary and Content. It represents the result data of the project unit test.
type CodeTest ¶
type CodeTest struct { Summary struct { CodeCover float64 `json:"code_cover"` PackageCover float64 `json:"pkg_cover"` TotalTime float64 `json:"total_time"` } `json:"summary"` Content struct { Pkg []string `json:"pkg"` Cover []float64 `json:"cover"` Time []float64 `json:"time"` NoTest []string `json:"no_test"` } `json:"content"` }
CodeTest is a struct that contains Summary and Content. It represents the result data of the project unit test.
type CopyItem ¶
type CopyItem struct { Label string `json:"label"` Score int `json:"score"` Detail [][]string `json:"detail"` // contains filtered or unexported fields }
CodeTest is a struct that contains Summary and Content. It represents the result data of the project unit test.
type Copycode ¶
Copycode is a struct that contains Files and Path. The type of Path MUST []string that contains more than one file path. The Copycode represents some copyed code information.
type Cyclo ¶
Cyclo is a struct that contains Pkg, Size and Info. The type of Info MUST []CycloInfo that represents detail information of all function.
type CycloInfo ¶
CycloInfo is a struct that contains Comp and Info. The type of Comp MUST int that represents the cyclo of one function.The CycloInfo represents one cyclo function information.
type Cycloi ¶
Cycloi is a struct that contains Average and Result. The Average is one package's cyclo coverage. And Result is the detail cyclo of the package's all function.
type Deadcode ¶
Deadcode is a struct that contains Path and Info. The type of Path and Info MUST string. The Deadcode represents one dead code.
type File ¶
File is a struct that contains Color, CycloVal and CycloInfo. And it is just for one file's display. The CycloInfo contains all cyclo detail information.
type HtmlData ¶
type HtmlData struct { Project string Score int IssuesNum int CodeTest string CodeStyle string CodeOptimization string CodeCount string CodeSmell string DepGraph template.HTML Date string LastRefresh time.Time `json:"last_refresh"` HumanizedLastRefresh string `json:"humanized_last_refresh"` }
UnitTest is a struct that contains some features in a report of html.
GoReporter HTML Report Features +----------------------------------------------------------------------+ | Feature | Information | +=======================+==============================================+ | Project | The path address of the item being detected | +-----------------------+----------------------------------------------+ | Score | The score of the tested project | +-----------------------+----------------------------------------------+ | CodeTest | Unit test results | +-----------------------+----------------------------------------------+ | IssuesNum | Issues number of the project | +-----------------------+----------------------------------------------+ | CodeCount | Number of lines of code | +-----------------------+----------------------------------------------+ | CodeStyle | Code style check | +-----------------------+----------------------------------------------+ | CodeOptimization | Code optimization | +-----------------------+----------------------------------------------+ | CodeSmell | Code smell | +-----------------------+----------------------------------------------+ | DepGraph | Depend graph of all packages in the project | +-----------------------+----------------------------------------------+ | Date | Date assessment of the project | +-----------------------+----------------------------------------------+ | LastRefresh | Last refresh time of one project | +-----------------------+----------------------------------------------+ | HumanizedLastRefresh | Humanized last refresh setting | +-----------------------+----------------------------------------------+
And the HtmlData just as data for default html template. If you want to customize your own template file, please follow these data, or you can redefine it yourself.
type Interfacer ¶
Interfacer is a struct that contains Path and Info. The type of Path and Info MUST string. The Interfacer warns about the usage of types that are more specific than necessary.
type Metric ¶
type Metric struct { Name string `json:"name"` Description string `json:"description"` Summaries map[string]Summary `json:"summaries"` Weight float64 `json:"weight"` Percentage float64 `json:"percentage"` Error string `json:"error"` }
Metric as template of report and will save all linters result data.But may have some difference in different linter.
type PackageTest ¶
type PackageTest struct { IsPass bool `json:"is_pass"` Coverage string `json:"coverage"` Time float64 `json:"time"` }
PackageTest is a struct that contains IsPass, Coverage and Time. The type of Time MUST float64.
type Race ¶
Race is a struct that contains Pkg, Len, Leng and Info. The type of Info MUST []string that represents more than one race case. Len is the number of cases.
type Reporter ¶
type Reporter struct { Project string `json:"project"` Score int `json:"score"` Grade int `json:"grade"` Metrics map[string]Metric `json:"metrics"` Issues int `json:"issues"` TimeStamp string `json:"time_stamp"` Linters []StrategyLinter Sync *Synchronizer `inject:"" json:"-"` ProjectPath string `json:"-"` ReportPath string `json:"-"` HtmlTemplate string `json:"-"` ReportFormat string `json:"-"` ExceptPackages string `json:"-"` StartTime time.Time }
Reporter is the top struct of GoReporter.
func NewReporter ¶
func (*Reporter) AddLinters ¶
func (r *Reporter) AddLinters(strategies ...StrategyLinter)
func (*Reporter) GetFinalScore ¶
type Scan ¶
Scan is a struct that contains Path and Info. The type of Path and Info MUST string. The Scan represents one defect case.
type Simple ¶
Simple is a struct that contains Path and Info. The type of Path and Info MUST string. The Simple represents one can be simpled code case.
type Spell ¶
Spell is a struct that contains Path and Info. The type of Path and Info MUST string. The Spell represents one word is misspelled.
type StrategyCopyCheck ¶
type StrategyCopyCheck struct {
Sync *Synchronizer `inject:""`
}
func (*StrategyCopyCheck) Compute ¶
func (s *StrategyCopyCheck) Compute(parameters StrategyParameter) (summaries *Summaries)
linterCopy provides a function that scans all duplicate code in the project and give duplicate code locations and rows.It will extract from the linter need to convert the data.The result will be saved in the r's attributes.
func (*StrategyCopyCheck) GetDescription ¶
func (s *StrategyCopyCheck) GetDescription() string
func (*StrategyCopyCheck) GetName ¶
func (s *StrategyCopyCheck) GetName() string
func (*StrategyCopyCheck) GetWeight ¶
func (s *StrategyCopyCheck) GetWeight() float64
func (*StrategyCopyCheck) Percentage ¶
func (s *StrategyCopyCheck) Percentage(summaries *Summaries) float64
type StrategyCountCode ¶
type StrategyCountCode struct {
Sync *Synchronizer `inject:""`
}
func (*StrategyCountCode) Compute ¶
func (s *StrategyCountCode) Compute(parameters StrategyParameter) (summaries *Summaries)
linterCount is a function that counts go files and go code lines of project.It will extract from the linter need to convert the data. The result will be saved in the r's attributes.
func (*StrategyCountCode) GetDescription ¶
func (s *StrategyCountCode) GetDescription() string
func (*StrategyCountCode) GetName ¶
func (s *StrategyCountCode) GetName() string
func (*StrategyCountCode) GetWeight ¶
func (s *StrategyCountCode) GetWeight() float64
func (*StrategyCountCode) Percentage ¶
func (s *StrategyCountCode) Percentage(summaries *Summaries) float64
type StrategyCyclo ¶
type StrategyCyclo struct { Sync *Synchronizer `inject:""` // contains filtered or unexported fields }
func (*StrategyCyclo) Compute ¶
func (s *StrategyCyclo) Compute(parameters StrategyParameter) (summaries *Summaries)
func (*StrategyCyclo) GetDescription ¶
func (s *StrategyCyclo) GetDescription() string
func (*StrategyCyclo) GetName ¶
func (s *StrategyCyclo) GetName() string
func (*StrategyCyclo) GetWeight ¶
func (s *StrategyCyclo) GetWeight() float64
func (*StrategyCyclo) Percentage ¶
func (s *StrategyCyclo) Percentage(summaries *Summaries) float64
type StrategyDeadCode ¶
type StrategyDeadCode struct {
Sync *Synchronizer `inject:""`
}
func (*StrategyDeadCode) Compute ¶
func (s *StrategyDeadCode) Compute(parameters StrategyParameter) (summaries *Summaries)
linterDead provides a function that will scans all useless code, or never obsolete obsolete code.It will extract from the linter need to convert the data.The result will be saved in the r's attributes.
func (*StrategyDeadCode) GetDescription ¶
func (s *StrategyDeadCode) GetDescription() string
func (*StrategyDeadCode) GetName ¶
func (s *StrategyDeadCode) GetName() string
func (*StrategyDeadCode) GetWeight ¶
func (s *StrategyDeadCode) GetWeight() float64
func (*StrategyDeadCode) Percentage ¶
func (s *StrategyDeadCode) Percentage(summaries *Summaries) float64
type StrategyDependGraph ¶
type StrategyDependGraph struct {
Sync *Synchronizer `inject:""`
}
func (*StrategyDependGraph) Compute ¶
func (s *StrategyDependGraph) Compute(parameters StrategyParameter) (summaries *Summaries)
linterDependGraph is a function that builds the dependency graph of all packages in the project helps you optimize the project architecture.It will extract from the linter need to convert the data.The result will be saved in the r's attributes.
func (*StrategyDependGraph) GetDescription ¶
func (s *StrategyDependGraph) GetDescription() string
func (*StrategyDependGraph) GetName ¶
func (s *StrategyDependGraph) GetName() string
func (*StrategyDependGraph) GetWeight ¶
func (s *StrategyDependGraph) GetWeight() float64
func (*StrategyDependGraph) Percentage ¶
func (s *StrategyDependGraph) Percentage(summaries *Summaries) float64
type StrategyDepth ¶
type StrategyDepth struct { Sync *Synchronizer `inject:""` // contains filtered or unexported fields }
func (*StrategyDepth) Compute ¶
func (s *StrategyDepth) Compute(parameters StrategyParameter) (summaries *Summaries)
Compute all [.go] file's function maximum depth. It is an important indicator that allows developer to see whether a function needs to be splitted into smaller functions for readability purpose
func (*StrategyDepth) GetDescription ¶
func (s *StrategyDepth) GetDescription() string
func (*StrategyDepth) GetName ¶
func (s *StrategyDepth) GetName() string
func (*StrategyDepth) GetWeight ¶
func (s *StrategyDepth) GetWeight() float64
func (*StrategyDepth) Percentage ¶
func (s *StrategyDepth) Percentage(summaries *Summaries) float64
type StrategyGoFmt ¶
type StrategyGoFmt struct {
Sync *Synchronizer `inject:""`
}
func (*StrategyGoFmt) Compute ¶
func (s *StrategyGoFmt) Compute(parameters StrategyParameter) (summaries *Summaries)
func (*StrategyGoFmt) GetDescription ¶
func (s *StrategyGoFmt) GetDescription() string
func (*StrategyGoFmt) GetName ¶
func (s *StrategyGoFmt) GetName() string
func (*StrategyGoFmt) GetWeight ¶
func (s *StrategyGoFmt) GetWeight() float64
func (*StrategyGoFmt) Percentage ¶
func (s *StrategyGoFmt) Percentage(summaries *Summaries) float64
type StrategyGoVet ¶
type StrategyGoVet struct {
Sync *Synchronizer `inject:""`
}
func (*StrategyGoVet) Compute ¶
func (s *StrategyGoVet) Compute(parameters StrategyParameter) (summaries *Summaries)
func (*StrategyGoVet) GetDescription ¶
func (s *StrategyGoVet) GetDescription() string
func (*StrategyGoVet) GetName ¶
func (s *StrategyGoVet) GetName() string
func (*StrategyGoVet) GetWeight ¶
func (s *StrategyGoVet) GetWeight() float64
func (*StrategyGoVet) Percentage ¶
func (s *StrategyGoVet) Percentage(summaries *Summaries) float64
type StrategyImportPackages ¶
type StrategyImportPackages struct {
Sync *Synchronizer `inject:""`
}
func (*StrategyImportPackages) Compute ¶
func (s *StrategyImportPackages) Compute(parameters StrategyParameter) (summaries *Summaries)
linterImportPackages is a function that scan the project contains all the package lists.It will extract from the linter need to convert the data.The result will be saved in the r's attributes.
func (*StrategyImportPackages) GetDescription ¶
func (s *StrategyImportPackages) GetDescription() string
func (*StrategyImportPackages) GetName ¶
func (s *StrategyImportPackages) GetName() string
func (*StrategyImportPackages) GetWeight ¶
func (s *StrategyImportPackages) GetWeight() float64
func (*StrategyImportPackages) Percentage ¶
func (s *StrategyImportPackages) Percentage(summaries *Summaries) float64
type StrategyInterfacer ¶
type StrategyInterfacer struct {
Sync *Synchronizer `inject:""`
}
func (*StrategyInterfacer) Compute ¶
func (s *StrategyInterfacer) Compute(parameters StrategyParameter) (summaries *Summaries)
linterInterfacer is a function that scan the interface of all packages in the project helps you optimize the project architecture.It will extract from the linter need to convert the data.The result will be saved in the r's attributes.
func (*StrategyInterfacer) GetDescription ¶
func (s *StrategyInterfacer) GetDescription() string
func (*StrategyInterfacer) GetName ¶
func (s *StrategyInterfacer) GetName() string
func (*StrategyInterfacer) GetWeight ¶
func (s *StrategyInterfacer) GetWeight() float64
func (*StrategyInterfacer) Percentage ¶
func (s *StrategyInterfacer) Percentage(summaries *Summaries) float64
type StrategyLint ¶
type StrategyLint struct {
Sync *Synchronizer `inject:""`
}
func (*StrategyLint) Compute ¶
func (s *StrategyLint) Compute(parameters StrategyParameter) (summaries *Summaries)
func (*StrategyLint) GetDescription ¶
func (s *StrategyLint) GetDescription() string
func (*StrategyLint) GetName ¶
func (s *StrategyLint) GetName() string
func (*StrategyLint) GetWeight ¶
func (s *StrategyLint) GetWeight() float64
func (*StrategyLint) Percentage ¶
func (s *StrategyLint) Percentage(summaries *Summaries) float64
type StrategyLinter ¶
type StrategyParameter ¶
type StrategySimpleCode ¶
type StrategySimpleCode struct {
Sync *Synchronizer `inject:""`
}
func (*StrategySimpleCode) Compute ¶
func (s *StrategySimpleCode) Compute(parameters StrategyParameter) (summaries *Summaries)
func (*StrategySimpleCode) GetDescription ¶
func (s *StrategySimpleCode) GetDescription() string
func (*StrategySimpleCode) GetName ¶
func (s *StrategySimpleCode) GetName() string
func (*StrategySimpleCode) GetWeight ¶
func (s *StrategySimpleCode) GetWeight() float64
func (*StrategySimpleCode) Percentage ¶
func (s *StrategySimpleCode) Percentage(summaries *Summaries) float64
type StrategySpellCheck ¶
type StrategySpellCheck struct {
Sync *Synchronizer `inject:""`
}
func (*StrategySpellCheck) Compute ¶
func (s *StrategySpellCheck) Compute(parameters StrategyParameter) (summaries *Summaries)
func (*StrategySpellCheck) GetDescription ¶
func (s *StrategySpellCheck) GetDescription() string
func (*StrategySpellCheck) GetName ¶
func (s *StrategySpellCheck) GetName() string
func (*StrategySpellCheck) GetWeight ¶
func (s *StrategySpellCheck) GetWeight() float64
func (*StrategySpellCheck) Percentage ¶
func (s *StrategySpellCheck) Percentage(summaries *Summaries) float64
type StrategyUnitTest ¶
type StrategyUnitTest struct { Sync *Synchronizer `inject:""` // contains filtered or unexported fields }
func (*StrategyUnitTest) Compute ¶
func (s *StrategyUnitTest) Compute(parameters StrategyParameter) (summaries *Summaries)
func (*StrategyUnitTest) GetDescription ¶
func (s *StrategyUnitTest) GetDescription() string
func (*StrategyUnitTest) GetName ¶
func (s *StrategyUnitTest) GetName() string
func (*StrategyUnitTest) GetWeight ¶
func (s *StrategyUnitTest) GetWeight() float64
func (*StrategyUnitTest) Percentage ¶
func (s *StrategyUnitTest) Percentage(summaries *Summaries) float64
type StyleItem ¶
type StyleItem struct { Label string `json:"label"` Score int `json:"score"` Detail []Item `json:"detail"` // contains filtered or unexported fields }
CodeTest is a struct that contains Summary and Content. It represents the result data of the project unit test.
type Summaries ¶
func NewSummaries ¶
func NewSummaries() *Summaries
type Summary ¶
type Summary struct { Name string `json:"name"` Description string `json:"description"` Errors []Error `json:"errors"` SumCover float64 CountCover int Avg float64 }
FileSummary contains the filename, location of the file on GitHub, and all of the errors related to the file
type Synchronizer ¶
type Synchronizer struct { SyncRW *sync.RWMutex `inject:""` WaitGW *WaitGroupWrapper `inject:""` LintersProcessChans chan int64 `json:"-"` LintersFinishedSignal chan string `json:"-"` }
type Test ¶
Test is a struct that contains Path, Result, Time and Cover. The type of Time and Cover MUST float64. And it is just for one package's display.
type UnitTest ¶
type UnitTest struct { AvgCover string `json:"average_cover"` PackagesTestDetail map[string]PackageTest `json:"packages_test_detail"` PackagesRaceDetail map[string][]string `json:"packages_race_detail"` }
UnitTest is a struct that contains AvgCover, PackagesTestDetail and PackagesRaceDetail. The type of AvgCover MUST string that represents the code coverage of the entire project. The type of PackagesTestDetail MUST map[string]PackageTest(contains pass-status,code-coverage and time). and it has all packages' detail information. PackagesRaceDetail contains all packages' race cases.
And the UnitTest contains all packages' result.
type WaitGroupWrapper ¶
WaitGroupWrapper is a struct that as a waiter for all linetr-tasks.And it encapsulates Sync.WaitGroup that can be call as a interface.
func (*WaitGroupWrapper) Wrap ¶
func (w *WaitGroupWrapper) Wrap(cb func())
Wrap implements a interface that run the function cd as a goroutine.And it encapsulates Add(1) and Done() operation.You can just think go cd() but not worry about synchronization and security issues.
Source Files ¶
- config.go
- const.go
- report2html.go
- reporter.go
- strategy.go
- strategy_copycheck.go
- strategy_countcode.go
- strategy_cyclo.go
- strategy_deadcode.go
- strategy_dependgraph.go
- strategy_depth.go
- strategy_gofmt.go
- strategy_golint.go
- strategy_govet.go
- strategy_importpackages.go
- strategy_interfacer.go
- strategy_simplecode.go
- strategy_spellcheck.go
- strategy_unittest.go
- template.html.go