From 242e12416341214733257d94b3678c776bd1432c Mon Sep 17 00:00:00 2001 From: attiasas Date: Tue, 12 Mar 2024 14:41:44 +0200 Subject: [PATCH] Remove applicabilityScannable attribute for technology --- utils/coreutils/techutils.go | 45 ++++++++----------------------- utils/coreutils/techutils_test.go | 17 ------------ 2 files changed, 11 insertions(+), 51 deletions(-) diff --git a/utils/coreutils/techutils.go b/utils/coreutils/techutils.go index ca63dc653..0d51b209d 100644 --- a/utils/coreutils/techutils.go +++ b/utils/coreutils/techutils.go @@ -48,8 +48,6 @@ type TechData struct { exclude []string // Whether this technology is supported by the 'jf ci-setup' command. ciSetupSupport bool - // Whether Contextual Analysis supported in this technology. - applicabilityScannable bool // The files that handle the project's dependencies. packageDescriptors []string // Formal name of the technology @@ -64,17 +62,15 @@ type TechData struct { var technologiesData = map[Technology]TechData{ Maven: { - indicators: []string{"pom.xml"}, - ciSetupSupport: true, - packageDescriptors: []string{"pom.xml"}, - execCommand: "mvn", - applicabilityScannable: true, + indicators: []string{"pom.xml"}, + ciSetupSupport: true, + packageDescriptors: []string{"pom.xml"}, + execCommand: "mvn", }, Gradle: { - indicators: []string{"build.gradle", "build.gradle.kts"}, - ciSetupSupport: true, - packageDescriptors: []string{"build.gradle", "build.gradle.kts"}, - applicabilityScannable: true, + indicators: []string{"build.gradle", "build.gradle.kts"}, + ciSetupSupport: true, + packageDescriptors: []string{"build.gradle", "build.gradle.kts"}, }, Npm: { indicators: []string{"package.json", "package-lock.json", "npm-shrinkwrap.json"}, @@ -84,21 +80,18 @@ var technologiesData = map[Technology]TechData{ formal: string(Npm), packageVersionOperator: "@", packageInstallationCommand: "install", - applicabilityScannable: true, }, Pnpm: { indicators: []string{"pnpm-lock.yaml"}, exclude: []string{".yarnrc.yml", "yarn.lock", ".yarn"}, packageDescriptors: []string{"package.json"}, packageVersionOperator: "@", - applicabilityScannable: true, }, Yarn: { indicators: []string{".yarnrc.yml", "yarn.lock", ".yarn", ".yarnrc"}, exclude: []string{"pnpm-lock.yaml"}, packageDescriptors: []string{"package.json"}, packageVersionOperator: "@", - applicabilityScannable: true, }, Go: { indicators: []string{"go.mod"}, @@ -107,11 +100,10 @@ var technologiesData = map[Technology]TechData{ packageInstallationCommand: "get", }, Pip: { - packageType: Pypi, - indicators: []string{"setup.py", "requirements.txt"}, - packageDescriptors: []string{"setup.py", "requirements.txt"}, - exclude: []string{"Pipfile", "Pipfile.lock", "pyproject.toml", "poetry.lock"}, - applicabilityScannable: true, + packageType: Pypi, + indicators: []string{"setup.py", "requirements.txt"}, + packageDescriptors: []string{"setup.py", "requirements.txt"}, + exclude: []string{"Pipfile", "Pipfile.lock", "pyproject.toml", "poetry.lock"}, }, Pipenv: { packageType: Pypi, @@ -119,7 +111,6 @@ var technologiesData = map[Technology]TechData{ packageDescriptors: []string{"Pipfile"}, packageVersionOperator: "==", packageInstallationCommand: "install", - applicabilityScannable: true, }, Poetry: { packageType: Pypi, @@ -127,7 +118,6 @@ var technologiesData = map[Technology]TechData{ packageDescriptors: []string{"pyproject.toml"}, packageInstallationCommand: "add", packageVersionOperator: "==", - applicabilityScannable: true, }, Nuget: { indicators: []string{".sln", ".csproj"}, @@ -187,10 +177,6 @@ func (tech Technology) GetPackageInstallationCommand() string { return technologiesData[tech].packageInstallationCommand } -func (tech Technology) ApplicabilityScannable() bool { - return technologiesData[tech].applicabilityScannable -} - func DetectedTechnologiesList() (technologies []string) { wd, err := os.Getwd() if errorutils.CheckError(err) != nil { @@ -477,12 +463,3 @@ func GetAllTechnologiesList() (technologies []Technology) { } return } - -func ContainsApplicabilityScannableTech(technologies []Technology) bool { - for _, technology := range technologies { - if technology.ApplicabilityScannable() { - return true - } - } - return false -} diff --git a/utils/coreutils/techutils_test.go b/utils/coreutils/techutils_test.go index c69d58ebe..c8b2e5c5e 100644 --- a/utils/coreutils/techutils_test.go +++ b/utils/coreutils/techutils_test.go @@ -490,20 +490,3 @@ func TestGetTechInformationFromWorkingDir(t *testing.T) { }) } } - -func TestContainsApplicabilityScannableTech(t *testing.T) { - tests := []struct { - name string - technologies []Technology - want bool - }{ - {name: "contains supported and unsupported techs", technologies: []Technology{Nuget, Go, Npm}, want: true}, - {name: "contains supported techs only", technologies: []Technology{Maven, Yarn, Npm}, want: true}, - {name: "contains unsupported techs only", technologies: []Technology{Dotnet, Nuget, Go}, want: false}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - assert.Equal(t, tt.want, ContainsApplicabilityScannableTech(tt.technologies)) - }) - } -}