entity

package
v0.0.0-...-fff90db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

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 Expansion

type Expansion struct {
	Order              int
	From               string
	Values             []string
	SplittingAlgorithm string
}

Expansion represents a set of expansions from a split.

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

type ExtractorFactory func(filename string) Extractor

ExtractorFactory defines the contract for the factory functions capable of building Extractors.

type File

type File struct {
	Name    string
	Raw     []byte
	AST     *ast.File
	FileSet *token.FileSet
	Error   error
}

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 NewIDBuilder

func NewIDBuilder() *IDBuilder

NewIDBuilder creates a new ID builder.

func (*IDBuilder) Build

func (b *IDBuilder) Build() string

Build creates the string ID from the provided input.

func (*IDBuilder) WithFilename

func (b *IDBuilder) WithFilename(filename string) *IDBuilder

WithFilename specifies the filename where the identifier is located.

func (*IDBuilder) WithName

func (b *IDBuilder) WithName(name string) *IDBuilder

WithName specifies the identifier's name.

func (*IDBuilder) WithPackage

func (b *IDBuilder) WithPackage(pkg string) *IDBuilder

WithPackage specifies the package the identifier belongs to.

func (*IDBuilder) WithReceiver

func (b *IDBuilder) WithReceiver(recv string) *IDBuilder

WithReceiver specifies the name of the interfac/struct the identifier is related to.

func (*IDBuilder) WithType

func (b *IDBuilder) WithType(declType token.Token) *IDBuilder

WithType specifies the token type for the identifier.

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

func (i Insight) AvgExpansions(algorithm string) float64

AvgExpansions returns the average number of expansions for a particular algorithm.

func (Insight) AvgSplits

func (i Insight) AvgSplits(algorithm string) float64

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.

func (Insight) Rate

func (i Insight) Rate() float64

Rate returns the correctness rate for the 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

type MinerFactory interface {
	// Make returns a mining algorithm instance.
	Make() (Miner, error)
}

MinerFactory is an interface for creating mining algorithm instances.

type Normalization

type Normalization struct {
	Word      string
	Algorithm string
	Score     float64
}

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

type SourceCode struct {
	Hash     string
	Location string
	Files    []string
}

SourceCode specifies the hash used for extracting the source code copy, its location and the associated list of included files.

type Split

type Split struct {
	Order int
	Value string
}

Split represents a hardword or softword in which the identifier was divided.

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.

type SplitterFactory

type SplitterFactory interface {
	// Make returns a splitting algorithm instance built from miners.
	Make(miners map[string]Miner) (Splitter, error)
}

SplitterFactory is an interface for creating splitting algorithm instances.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL