From e56cb6fb5e5e643a8573ed9106b9883015abb1e4 Mon Sep 17 00:00:00 2001 From: Shawn Hurley Date: Thu, 25 Jul 2024 15:42:40 -0400 Subject: [PATCH] :bug: During source only analsis, we should not also set the scope. (#116) Cherry-pick #101 Signed-off-by: Shawn Hurley --- cmd/analyzer.go | 2 +- cmd/scope.go | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cmd/analyzer.go b/cmd/analyzer.go index ba023ca..4c70ada 100644 --- a/cmd/analyzer.go +++ b/cmd/analyzer.go @@ -66,7 +66,7 @@ func (r *Analyzer) options(output string) (options command.Options, err error) { if err != nil { return } - err = r.Scope.AddOptions(&options) + err = r.Scope.AddOptions(&options, r.Mode) if err != nil { return } diff --git a/cmd/scope.go b/cmd/scope.go index 203c37c..bfcb8be 100644 --- a/cmd/scope.go +++ b/cmd/scope.go @@ -16,11 +16,18 @@ type Scope struct { } // AddOptions adds analyzer options. -func (r *Scope) AddOptions(options *command.Options) (err error) { - if !r.WithKnownLibs { - options.Add( - "--dep-label-selector", - "!konveyor.io/dep-source=open-source") +func (r *Scope) AddOptions(options *command.Options, mode Mode) (err error) { + // If withDeps is false, we are only every doing source analysis + // adding a dep label selector is strictly wrong in this situation + if mode.WithDeps { + // We want to filter out open source violations when we are not running + // with known libraries. + if !r.WithKnownLibs { + options.Add( + "--dep-label-selector", + "!konveyor.io/dep-source=open-source") + } + } selector := r.incidentSelector() if selector != "" {