Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove applicabilityScannable attribute for technology #1154

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 11 additions & 34 deletions utils/coreutils/techutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"},
Expand All @@ -84,22 +80,19 @@ 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: "@",
packageInstallationCommand: "update",
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"},
Expand All @@ -108,27 +101,24 @@ 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,
indicators: []string{"Pipfile", "Pipfile.lock"},
packageDescriptors: []string{"Pipfile"},
packageVersionOperator: "==",
packageInstallationCommand: "install",
applicabilityScannable: true,
},
Poetry: {
packageType: Pypi,
indicators: []string{"pyproject.toml", "poetry.lock"},
packageDescriptors: []string{"pyproject.toml"},
packageInstallationCommand: "add",
packageVersionOperator: "==",
applicabilityScannable: true,
},
Nuget: {
indicators: []string{".sln", ".csproj"},
Expand Down Expand Up @@ -188,10 +178,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 {
Expand Down Expand Up @@ -478,12 +464,3 @@ func GetAllTechnologiesList() (technologies []Technology) {
}
return
}

func ContainsApplicabilityScannableTech(technologies []Technology) bool {
for _, technology := range technologies {
if technology.ApplicabilityScannable() {
return true
}
}
return false
}
17 changes: 0 additions & 17 deletions utils/coreutils/techutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
}
}
Loading