Documentation ¶
Index ¶
- Constants
- func AbsPath(path string) string
- func CountPercentage(issues int) float64
- func DirList(projectPath string, suffix, except string) (dirs map[string]string, err error)
- func ExceptPkg(pkg string) bool
- func GetProcessUnit(sumProcessNumber int64, number int) int64
- func PackageAbsPath(path string) (packagePath string)
- func PackageAbsPathExceptSuffix(path string) (packagePath string)
- func PackageNameFromGoPath(path string) string
- func ProjectName(projectPath string) (project string)
- func SaveAsHtml(htmlData HtmlData, projectPath, savePath, timestamp, tpl string)
- type Copycode
- type Cyclo
- type CycloInfo
- type Cycloi
- type Deadcode
- type Depth
- type DepthInfo
- type Error
- type File
- type HtmlData
- type Interfacer
- 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 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 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 Summaries
- type Summary
- type Synchronizer
- type Test
- type UnitTest
- type WaitGroupWrapper
Constants ¶
const DefaultTpl = `` /* 765028-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func CountPercentage ¶
CountPercentage will count all linters' percentage.And rule is
+--------------------------------------------------+ | issues | score | +==================================================+ | 5 | 100-issues*2 | +--------------------------------------------------+ | [5,10) | 100 - 10 - (issues-5)*4 | +--------------------------------------------------+ | [10,20) | 100 - 10 - 20 - (issues-10)*5 | +--------------------------------------------------+ | [20,40) | 100 - 10 - 20 - 50 - (issues-20)*1 | +--------------------------------------------------+ | [40,*) | 0 | +--------------------------------------------------+
It will return a float64 type score.
func DirList ¶
DirList is a function that traverse the file directory containing the specified file format according to the specified rule.
func GetProcessUnit ¶
GetProcessUnit provides function that will get sumProcessNumber of linter's weight and the number of current linter's case.It will return 1 if sumProcessNumber/int64(number) <= 0 or sumProcessNumber / int64(number). Just for communication.
func PackageAbsPath ¶
PackageAbsPath will gets the absolute path of the specified package from GOPATH's [src].
func PackageAbsPathExceptSuffix ¶
PackageAbsPath will gets the absolute directory path of the specified file from GOPATH's [src].
func PackageNameFromGoPath ¶
PackageNameFromGoPath is a function that will get package's name from GOPATH.
func ProjectName ¶
ProjectName is a function that gets project's name.
func SaveAsHtml ¶
SaveAsHtml is a function that save HtmlData as a html report.And will receive htmlData, projectPath, savePath and tpl parameters.
Types ¶
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 Tests string Date string Issues int FileCount int CodeLines int CommentLines int TotalLines int TestSummaryCoverAvg string AveragePackageCover float64 SimpleIssues int DeadcodeIssues int CycloBigThan15 int DepthBigThan3 int Races []Race NoTests string Simples string Interfacers string Spells string SimpleLevel int Deadcodes string Copycodes string Cyclos string Depths string DepGraph template.HTML 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 | +-----------------------+----------------------------------------------+ | Tests | Unit test results | +-----------------------+----------------------------------------------+ | Date | Date assessment of the project | +-----------------------+----------------------------------------------+ | Issues | Issues number of the project | +-----------------------+----------------------------------------------+ | FileCount | Go file number of the peoject | +-----------------------+----------------------------------------------+ | CodeLines | Number of lines of code | +-----------------------+----------------------------------------------+ | CommentLines | Number of lines of Comment | +-----------------------+----------------------------------------------+ | TestSummaryCoverAvg | Code cover average of all unit test | +-----------------------+----------------------------------------------+ | AveragePackageCover | Package cover average of all packages | +-----------------------+----------------------------------------------+ | SimpleIssues | Simpled issues number | +-----------------------+----------------------------------------------+ | DeadcodeIssues | Dead code issues number | +-----------------------+----------------------------------------------+ | CycloBigThan15 | Cyclo more than 15 number | +-----------------------+----------------------------------------------+ | Races | Race result of all packages | +-----------------------+----------------------------------------------+ | NoTests | No unit test packages information | +-----------------------+----------------------------------------------+ | Simples | Simpled cases of all packages information | +-----------------------+----------------------------------------------+ | Interfacers | Warns about types specific necessary | +-----------------------+----------------------------------------------+ | SimpleLevel | Simple level of path | +-----------------------+----------------------------------------------+ | Deadcodes | Dead code cases information | +-----------------------+----------------------------------------------+ | Copycodes | Copy code cases information | +-----------------------+----------------------------------------------+ | Cyclos | Cyclo of function cases information | +-----------------------+----------------------------------------------+ | DepGraph | Depend graph of all packages in 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 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 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 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_importpackages.go
- strategy_interfacer.go
- strategy_simplecode.go
- strategy_spellcheck.go
- strategy_unittest.go
- template.html.go
- utils.go