Skip to content

Commit dba6ed8

Browse files
fix golangci-lint errors
1 parent b1cc369 commit dba6ed8

11 files changed

+34
-33
lines changed

.golangci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ linters-settings:
2626
gofmt:
2727
simplify: false
2828
goimports:
29-
local-prefixes: github.com/fxamacker/cbor
3029
golint:
3130
min-confidence: 0
3231
govet:

common.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func codeStringer(code interface{}, dict codeDictionary, codeName string) string
7777
func codeToCBOR(code interface{}, dict stringDictionary) ([]byte, error) {
7878
v := code
7979

80-
// always try to minimise bandwidth
80+
// always try to minimize bandwidth
8181
if err := codifyString(&v, dict); err != nil {
8282
return nil, err
8383
}
@@ -88,7 +88,7 @@ func codeToCBOR(code interface{}, dict stringDictionary) ([]byte, error) {
8888
func codeToJSON(code interface{}, dict codeDictionary) ([]byte, error) {
8989
v := code // make a copy we can clobber
9090

91-
// always try to maximise expressiveness
91+
// always try to maximize expressiveness
9292
// however, avoid encoding unknown codes
9393
if err := stringifyCode(&v, dict, ""); err != nil {
9494
return nil, err
@@ -100,7 +100,7 @@ func codeToJSON(code interface{}, dict codeDictionary) ([]byte, error) {
100100
func codeToXMLAttr(attrName xml.Name, code interface{}, dict codeDictionary) (xml.Attr, error) {
101101
v := code // make a copy we can clobber
102102

103-
// always try to maximise expressiveness
103+
// always try to maximize expressiveness
104104
// however, avoid encoding unknown codes
105105
if err := stringifyCode(&v, dict, ""); err != nil {
106106
return xml.Attr{}, err
@@ -116,7 +116,7 @@ func xToCode(enc encoder, from []byte, dict stringDictionary, to *interface{}) e
116116
return err
117117
}
118118

119-
// try to make internal representation as homogeneus as possible
119+
// try to make internal representation as homogeneous as possible
120120
if err := codifyString(to, dict); err != nil {
121121
return err
122122
}

doc.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Identification (SWID) Tags as defined by ISO/IEC 19770-2:2015 as well as by
44
their "concise" counterpart (CoSWID) defined by draft-ietf-sacm-coswid.
55
66
The library aims at using the most space-efficient encoding when using CBOR
7-
and the most expressive one when using XML and JSON, preferring to serialise
7+
and the most expressive one when using XML and JSON, preferring to serialize
88
strings rather tham of their equivalent code-points. When decoding, the most
99
space efficient representation is used. In dealing with unknown code-points,
1010
we follow the Postel principle: refusing to encode unknown protocol entities,
@@ -26,7 +26,7 @@ This will generate a Tag with a minimal structure. You can then use the API
2626
to add additional information and meta data to the tag.
2727
2828
You will need to add one or more "entity" entries, representing the
29-
organisation(s) responsible for the information contained in the tag.
29+
organization(s) responsible for the information contained in the tag.
3030
All entities have an associated "role" and a recommended "registration id":
3131
3232
entity, err := NewEntity(
@@ -76,15 +76,15 @@ And subsequently added to the tag's "payload":
7676
Note that the same data structures could be added to an "evidence" instead,
7777
were the tag describing a "live" system rather than a software package.
7878
79-
Once the tag is complete, it can be serialised using one of the CBOR, XML or
79+
Once the tag is complete, it can be serialized using one of the CBOR, XML or
8080
JSON marshalers:
8181
8282
data, err := tag.ToXML() // or tag.ToCBOR(), or tag.ToJSON()
8383
8484
8585
Consuming Tags
8686
87-
A tag can be de-serialised using one of the "From" interfaces. For example,
87+
A tag can be de-serialized using one of the "From" interfaces. For example,
8888
to decode a CoSWID tag from a memory buffer:
8989
9090
var tag SoftwareIdentity

entity.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type Entity struct {
5656
Thumbprint *HashEntry `cbor:"34,keyasint,omitempty" json:"thumbprint,omitempty" xml:"thumbprint,omitempty"`
5757
}
5858

59-
// NewEntity instantiates a new Entity object initialised with the given
59+
// NewEntity instantiates a new Entity object initialized with the given
6060
// entityName and roles
6161
func NewEntity(entityName string, roles ...interface{}) (*Entity, error) {
6262
e := Entity{

evidence.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Evidence struct {
1818
DeviceID string `cbor:"36,keyasint,omitempty" json:"device-id,omitempty" xml:"deviceId,attr,omitempty"`
1919
}
2020

21-
// NewEvidence instantiates a new Evidence object initialised with the given
21+
// NewEvidence instantiates a new Evidence object initialized with the given
2222
// deviceID
2323
func NewEvidence(deviceID string) *Evidence {
2424
return &Evidence{

link.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ type Link struct {
105105
Use *Use `cbor:"42,keyasint,omitempty" json:"use,omitempty" xml:"use,attr,omitempty"`
106106
}
107107

108-
// NewLink instantiates a new Link object initialised with the supplied href and
108+
// NewLink instantiates a new Link object initialized with the supplied href and
109109
// link relation
110110
func NewLink(href string, rel Rel) (*Link, error) {
111111
l := Link{

processes_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func TestProcesses_UnmarshalCBOR(t *testing.T) {
8888
expectedErr: nil,
8989
},
9090
{
91-
name: "accept array with one element (non optimised)",
91+
name: "accept array with one element (non optimized)",
9292
/*
9393
81 # array(1)
9494
a1 # map(1)
@@ -128,7 +128,7 @@ func TestProcesses_UnmarshalCBOR(t *testing.T) {
128128
expectedErr: nil,
129129
},
130130
{
131-
name: "one scalar element (optimised encoding)",
131+
name: "one scalar element (optimized encoding)",
132132
/*
133133
a1 # map(1)
134134
18 1b # unsigned(27)
@@ -162,7 +162,7 @@ func benchmarkProcessesMarshal(i int, b *testing.B) {
162162

163163
for n := 0; n < b.N; n++ {
164164
if _, e := ps.MarshalCBOR(); e != nil {
165-
b.Fatalf("marshalling failed: %v", e)
165+
b.Fatalf("marshaling failed: %v", e)
166166
}
167167
}
168168
}

resource_extension.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type PSAMeasuredSoftwareComponent struct {
2020
}
2121

2222
// NewPSAMeasuredSoftwareComponentResource returns a Resource of type
23-
// PSAMeasuredSoftwareComponent initialised according to the supplied
23+
// PSAMeasuredSoftwareComponent initialized according to the supplied
2424
// measurement value and signer ID
2525
func NewPSAMeasuredSoftwareComponentResource(
2626
measurementValue HashEntry, signerID HashEntry,

roundtripper.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,20 @@ import (
1111

1212
// marshal + unmarshal
1313
func roundTripper(t *testing.T, tv interface{}, expectedCBOR []byte) interface{} {
14-
// don't allow TZ info to get lost in the encoding / decoding process
15-
// em, err := cbor.EncOptions{Time: cbor.TimeRFC3339, TimeTag: cbor.EncTagRequired}.EncMode()
16-
em, err := cbor.EncOptions{TimeTag: cbor.EncTagRequired}.EncMode()
14+
encMode, err := cbor.EncOptions{TimeTag: cbor.EncTagRequired}.EncMode()
1715
require.Nil(t, err)
1816

19-
data, err := em.Marshal(tv)
17+
data, err := encMode.Marshal(tv)
2018

2119
assert.Nil(t, err)
2220
t.Logf("CBOR(hex): %x\n", data)
2321
assert.Equal(t, expectedCBOR, data)
2422

25-
dm, err := cbor.DecOptions{TimeTag: cbor.DecTagOptional}.DecMode()
23+
decMode, err := cbor.DecOptions{TimeTag: cbor.DecTagOptional}.DecMode()
2624
require.Nil(t, err)
2725

2826
actual := reflect.New(reflect.TypeOf(tv))
29-
err = dm.Unmarshal(data, actual.Interface())
27+
err = decMode.Unmarshal(data, actual.Interface())
3028

3129
assert.Nil(t, err)
3230
assert.Equal(t, tv, actual.Elem().Interface())

softwareidentity.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -151,35 +151,35 @@ func NewTag(tagID interface{}, softwareName, softwareVersion string) (*SoftwareI
151151
return &t, nil
152152
}
153153

154-
// ToXML serialises the receiver SoftwareIdentity to SWID
154+
// ToXML serializes the receiver SoftwareIdentity to SWID
155155
func (t SoftwareIdentity) ToXML() ([]byte, error) {
156156
return xml.Marshal(t)
157157
}
158158

159-
// ToJSON serialises the receiver SoftwareIdentity to CoSWID using the JSON
159+
// ToJSON serializes the receiver SoftwareIdentity to CoSWID using the JSON
160160
// formatter
161161
func (t SoftwareIdentity) ToJSON() ([]byte, error) {
162162
return json.Marshal(t)
163163
}
164164

165-
// ToCBOR serialises the receiver SoftwareIdentity to CoSWID
165+
// ToCBOR serializes the receiver SoftwareIdentity to CoSWID
166166
func (t SoftwareIdentity) ToCBOR() ([]byte, error) {
167167
return em.Marshal(t)
168168
}
169169

170-
// FromXML deserialises the supplied XML encoded SWID into the receiver
170+
// FromXML deserializes the supplied XML encoded SWID into the receiver
171171
// SoftwareIdentity
172172
func (t *SoftwareIdentity) FromXML(data []byte) error {
173173
return xml.Unmarshal(data, t)
174174
}
175175

176-
// FromJSON deserialises the supplied JSON encoded CoSWID into the receiver
176+
// FromJSON deserializes the supplied JSON encoded CoSWID into the receiver
177177
// SoftwareIdentity
178178
func (t *SoftwareIdentity) FromJSON(data []byte) error {
179179
return json.Unmarshal(data, t)
180180
}
181181

182-
// FromCBOR deserialises the supplied CBOR encoded CoSWID into the receiver
182+
// FromCBOR deserializes the supplied CBOR encoded CoSWID into the receiver
183183
// SoftwareIdentity
184184
func (t *SoftwareIdentity) FromCBOR(data []byte) error {
185185
return dm.Unmarshal(data, t)

softwareidentity_test.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
package swid
22

3-
import "testing"
3+
import (
4+
"testing"
45

5-
func makeACMEEntityWithRoles(roles ...interface{}) Entity {
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
func makeACMEEntityWithRoles(t *testing.T, roles ...interface{}) Entity {
610
e := Entity{
711
EntityName: "ACME Ltd",
812
RegID: "acme.example",
913
}
1014

11-
e.SetRoles(roles...)
15+
require.Nil(t, e.SetRoles(roles...))
1216

1317
return e
1418
}
@@ -19,7 +23,7 @@ func TestTag_RoundtripPSABundle(t *testing.T) {
1923
SoftwareName: "Roadrunner software bundle",
2024
SoftwareVersion: "1.0.0",
2125
Entities: Entities{
22-
makeACMEEntityWithRoles(
26+
makeACMEEntityWithRoles(t,
2327
RoleTagCreator,
2428
RoleSoftwareCreator,
2529
RoleAggregator,
@@ -136,7 +140,7 @@ func TestTag_RoundtripPSAComponent(t *testing.T) {
136140
SoftwareName: "Roadrunner boot loader",
137141
SoftwareVersion: "1.0.0",
138142
Entities: Entities{
139-
makeACMEEntityWithRoles(
143+
makeACMEEntityWithRoles(t,
140144
RoleTagCreator,
141145
RoleAggregator,
142146
),

0 commit comments

Comments
 (0)