file

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComponentDeclaration = "modularity:component:declarations"
	ComponentImport      = "modularity:component:imports"
	AbstractType         = "modularity:types:abstract"
	Type                 = "modularity:types:total"
	FileCount            = "complexity:files"
)

Variables

This section is empty.

Functions

func AddLineNumberAndCharInLineToPositions

func AddLineNumberAndCharInLineToPositions(theFile []byte, positions []*Position)

func AddLineNumberAndCharInLineToSnippets

func AddLineNumberAndCharInLineToSnippets(theFile []byte, snippets []*Snippet)

func ByComponent

func ByComponent(snippet *Snippet) string

func ByDirectory

func ByDirectory(snippet *Snippet) string

func ByFile

func ByFile(snippet *Snippet) string

func ByType

func ByType(s *Snippet) string

func MultiGroupSnippetsBy

func MultiGroupSnippetsBy(snippets []*Snippet, groupBys map[string]GroupSnippetByFunc) map[string]SnippetGroup

Types

type File

type File interface {
	fs.FileInfo
	Path() string
	Content() []byte
}

type GroupSnippetByFunc

type GroupSnippetByFunc func(*Snippet) string

type Position

type Position struct {
	// The offset in the file
	Offset int
	// The line number in the file. This value is not always available, and is calculated from the offset.
	Line int
	// The character position in the line. This value is not always available, and is calculated from the offset.
	CharInLine int
}

Position in a file. Only the offset is required.

func (*Position) String

func (p *Position) String() string

type Results

type Results struct {
	// TODO can I avoid exposing this field?
	Name     string
	Stats    []*StatRecord
	Snippets []*Snippet
}

type Snippet

type Snippet struct {
	File      string    `json:"file"`
	Directory string    `json:"directory"`
	Component string    `json:"component"`
	Type      string    `json:"type"`
	Begin     *Position `json:"begin"`
	End       *Position `json:"end"`
	Value     string    `json:"Value"`
}

A Snippet is a piece of text that is extracted from a file. Snippets are used to generate Stats for a code base. Snippets can have several types, for example "function" or "class".

type SnippetGroup

type SnippetGroup map[string][]*Snippet

type StatRecord

type StatRecord struct {
	StatType string
	Value    interface{}
}

func SnippetsToStats

func SnippetsToStats(snippets []*Snippet) []*StatRecord

type Stats

type Stats map[string]interface{}

Stats are a map of stat type to value For example: {"function": 10, "class": 5} These stats are usually the number of Snippet of a certain type Stats can also be generated by a StatProvider

type StatsGroup

type StatsGroup map[string]*Stats

StatsGroup is a mapping of a name to a Stats

func (StatsGroup) SetStat

func (s StatsGroup) SetStat(key, stat string, value interface{})

Jump to

Keyboard shortcuts

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