Skip to content

Commit e72b1e5

Browse files
authored
Use of vars instead of func
1 parent c81cff0 commit e72b1e5

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

cwe/data.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package cwe
22

3+
import "fmt"
4+
35
const (
46
// Acronym is the acronym of CWE
57
Acronym = "CWE"
@@ -14,6 +16,11 @@ const (
1416
)
1517

1618
var (
19+
// InformationURI link to the published CWE PDF
20+
InformationURI = fmt.Sprintf("https://cwe.mitre.org/data/published/cwe_v%s.pdf/", Version)
21+
// DownloadURI link to the zipped XML of the CWE list
22+
DownloadURI = fmt.Sprintf("https://cwe.mitre.org/data/xml/cwec_v%s.xml.zip", Version)
23+
1724
data = map[string]*Weakness{}
1825

1926
weaknesses = []*Weakness{

cwe/types.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,3 @@ func (w *Weakness) MarshalJSON() ([]byte, error) {
3232
URL: w.SprintURL(),
3333
})
3434
}
35-
36-
// InformationURI link to the published CWE PDF
37-
func InformationURI() string {
38-
return fmt.Sprintf("https://cwe.mitre.org/data/published/cwe_v%s.pdf/", Version)
39-
}
40-
41-
// DownloadURI link to the zipped XML of the CWE list
42-
func DownloadURI() string {
43-
return fmt.Sprintf("https://cwe.mitre.org/data/xml/cwec_v%s.xml.zip", Version)
44-
}

cwe/types_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ var _ = Describe("CWE Types", func() {
1111
})
1212
Context("when consulting cwe types", func() {
1313
It("it should retrieves the information and download URIs", func() {
14-
Expect(cwe.InformationURI()).To(Equal("https://cwe.mitre.org/data/published/cwe_v4.4.pdf/"))
15-
Expect(cwe.DownloadURI()).To(Equal("https://cwe.mitre.org/data/xml/cwec_v4.4.xml.zip"))
14+
Expect(cwe.InformationURI).To(Equal("https://cwe.mitre.org/data/published/cwe_v4.4.pdf/"))
15+
Expect(cwe.DownloadURI).To(Equal("https://cwe.mitre.org/data/xml/cwec_v4.4.xml.zip"))
1616
})
1717

1818
It("it should retrieves the weakness ID and URL", func() {

report/sarif/formatter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ func buildSarifReportingDescriptorRelationship(weakness *cwe.Weakness) *Reportin
104104
}
105105

106106
func buildCWETaxonomy(taxa []*ReportingDescriptor) *ToolComponent {
107-
return NewToolComponent(cwe.Acronym, cwe.Version, cwe.InformationURI()).
107+
return NewToolComponent(cwe.Acronym, cwe.Version, cwe.InformationURI).
108108
WithReleaseDateUtc(cwe.ReleaseDateUtc).
109-
WithDownloadURI(cwe.DownloadURI()).
109+
WithDownloadURI(cwe.DownloadURI).
110110
WithOrganization(cwe.Organization).
111111
WithShortDescription(NewMultiformatMessageString(cwe.Description)).
112112
WithIsComprehensive(true).

0 commit comments

Comments
 (0)