Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
Signed-off-by: Soham Arora <[email protected]>
  • Loading branch information
arorasoham9 committed Aug 15, 2024
1 parent d7f2658 commit bd1f6fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
6 changes: 2 additions & 4 deletions pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,6 @@ func ComputeStringDiffs(dmp *diffmatchpatch.DiffMatchPatch, text1, text2 string)
return diffString
}



func FormatDiffs(diffs []diffmatchpatch.Diff) string {

var parts []string
Expand Down Expand Up @@ -1078,7 +1076,7 @@ func CompareAllPaths(listOne, listTwo [][]*Node) (DiffResult, error) {
nodeDiffs, diffs, diffNum, err := CompareTwoPaths(dmp, pathOne, pathTwo)

if err != nil {
return DiffResult{}, fmt.Errorf(err.Error())
return DiffResult{}, fmt.Errorf("error comparing paths %v", err.Error())
}

if diffNum < min {
Expand Down Expand Up @@ -1146,7 +1144,7 @@ func CompareAllPaths(listOne, listTwo [][]*Node) (DiffResult, error) {
dmp := diffmatchpatch.New()
diffNode, _, err := compareNodes(dmp, *node, *dumnode)
if err != nil {
return DiffResult{}, fmt.Errorf(err.Error())
return DiffResult{}, fmt.Errorf("error comparing nodes %v", fmt.Errorf(err.Error()))
}
missingPath = append(missingPath, diffNode)

Expand Down
22 changes: 11 additions & 11 deletions pkg/analyzer/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,31 @@ func TestHighlightAnalysis(t *testing.T) {

data, err := readTestFileFromHub(diffTestFile)
if err != nil {
t.Errorf("Error reading test JSON")
t.Errorf("error reading test JSON")
}

var sboms []model.HasSBOMsHasSBOM

err = json.Unmarshal(data, &sboms)
if err != nil {
t.Errorf("Error unmarshaling JSON")
t.Errorf("error unmarshaling JSON")
}

graphOne, errOne := analyzer.MakeGraph(sboms[0], false, false, false, false, false)

graphTwo, errTwo := analyzer.MakeGraph(sboms[1], false, false, false, false, false)

if errOne != nil || errTwo != nil {
t.Errorf("Error making graph %v %v", errOne.Error(), errTwo.Error())
t.Errorf("error making graph %v %v", errOne.Error(), errTwo.Error())
}

one, two, err := analyzer.HighlightAnalysis(graphOne, graphTwo, 0)

if err != nil {
t.Errorf("Error highlighting diff %v", err.Error())
t.Errorf("error highlighting diff %v", err.Error())
}
if len(one) == 0 || len(two) == 0 {
t.Errorf("Error highlighting diff, wanted diffs got 0")
t.Errorf("error highlighting diff, wanted diffs got 0")
}
}

Expand All @@ -83,7 +83,7 @@ func TestAddGraphNode(t *testing.T) {
analyzer.AddGraphNode(g, "id", "black")
_, err := g.Vertex("id")
if err != nil {
t.Errorf("Error adding node with id 'id': %v", err)
t.Errorf("error adding node with id 'id': %v", err)
}
}

Expand All @@ -93,14 +93,14 @@ func TestAddGraphEdge(t *testing.T) {

_, err := g.Edge("from", "to")
if err != nil {
t.Errorf("Error getting edge from %s to %s: %v", "from", "to", err)
t.Errorf("error getting edge from %s to %s: %v", "from", "to", err)
}
}

func TestEquivalence(t *testing.T) {
data, err := readTestFileFromHub(diffTestFile)
if err != nil {
t.Errorf("Error reading test file %v", err.Error())
t.Errorf("error reading test file %v", err.Error())
}

var sboms []model.HasSBOMsHasSBOM
Expand All @@ -116,17 +116,17 @@ func TestEquivalence(t *testing.T) {
graphTwo, errTwo := analyzer.MakeGraph(val, false, false, false, false, false)

if errOne != nil || errTwo != nil {
t.Errorf("Error making graph %v %v", errOne.Error(), errTwo.Error())
t.Errorf("error making graph %v %v", errOne.Error(), errTwo.Error())
}

ok, err := analyzer.GraphEqual(graphOne, graphTwo)
if !ok {
t.Errorf("Reconstructed graph not equal " + err.Error())
t.Errorf("reconstructed graph not equal %v", err.Error())
}

ok, err = analyzer.GraphEdgesEqual(graphOne, graphTwo)
if !ok {
t.Errorf("Reconstructed graph edges not equal " + err.Error())
t.Errorf("reconstructed graph edges not equal %v", err.Error())
}
}

Expand Down

0 comments on commit bd1f6fa

Please sign in to comment.