From a3254f9edd8959d098311f911764f1713c062bd3 Mon Sep 17 00:00:00 2001 From: DmitriyLewen Date: Sat, 27 Apr 2024 12:53:21 +0600 Subject: [PATCH] refactor(fanal): use const for `environment.yaml` --- pkg/fanal/analyzer/language/conda/environment/environment.go | 2 +- .../analyzer/language/conda/environment/environment_test.go | 3 +-- pkg/fanal/types/const.go | 3 +++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/fanal/analyzer/language/conda/environment/environment.go b/pkg/fanal/analyzer/language/conda/environment/environment.go index fbf8d8fc3451..ee4dfbd7de88 100644 --- a/pkg/fanal/analyzer/language/conda/environment/environment.go +++ b/pkg/fanal/analyzer/language/conda/environment/environment.go @@ -29,7 +29,7 @@ func (a environmentAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisI return res, nil } func (a environmentAnalyzer) Required(filePath string, _ os.FileInfo) bool { - return filepath.Base(filePath) == "environment.yaml" || filepath.Base(filePath) == "environment.yml" + return filepath.Base(filePath) == types.CondaEnvYml || filepath.Base(filePath) == types.CondaEnvYaml } func (a environmentAnalyzer) Type() analyzer.Type { diff --git a/pkg/fanal/analyzer/language/conda/environment/environment_test.go b/pkg/fanal/analyzer/language/conda/environment/environment_test.go index b9a8098b2879..2a35aea316bb 100644 --- a/pkg/fanal/analyzer/language/conda/environment/environment_test.go +++ b/pkg/fanal/analyzer/language/conda/environment/environment_test.go @@ -36,8 +36,7 @@ func Test_environmentAnalyzer_Analyze(t *testing.T) { }, }, { - Name: "_openmp_mutex", - Version: "5.1", + Name: "_openmp_mutex", Locations: []types.Location{ { StartLine: 6, diff --git a/pkg/fanal/types/const.go b/pkg/fanal/types/const.go index 52769674539b..56f56036a590 100644 --- a/pkg/fanal/types/const.go +++ b/pkg/fanal/types/const.go @@ -140,4 +140,7 @@ const ( PubSpecLock = "pubspec.lock" MixLock = "mix.lock" + + CondaEnvYaml = "environment.yaml" + CondaEnvYml = "environment.yml" )