@@ -36,7 +36,7 @@ var _ = Describe("Analyzer", func() {
36
36
err = analyzer .Process (buildTags , dir )
37
37
Expect (err ).ShouldNot (HaveOccurred ())
38
38
_ , _ , errors := analyzer .Report ()
39
- Expect (len ( errors )) .To (Equal ( 0 ))
39
+ Expect (errors ).To (BeEmpty ( ))
40
40
})
41
41
42
42
It ("should report an error if the package fails to build" , func () {
@@ -49,9 +49,9 @@ var _ = Describe("Analyzer", func() {
49
49
err = analyzer .Process (buildTags , pkg .Path )
50
50
Expect (err ).ShouldNot (HaveOccurred ())
51
51
_ , _ , errors := analyzer .Report ()
52
- Expect (len ( errors )) .To (Equal (1 ))
52
+ Expect (errors ).To (HaveLen (1 ))
53
53
for _ , ferr := range errors {
54
- Expect (len ( ferr )) .To (Equal (1 ))
54
+ Expect (ferr ).To (HaveLen (1 ))
55
55
}
56
56
})
57
57
@@ -155,7 +155,7 @@ var _ = Describe("Analyzer", func() {
155
155
_ , _ , errors := analyzer .Report ()
156
156
foundErr := false
157
157
for _ , ferr := range errors {
158
- Expect (len ( ferr )) .To (Equal (1 ))
158
+ Expect (ferr ).To (HaveLen (1 ))
159
159
match , err := regexp .MatchString (ferr [0 ].Err , `expected declaration, found '}'` )
160
160
if ! match || err != nil {
161
161
continue
@@ -420,7 +420,7 @@ var _ = Describe("Analyzer", func() {
420
420
err = customAnalyzer .Process (buildTags , nosecPackage .Path )
421
421
Expect (err ).ShouldNot (HaveOccurred ())
422
422
nosecIssues , _ , _ := customAnalyzer .Report ()
423
- Expect (nosecIssues ).Should (HaveLen ( 0 ))
423
+ Expect (nosecIssues ).Should (BeEmpty ( ))
424
424
})
425
425
426
426
It ("should ignore vulnerabilities when the default tag is found" , func () {
@@ -443,7 +443,7 @@ var _ = Describe("Analyzer", func() {
443
443
err = customAnalyzer .Process (buildTags , nosecPackage .Path )
444
444
Expect (err ).ShouldNot (HaveOccurred ())
445
445
nosecIssues , _ , _ := customAnalyzer .Report ()
446
- Expect (nosecIssues ).Should (HaveLen ( 0 ))
446
+ Expect (nosecIssues ).Should (BeEmpty ( ))
447
447
})
448
448
449
449
It ("should be able to analyze Go test package" , func () {
@@ -511,7 +511,7 @@ var _ = Describe("Analyzer", func() {
511
511
err = customAnalyzer .Process (buildTags , pkg .Path )
512
512
Expect (err ).ShouldNot (HaveOccurred ())
513
513
issues , _ , _ := customAnalyzer .Report ()
514
- Expect (issues ).Should (HaveLen ( 0 ))
514
+ Expect (issues ).Should (BeEmpty ( ))
515
515
})
516
516
})
517
517
It ("should be able to analyze Cgo files" , func () {
@@ -527,7 +527,7 @@ var _ = Describe("Analyzer", func() {
527
527
err = analyzer .Process (buildTags , testPackage .Path )
528
528
Expect (err ).ShouldNot (HaveOccurred ())
529
529
issues , _ , _ := analyzer .Report ()
530
- Expect (issues ).Should (HaveLen ( 0 ))
530
+ Expect (issues ).Should (BeEmpty ( ))
531
531
})
532
532
533
533
Context ("when parsing errors from a package" , func () {
@@ -549,9 +549,9 @@ var _ = Describe("Analyzer", func() {
549
549
err := analyzer .ParseErrors (pkg )
550
550
Expect (err ).ShouldNot (HaveOccurred ())
551
551
_ , _ , errors := analyzer .Report ()
552
- Expect (len ( errors )) .To (Equal (1 ))
552
+ Expect (errors ).To (HaveLen (1 ))
553
553
for _ , ferr := range errors {
554
- Expect (len ( ferr )) .To (Equal (1 ))
554
+ Expect (ferr ).To (HaveLen (1 ))
555
555
Expect (ferr [0 ].Line ).To (Equal (1 ))
556
556
Expect (ferr [0 ].Column ).To (Equal (2 ))
557
557
Expect (ferr [0 ].Err ).Should (MatchRegexp (`build error` ))
@@ -570,9 +570,9 @@ var _ = Describe("Analyzer", func() {
570
570
err := analyzer .ParseErrors (pkg )
571
571
Expect (err ).ShouldNot (HaveOccurred ())
572
572
_ , _ , errors := analyzer .Report ()
573
- Expect (len ( errors )) .To (Equal (1 ))
573
+ Expect (errors ).To (HaveLen (1 ))
574
574
for _ , ferr := range errors {
575
- Expect (len ( ferr )) .To (Equal (1 ))
575
+ Expect (ferr ).To (HaveLen (1 ))
576
576
Expect (ferr [0 ].Line ).To (Equal (0 ))
577
577
Expect (ferr [0 ].Column ).To (Equal (0 ))
578
578
Expect (ferr [0 ].Err ).Should (MatchRegexp (`build error` ))
@@ -591,9 +591,9 @@ var _ = Describe("Analyzer", func() {
591
591
err := analyzer .ParseErrors (pkg )
592
592
Expect (err ).ShouldNot (HaveOccurred ())
593
593
_ , _ , errors := analyzer .Report ()
594
- Expect (len ( errors )) .To (Equal (1 ))
594
+ Expect (errors ).To (HaveLen (1 ))
595
595
for _ , ferr := range errors {
596
- Expect (len ( ferr )) .To (Equal (1 ))
596
+ Expect (ferr ).To (HaveLen (1 ))
597
597
Expect (ferr [0 ].Line ).To (Equal (0 ))
598
598
Expect (ferr [0 ].Column ).To (Equal (0 ))
599
599
Expect (ferr [0 ].Err ).Should (MatchRegexp (`build error` ))
@@ -642,9 +642,9 @@ var _ = Describe("Analyzer", func() {
642
642
err := analyzer .ParseErrors (pkg )
643
643
Expect (err ).ShouldNot (HaveOccurred ())
644
644
_ , _ , errors := analyzer .Report ()
645
- Expect (len ( errors )) .To (Equal (1 ))
645
+ Expect (errors ).To (HaveLen (1 ))
646
646
for _ , ferr := range errors {
647
- Expect (len ( ferr )) .To (Equal (2 ))
647
+ Expect (ferr ).To (HaveLen (2 ))
648
648
Expect (ferr [0 ].Line ).To (Equal (1 ))
649
649
Expect (ferr [0 ].Column ).To (Equal (2 ))
650
650
Expect (ferr [0 ].Err ).Should (MatchRegexp (`error1` ))
@@ -675,7 +675,7 @@ var _ = Describe("Analyzer", func() {
675
675
It ("should skip error for non-buildable packages" , func () {
676
676
analyzer .AppendError ("test" , errors .New (`loading file from package "pkg/test": no buildable Go source files in pkg/test` ))
677
677
_ , _ , errors := analyzer .Report ()
678
- Expect (len ( errors )) .To (Equal ( 0 ))
678
+ Expect (errors ).To (BeEmpty ( ))
679
679
})
680
680
681
681
It ("should add a new error" , func () {
@@ -691,9 +691,9 @@ var _ = Describe("Analyzer", func() {
691
691
Expect (err ).ShouldNot (HaveOccurred ())
692
692
analyzer .AppendError ("file" , errors .New ("file build error" ))
693
693
_ , _ , errors := analyzer .Report ()
694
- Expect (len ( errors )) .To (Equal (1 ))
694
+ Expect (errors ).To (HaveLen (1 ))
695
695
for _ , ferr := range errors {
696
- Expect (len ( ferr )) .To (Equal (2 ))
696
+ Expect (ferr ).To (HaveLen (2 ))
697
697
}
698
698
})
699
699
})
0 commit comments