module

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: MPL-2.0 Imports: 9 Imported by: 51

Documentation

Overview

Package module defines a FOSSA CLI module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analysis added in v1.0.5

type Analysis struct {
	AnalyzerName string
	Graphs       []TaggedGraph
}

The completed analysis by an analyzer

type AnalyzerV2 added in v1.0.5

type AnalyzerV2 struct {
	Name         string
	DiscoverFunc DiscoverFuncV2
	Strategies   Strategies
}

func (AnalyzerV2) ScanModule added in v1.0.5

func (a AnalyzerV2) ScanModule(startJob func() error, endJob func(), progress display.ProgressTracker, folder Filepath, strategies DiscoveredStrategies) ([]TaggedGraph, *errors.Error)

type AnalyzerV2Output added in v1.0.5

type AnalyzerV2Output map[Filepath][]Analysis

type DiscoverFuncV2 added in v1.0.5

type DiscoverFuncV2 func(dir Filepath) (map[Filepath]DiscoveredStrategies, *errors.Error) // Map from 'module' roots to discovered strategies

A discoverfunc takes a root directory to scan and produces a map of relative filepaths to discovered strategies

NB: we may discover overlapping strategies for the same module For example: if we find package.json and node_modules, we're going to discover two `npm ls` strategies

We arbitrarily choose one file to use as the target of that strategy

type DiscoveredStrategies added in v1.0.5

type DiscoveredStrategies = map[StrategyName]Filepath

The filepath is the relative filepath from the root of the module

type Filepath added in v1.0.5

type Filepath = string

type Hashes added in v0.6.3

type Hashes struct {
	SHA1   string
	SHA256 string
	MD5    string
}

Hashes contains hexadecimal checksums of code libraries brought in by running a Build.

type Module

type Module struct {
	Name         string   `yaml:"name"`             // Uniquely identifies the module.
	Type         pkg.Type `yaml:"type"`             // Type of the root package, used to select the module's analyzer.
	IsExecutable bool     `yaml:"-"`                // Used for filtering discovered projects.
	Ignore       bool     `yaml:"ignore,omitempty"` // Used for marking ignored (blacklisted) modules.

	BuildTarget string `yaml:"target,omitempty"` // Exact build target in the semantics of the module's analyzers.
	Dir         string `yaml:"cwd,omitempty"`    // CWD to analyze the module from.

	Options map[string]interface{} `yaml:"options,omitempty"` // Analyzer option struct of the module type.

	Imports []pkg.Import           `yaml:"-"` // Direct dependencies of the root package.
	Deps    map[pkg.ID]pkg.Package `yaml:"-"` // All transitive dependencies of the root package (including Imports).
}

A Module is a single compilable unit of code (e.g. an entrypoint) to analyze. Modules consist of a root Package, and the transitive dependencies of that package.

func (*Module) IsAnalyzed added in v0.7.0

func (p *Module) IsAnalyzed() bool

IsAnalyzed returns true if a module has already been analyzed, and false otherwise.

type Strategies added in v1.0.5

type Strategies struct {
	// Map of strategy names to functions
	Named map[StrategyName]Strategy
	// The order in which to run strategies -- the first strategy to succeed is elected
	// as the "Best" dependency graph
	SortedNames []StrategyName
	// The set of optimal strategies. This will be used for warnings
	Optimal []StrategyName
}

type Strategy added in v1.0.5

type Strategy func(dir Filepath, target Filepath) (graph.Deps, *errors.Error)

A strategy produces a dependency graph, with two paths relative to the root as arguments:

  • The directory of the module. This is usually the parent directory of the "target"
  • The "target" -- usually the file (or directory) that caused the invocation of this strategy

type StrategyName added in v1.0.5

type StrategyName = string

type TaggedGraph added in v1.0.5

type TaggedGraph struct {
	Strategy StrategyName
	// The file that led to this analysis, most often the file
	// analyzed by the relevant strategy
	File  Filepath
	Graph graph.Deps
}

Jump to

Keyboard shortcuts

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