Skip to content

Commit

Permalink
merging-extra-lint
Browse files Browse the repository at this point in the history
Signed-off-by: Akhilesh Kr. Yadav <[email protected]>
  • Loading branch information
Akhilesh Kr. Yadav authored and Akhilesh Kr. Yadav committed Jan 13, 2025
1 parent 7a7c630 commit 33723e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
24 changes: 12 additions & 12 deletions corim/unsignedcorim.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ func (o *UnsignedCorim) SetID(v interface{}) *UnsignedCorim {
}

// GetID retrieves the corim-id from the unsigned-corim-map as a string
func (o UnsignedCorim) GetID() string {
return o.ID.String()
func (o *UnsignedCorim) GetID() string {
return o.ID.String()
}

// AddComid appends the CBOR encoded (and appropriately tagged) CoMID to the
// tags array of the unsigned-corim-map
func (o *UnsignedCorim) AddComid(c comid.Comid) *UnsignedCorim {
func (o *UnsignedCorim) AddComid(c *comid.Comid) *UnsignedCorim {
if o != nil {
if c.Valid() != nil {
return nil
Expand All @@ -105,7 +105,7 @@ func (o *UnsignedCorim) AddComid(c comid.Comid) *UnsignedCorim {
return nil
}

taggedComid := append(ComidTag, comidCBOR...)
taggedComid := append(ComidTag, comidCBOR...) //nolint:gocritic

o.Tags = append(o.Tags, taggedComid)
}
Expand All @@ -114,7 +114,7 @@ func (o *UnsignedCorim) AddComid(c comid.Comid) *UnsignedCorim {

// AddCots appends the CBOR encoded (and appropriately tagged) CoTS to the
// tags array of the unsigned-corim-map
func (o *UnsignedCorim) AddCots(c cots.ConciseTaStore) *UnsignedCorim {
func (o *UnsignedCorim) AddCots(c *cots.ConciseTaStore) *UnsignedCorim {
if o != nil {
if c.Valid() != nil {
return nil
Expand All @@ -125,7 +125,7 @@ func (o *UnsignedCorim) AddCots(c cots.ConciseTaStore) *UnsignedCorim {
return nil
}

taggedCots := append(cots.CotsTag, cotsCBOR...)
taggedCots := append(cots.CotsTag, cotsCBOR...) //nolint:gocritic

o.Tags = append(o.Tags, taggedCots)
}
Expand All @@ -134,7 +134,7 @@ func (o *UnsignedCorim) AddCots(c cots.ConciseTaStore) *UnsignedCorim {

// AddCoswid appends the CBOR encoded (and appropriately tagged) CoSWID to the
// tags array of the unsigned-corim-map
func (o *UnsignedCorim) AddCoswid(c swid.SoftwareIdentity) *UnsignedCorim {
func (o *UnsignedCorim) AddCoswid(c *swid.SoftwareIdentity) *UnsignedCorim {
if o != nil {
// Currently the swid package doesn't offer an interface
// for validating the supplied CoSWID, so -- for now --
Expand All @@ -146,7 +146,7 @@ func (o *UnsignedCorim) AddCoswid(c swid.SoftwareIdentity) *UnsignedCorim {
return nil
}

taggedCoswid := append(CoswidTag, coswidCBOR...)
taggedCoswid := append(CoswidTag, coswidCBOR...) //nolint:gocritic

o.Tags = append(o.Tags, taggedCoswid)
}
Expand Down Expand Up @@ -232,7 +232,7 @@ func (o *UnsignedCorim) AddEntity(name string, regID *string, roles ...Role) *Un
}

// Valid checks the validity (according to the spec) of the target unsigned CoRIM
func (o UnsignedCorim) Valid() error {
func (o *UnsignedCorim) Valid() error {
if o.ID == (swid.TagID{}) {
return fmt.Errorf("empty id")
}
Expand Down Expand Up @@ -275,11 +275,11 @@ func (o UnsignedCorim) Valid() error {
}
}

return o.Extensions.validCorim(&o)
o)

Check failure on line 278 in corim/unsignedcorim.go

View workflow job for this annotation

GitHub Actions / Lint

syntax error: unexpected ) at end of statement (typecheck)

Check failure on line 278 in corim/unsignedcorim.go

View workflow job for this annotation

GitHub Actions / Lint

expected statement, found ')' (typecheck)

Check failure on line 278 in corim/unsignedcorim.go

View workflow job for this annotation

GitHub Actions / Test on macos-latest

syntax error: unexpected ) at end of statement

Check failure on line 278 in corim/unsignedcorim.go

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

syntax error: unexpected ) at end of statement
}

// ToCBOR serializes the target unsigned CoRIM to CBOR
func (o UnsignedCorim) ToCBOR() ([]byte, error) {
func (o *UnsignedCorim) ToCBOR() ([]byte, error) {
// If extensions have been registered, the collection will exist, but
// might be empty. If that is the case, set it to nil to avoid
// marshaling an empty list (and let the marshaller omit the claim
Expand All @@ -299,7 +299,7 @@ func (o *UnsignedCorim) FromCBOR(data []byte) error {
}

// ToJSON serializes the target unsigned CoRIM to JSON
func (o UnsignedCorim) ToJSON() ([]byte, error) {
func (o *UnsignedCorim) ToJSON() ([]byte, error) {
// If extensions have been registered, the collection will exist, but
// might be empty. If that is the case, set it to nil to avoid
// marshaling an empty list (and let the marshaller omit the claim
Expand Down
12 changes: 6 additions & 6 deletions corim/unsignedcorim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestUnsignedCorim_AddComid_and_marshal(t *testing.T) {
tv := NewUnsignedCorim().SetID("test corim id")
require.NotNil(t, tv)

c := comid.Comid{}
c := &comid.Comid{}
err := c.FromJSON([]byte(comid.PSARefValJSONTemplate))
require.Nil(t, err)

Expand All @@ -76,7 +76,7 @@ func TestUnsignedCorim_AddCots_and_marshal(t *testing.T) {
tv := NewUnsignedCorim().SetID("test corim id with CoTS")
require.NotNil(t, tv)

c := cots.ConciseTaStore{}
c := &cots.ConciseTaStore{}

err := c.FromJSON([]byte(cots.ConciseTaStoreTemplateSingleOrg))
require.Nil(t, err)
Expand All @@ -102,7 +102,7 @@ func TestUnsignedCorim_AddCoswid_and_marshal(t *testing.T) {
err := c.FromXML(data)
require.Nil(t, err)

assert.NotNil(t, tv.AddCoswid(c))
assert.NotNil(t, tv.AddCoswid(&c))

actual, err := tv.ToCBOR()
assert.Nil(t, err)
Expand Down Expand Up @@ -191,7 +191,7 @@ func TestUnsignedCorim_Valid_ok(t *testing.T) {
SetID("invalid.tags.corim").
AddDependentRim("http://endorser.example/addon.corim", nil).
SetProfile("https://arm.com/psa/iot/2.0.0").
AddComid(*c).
AddComid(c).
SetRimValidity(time.Now().Add(time.Hour), nil).
AddEntity("ACME Ltd.", nil, RoleManifestCreator)

Expand Down Expand Up @@ -325,7 +325,7 @@ func TestUnsignedCorim_ToJSON(t *testing.T) {
SetID("invalid.tags.corim").
AddDependentRim("http://endorser.example/addon.corim", nil).
SetProfile("https://arm.com/psa/iot/2.0.0").
AddComid(*c)
AddComid(c)

require.NotNil(t, tv)

Expand Down Expand Up @@ -368,7 +368,7 @@ func TestUnsignedCorim_ToCBOR(t *testing.T) {
SetID("invalid.tags.corim").
AddDependentRim("http://endorser.example/addon.corim", nil).
SetProfile("https://arm.com/psa/iot/2.0.0").
AddComid(*c)
AddComid(c)

require.NotNil(t, tv)

Expand Down

0 comments on commit 33723e5

Please sign in to comment.