processor

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2018 License: MIT, Unlicense Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	T_STRING int = iota + 1
	T_SLCOMMENT
	T_MLCOMMENT
	T_COMPLEXITY
)
View Source
const (
	S_BLANK              int64 = 1
	S_CODE               int64 = 2
	S_COMMENT            int64 = 3
	S_COMMENT_CODE       int64 = 4 // Indicates comment after code
	S_MULTICOMMENT       int64 = 5
	S_MULTICOMMENT_CODE  int64 = 6 // Indicates multi comment after code
	S_MULTICOMMENT_BLANK int64 = 7 // Indicates multi comment ended with blank afterwards
	S_STRING             int64 = 8
)

Variables

View Source
var AverageWage int64 = 56286
View Source
var Cocomo = false
View Source
var Complexity = false
View Source
var Debug = false
View Source
var DirFilePaths = []string{}

Not set via flags but by arguments following the the flags

View Source
var DisableCheckBinary = false
View Source
var Duplicates = false
View Source
var Exclude = ""
View Source
var ExtensionToLanguage = map[string]string{}

Loaded from the JSON that is in constants.go

View Source
var FileListQueueSize = runtime.NumCPU()
View Source
var FileOutput = ""
View Source
var FileProcessJobQueueSize = runtime.NumCPU()
View Source
var FileProcessJobWorkers = runtime.NumCPU() * 4
View Source
var FileReadContentJobQueueSize = runtime.NumCPU()
View Source
var FileReadJobQueueSize = runtime.NumCPU()
View Source
var FileReadJobWorkers = runtime.NumCPU() * 4
View Source
var FileSummaryJobQueueSize = runtime.NumCPU()
View Source
var Files = false

Flags set via the CLI which control how the output is displayed

View Source
var Format = ""
View Source
var GcFileCount = 10000
View Source
var LanguageFeatures = map[string]LanguageFeature{}
View Source
var Languages = false
View Source
var More = false
View Source
var PathBlacklist = ""
View Source
var SortBy = ""
View Source
var Trace = false
View Source
var Verbose = false
View Source
var WhiteListExtensions = ""

Functions

func ConfigureGc

func ConfigureGc()

This needs to be set outside of ProcessConstants because it should only be enabled in command line mode https://github.com/boyter/scc/issues/32

func CountStats

func CountStats(fileJob *FileJob)

CountStats will process the fileJob If the file contains anything even just a newline its line count should be >= 1. If the file has a size of 0 its line count should be 0. Newlines belong to the line they started on so a file of \n means only 1 line This is the 'hot' path for the application and needs to be as fast as possible

func EstimateCost

func EstimateCost(effortApplied float64, averageWage int64) float64

Calculate the cost in dollars applied using generic COCOMO2 weighted values based on the average yearly wage

func EstimateEffort

func EstimateEffort(sloc int64) float64

Calculate the effort applied using generic COCOMO2 weighted values

func EstimateScheduleMonths

func EstimateScheduleMonths(effortApplied float64) float64

func Process

func Process()

func ProcessConstants

func ProcessConstants()

ProcessConstants is responsible for setting up the language features based on the JSON file that is stored in constants Needs to be called at least once in order for anything to actually happen

Types

type CheckDuplicates

type CheckDuplicates struct {
	// contains filtered or unexported fields
}

func (*CheckDuplicates) Add

func (c *CheckDuplicates) Add(key int64, hash []byte)

func (*CheckDuplicates) Check

func (c *CheckDuplicates) Check(key int64, hash []byte) bool

type FileJob

type FileJob struct {
	Language           string
	Filename           string
	Extension          string
	Location           string
	Content            []byte
	Bytes              int64
	Lines              int64
	Code               int64
	Comment            int64
	Blank              int64
	Complexity         int64
	WeightedComplexity float64
	Hash               []byte
	Callback           FileJobCallback
	Binary             bool
}

type FileJobCallback

type FileJobCallback interface {
	// ProcessLine should return true to continue processing or false to stop further processing and return
	ProcessLine(job *FileJob, currentLine int64, lineType LineType) bool
}

FileJobCallback is an interface that FileJobs can implement to get a per line callback with the line type

type Language

type Language struct {
	LineComment      []string   `json:"line_comment"`
	ComplexityChecks []string   `json:"complexitychecks"`
	Extensions       []string   `json:"extensions"`
	ExtensionFile    bool       `json:"extensionFile"`
	MultiLine        [][]string `json:"multi_line"`
	Quotes           [][]string `json:"quotes"`
	NestedMultiLine  bool       `json:"nestedmultiline"`
}

type LanguageFeature

type LanguageFeature struct {
	Complexity            *Trie
	MultiLineComments     *Trie
	SingleLineComments    *Trie
	Strings               *Trie
	Tokens                *Trie
	Nested                bool
	ComplexityCheckMask   byte
	SingleLineCommentMask byte
	MultiLineCommentMask  byte
	StringCheckMask       byte
	ProcessMask           byte
}

type LanguageSummary

type LanguageSummary struct {
	Name               string
	Bytes              int64
	Lines              int64
	Code               int64
	Comment            int64
	Blank              int64
	Complexity         int64
	Count              int64
	WeightedComplexity float64
	Files              []*FileJob
}

type LineType

type LineType int32
const (
	LINE_BLANK LineType = iota
	LINE_CODE
	LINE_COMMENT
)

type OpenClose

type OpenClose struct {
	Open  []byte
	Close []byte
}

type Trie

type Trie struct {
	Type  int
	Close []byte
	Table [256]*Trie
}

func (*Trie) Insert

func (root *Trie) Insert(tokenType int, token []byte)

func (*Trie) InsertClose

func (root *Trie) InsertClose(tokenType int, openToken, closeToken []byte)

func (*Trie) Match

func (root *Trie) Match(token []byte) (int, int, []byte)

Jump to

Keyboard shortcuts

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