Documentation
¶
Index ¶
- type AnalysisConfig
- type AnalysisResults
- type Expander
- type ExpanderAbstractFactory
- type ExpanderFactory
- type Expansion
- type Extractor
- type ExtractorFactory
- type File
- type IDBuilder
- func (b *IDBuilder) Build() string
- func (b *IDBuilder) WithFilename(filename string) *IDBuilder
- func (b *IDBuilder) WithName(name string) *IDBuilder
- func (b *IDBuilder) WithPackage(pkg string) *IDBuilder
- func (b *IDBuilder) WithReceiver(recv string) *IDBuilder
- func (b *IDBuilder) WithType(declType token.Token) *IDBuilder
- type Identifier
- type Insight
- type Metadata
- type Miner
- type MinerAbstractFactory
- type MinerFactory
- type Normalization
- type Project
- type SourceCode
- type Split
- type Splitter
- type SplitterAbstractFactory
- type SplitterFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalysisConfig ¶
type AnalysisConfig struct {
Miners []string
MinerAlgorithmFactory MinerAbstractFactory
ExtractorFactory ExtractorFactory
SplittingAlgorithmFactory SplitterAbstractFactory
Splitters []string
ExpansionAlgorithmFactory ExpanderAbstractFactory
Expanders []string
}
AnalysisConfig defines the configuration options for an analysis execution.
type AnalysisResults ¶
type AnalysisResults struct {
ID uuid.UUID
DateCreated time.Time
ProjectID uuid.UUID
ProjectName string
PipelineMiners []string
PipelineSplitters []string
PipelineExpanders []string
FilesTotal int
FilesValid int
FilesError int
FilesErrorSamples []string
IdentifiersTotal int
IdentifiersValid int
IdentifiersError int
IdentifiersErrorSamples []string
}
AnalysisResults represents the results for an analysis, indicating its creation date, the configuration provided (URL, miners, splitters, expanders), and information about the processed files and identifiers.
type Expander ¶
type Expander interface {
// Name returns the name of the custom expander.
Name() string
// ApplicableOn defines the name of splits used as input.
ApplicableOn() string
// Expand performs the expansion on the token as a whole.
Expand(ident Identifier) []Expansion
}
Expander interface is used to define a custom expander.
type ExpanderAbstractFactory ¶
type ExpanderAbstractFactory interface {
// Get returns a ExpanderFactory for the selectd expansion algorithm.
Get(algorithm string) (ExpanderFactory, error)
}
ExpanderAbstractFactory is an interface for creating expandion algorithm factories.
type ExpanderFactory ¶
type ExpanderFactory interface {
// Make returns an expansion algorithm instance built from miners.
Make(miningResults map[string]Miner) (Expander, error)
}
ExpanderFactory is an interface for creating expansion algorithm instances.
type Extractor ¶
type Extractor interface {
// Visit applies the extraction logic while traversing the Abstract Syntax Tree.
Visit(node ast.Node) ast.Visitor
// Identifiers returns the extracted identifiers.
Identifiers() []Identifier
}
Extractor is used to define a custom identifier extractor.
type ExtractorFactory ¶
ExtractorFactory defines the contract for the factory functions capable of building Extractors.
type File ¶
File represents a source code file, including its raw form and also its Abstract Syntax Tree representation.
type IDBuilder ¶
type IDBuilder struct {
// contains filtered or unexported fields
}
IDBuilder builds an identifier's ID from based on several properties like: * the file the identifier belongs to; * the package name it's included in; * the name of the identifier; * the receiver, in case the identifier is a method of a struct/interface; * the type (function/struct/variable/constant)
func (*IDBuilder) WithFilename ¶
WithFilename specifies the filename where the identifier is located.
func (*IDBuilder) WithPackage ¶
WithPackage specifies the package the identifier belongs to.
func (*IDBuilder) WithReceiver ¶
WithReceiver specifies the name of the interfac/struct the identifier is related to.
type Identifier ¶
type Identifier struct {
ID string
ProjectRef string
AnalysisID uuid.UUID
Package string
File string
Position token.Pos
Name string
Type token.Token
Node *ast.Node
Splits map[string][]Split
Expansions map[string][]Expansion
Error error
Normalization Normalization
}
Identifier represents an identifier extracted from source code, indicating its origin, type, parent information, and splits/expansions.
func (Identifier) Exported ¶
func (i Identifier) Exported() bool
Exported determines if the identifier is exported on its package.
func (Identifier) FullPackageName ¶
func (i Identifier) FullPackageName() string
FullPackageName returns the package name, including its directory structure.
func (*Identifier) Normalize ¶
func (i *Identifier) Normalize()
Normalize applies a normalization function to select the best split/expansion approach.
type Insight ¶
type Insight struct {
ID string
ProjectRef string
AnalysisID uuid.UUID
Package string
TotalIdentifiers int
TotalExported int
TotalSplits map[string]int
TotalExpansions map[string]int
TotalWeight float64
Files map[string]struct{}
}
Insight represents information extracted and summarized from an Analysis, for a package.
func (Insight) AvgExpansions ¶
AvgExpansions returns the average number of expansions for a particular algorithm.
func (Insight) AvgSplits ¶
AvgSplits returns the average number of splits for a particular algorithm.
func (*Insight) Include ¶
func (i *Insight) Include(ident Identifier)
Include includes an identifier into the analysis for the current package Insight.
type Metadata ¶
type Metadata struct {
RemoteID string
Owner string
Fullname string
Description string
CloneURL string
DefaultBranch string
License string
CreatedAt *time.Time
UpdatedAt *time.Time
IsFork bool
Size int32
Stargazers int32
Watchers int32
Forks int32
}
Metadata holds the remote project information.
type Miner ¶
type Miner interface {
// Name provides the name of the miner.
Name() string
// Visit applies the mining logic while traversing the Abstract Syntax Tree.
Visit(node ast.Node) ast.Visitor
// SetCurrentFile specifies the current file being mined.
SetCurrentFile(filename string)
// Results returns the results after mining.
Results() interface{}
}
Miner interface is used to define a custom miner.
type MinerAbstractFactory ¶
type MinerAbstractFactory interface {
// Get returns a MinerFactory for the selectd mining algorithm.
Get(algorithm string) (MinerFactory, error)
}
MinerAbstractFactory is an interface for creating mining algorithm factories.
type MinerFactory ¶
MinerFactory is an interface for creating mining algorithm instances.
type Normalization ¶
Normalization represents a word composition with its given score.
type Project ¶
type Project struct {
ID uuid.UUID
Status string
Reference string
CreatedAt time.Time
Metadata Metadata
SourceCode SourceCode
}
Project represents a GitHub repository, which contains metadata about it and references to locally stored source code.
type SourceCode ¶
SourceCode specifies the hash used for extracting the source code copy, its location and the associated list of included files.
type Splitter ¶
type Splitter interface {
// Name returns the name of the custom splitter.
Name() string
// Split returns the split identifier.
Split(token string) []Split
}
Splitter interface is used to define a custom splitter.
type SplitterAbstractFactory ¶
type SplitterAbstractFactory interface {
// Get returns a SplitterFactory for the selectd splitting algorithm.
Get(algorithm string) (SplitterFactory, error)
}
SplitterAbstractFactory is an interface for creating splitting algorithm factories.