github.com/joey-fossa/fossa-cli@v0.7.34-0.20190708193710-569f1e8679f0/analyzers/haskell/analyzer.go (about) 1 package haskell 2 3 import ( 4 "github.com/mitchellh/mapstructure" 5 6 "github.com/fossas/fossa-cli/buildtools/cabal" 7 "github.com/fossas/fossa-cli/buildtools/stack" 8 "github.com/fossas/fossa-cli/errors" 9 "github.com/fossas/fossa-cli/graph" 10 "github.com/fossas/fossa-cli/module" 11 ) 12 13 type Analyzer struct { 14 Module module.Module 15 AnalyzeFn func(module.Module) (graph.Deps, error) 16 } 17 18 func New(m module.Module) (*Analyzer, error) { 19 var options Options 20 err := mapstructure.Decode(m.Options, &options) 21 22 if err != nil { 23 return nil, err 24 } 25 26 if options.Strategy == CabalInstall { 27 return &Analyzer{ 28 Module: m, 29 AnalyzeFn: cabal.GetDeps, 30 }, nil 31 } else if options.Strategy == Stack { 32 return &Analyzer{ 33 Module: m, 34 AnalyzeFn: stack.GetDeps, 35 }, nil 36 } 37 38 return nil, errors.New("Unknown haskell analysis strategy") 39 } 40 41 func (a *Analyzer) Analyze() (graph.Deps, error) { 42 return a.AnalyzeFn(a.Module) 43 } 44 45 func (Analyzer) Clean() error { 46 return nil 47 } 48 49 func (Analyzer) Build() error { 50 return nil 51 } 52 53 func (Analyzer) IsBuilt() (bool, error) { 54 return true, nil 55 }