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

🐛 use the location from the inital call #668

Merged
Merged
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
100 changes: 50 additions & 50 deletions engine/conditions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,224 +15,224 @@ func Test_sortConditionEntries(t *testing.T) {
{
title: "correctly sorted conditions should stay sorted",
entries: []ConditionEntry{
ConditionEntry{
{
As: "a",
},
ConditionEntry{
{
As: "b",
From: "a",
},
},
expected: []ConditionEntry{
ConditionEntry{
{
As: "a",
},
ConditionEntry{
{
As: "b",
From: "a",
},
},
}, {
title: "incorrectly sorted conditions should be sorted",
entries: []ConditionEntry{
ConditionEntry{
{
As: "b",
From: "a",
},
ConditionEntry{
{
As: "a",
},
},
expected: []ConditionEntry{
ConditionEntry{
{
As: "a",
},
ConditionEntry{
{
As: "b",
From: "a",
},
},
}, {
title: "incorrectly sorted conditions that branch should be sorted",
entries: []ConditionEntry{
ConditionEntry{
{
As: "b",
From: "a",
},
ConditionEntry{
{
As: "a",
},
ConditionEntry{
{
As: "c",
From: "b",
},
ConditionEntry{
{
As: "e",
From: "d",
},
ConditionEntry{
{
As: "d",
From: "b",
},
},
expected: []ConditionEntry{
ConditionEntry{
{
As: "a",
},
ConditionEntry{
{
As: "b",
From: "a",
},
ConditionEntry{
{
As: "c",
From: "b",
},
ConditionEntry{
{
As: "d",
From: "b",
},
ConditionEntry{
{
As: "e",
From: "d",
},
},
}, {
title: "longer chains should sort properly",
entries: []ConditionEntry{
ConditionEntry{
{
From: "e",
As: "f",
},
ConditionEntry{
{
As: "a",
},
ConditionEntry{
{
From: "d",
As: "e",
},
ConditionEntry{
{
From: "a",
As: "b",
},
ConditionEntry{
{
From: "b",
As: "c",
},
ConditionEntry{
{
From: "c",
As: "d",
},
ConditionEntry{
{
From: "f",
},
},
expected: []ConditionEntry{
ConditionEntry{
{
As: "a",
},
ConditionEntry{
{
From: "a",
As: "b",
},
ConditionEntry{
{
From: "b",
As: "c",
},
ConditionEntry{
{
From: "c",
As: "d",
},
ConditionEntry{
{
From: "d",
As: "e",
},
ConditionEntry{
{
From: "e",
As: "f",
},
ConditionEntry{
{
From: "f",
},
},
}, {
title: "completely reversed chains should sort properly",
entries: []ConditionEntry{
ConditionEntry{
{
From: "c",
},
ConditionEntry{
{
From: "b",
As: "c",
},
ConditionEntry{
{
From: "a",
As: "b",
},
ConditionEntry{
{
As: "a",
},
},
expected: []ConditionEntry{
ConditionEntry{
{
As: "a",
},
ConditionEntry{
{
From: "a",
As: "b",
},
ConditionEntry{
{
From: "b",
As: "c",
},
ConditionEntry{
{
From: "c",
},
},
}, {
title: "unused As should not cause error",
entries: []ConditionEntry{
ConditionEntry{
{
From: "c",
As: "d",
},
ConditionEntry{
{
From: "b",
As: "c",
},
ConditionEntry{
{
From: "a",
As: "b",
},
ConditionEntry{
{
As: "a",
},
},
expected: []ConditionEntry{
ConditionEntry{
{
As: "a",
},
ConditionEntry{
{
From: "a",
As: "b",
},
ConditionEntry{
{
From: "b",
As: "c",
},
ConditionEntry{
{
From: "c",
As: "d",
},
},
}, {
title: "length 1 lists should not cause error",
entries: []ConditionEntry{
ConditionEntry{
{
As: "a",
},
},
expected: []ConditionEntry{
ConditionEntry{
{
As: "a",
},
},
Expand Down
2 changes: 1 addition & 1 deletion engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ func (r *ruleEngine) createViolation(ctx context.Context, conditionResponse Cond
}, nil
}

func (r *ruleEngine) getCodeLocation(ctx context.Context, m IncidentContext, rule Rule) (codeSnip string, err error) {
func (r *ruleEngine) getCodeLocation(_ context.Context, m IncidentContext, rule Rule) (codeSnip string, err error) {
if m.CodeLocation == nil {
r.logger.V(6).Info("unable to get the code snip", "URI", m.FileURI)
return "", nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (p *javaServiceClient) GetDependenciesDAG(ctx context.Context) (map[uri.URI
}
}

func (p *javaServiceClient) getDependenciesForMaven(ctx context.Context) (map[uri.URI][]provider.DepDAGItem, error) {
func (p *javaServiceClient) getDependenciesForMaven(_ context.Context) (map[uri.URI][]provider.DepDAGItem, error) {
localRepoPath := getMavenLocalRepoPath(p.mvnSettingsFile)

path := p.findPom()
Expand Down Expand Up @@ -338,7 +338,7 @@ func (p *javaServiceClient) getDependenciesForMaven(ctx context.Context) (map[ur

// getDependenciesForGradle invokes the Gradle wrapper to get the dependency tree and returns all project dependencies
// TODO: what if no wrapper?
func (p *javaServiceClient) getDependenciesForGradle(ctx context.Context) (map[uri.URI][]provider.DepDAGItem, error) {
func (p *javaServiceClient) getDependenciesForGradle(_ context.Context) (map[uri.URI][]provider.DepDAGItem, error) {
subprojects, err := p.getGradleSubprojects()
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ func Test_parseMavenDepLines(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
lines := strings.Split(tt.mavenOutput, "\n")
deps := []provider.DepDAGItem{}
var err error
p := javaServiceClient{
log: testr.New(t),
Expand All @@ -540,6 +539,7 @@ func Test_parseMavenDepLines(t *testing.T) {
}
// we are not testing dep init here, so ignore error
p.depInit()
var deps []provider.DepDAGItem
if deps, err = p.parseMavenDepLines(lines[1:], "testdata", "pom.xml"); (err != nil) != tt.wantErr {
t.Errorf("parseMavenDepLines() error = %v, wantErr %v", err, tt.wantErr)
}
Expand Down
Loading
Loading