Skip to content

Commit b2da5d8

Browse files
authored
Merge pull request #86 from sapcc/enable_revive
enable revive, run gomm, fix dostring lints
2 parents 18b324a + 520da7e commit b2da5d8

File tree

12 files changed

+76
-14
lines changed

12 files changed

+76
-14
lines changed

.golangci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ linters:
6363
- perfsprint
6464
- predeclared
6565
- rowserrcheck
66+
- revive
6667
- sqlclosecheck
6768
- staticcheck
6869
- unconvert
@@ -159,6 +160,12 @@ linters:
159160
perfsprint:
160161
# modernize generates nicer fix code
161162
concat-loop: false
163+
revive:
164+
rules:
165+
- name: exported
166+
arguments:
167+
- checkPrivateReceivers
168+
- disableChecksOnConstants
162169
staticcheck:
163170
dot-import-whitelist:
164171
- github.com/majewsky/gg/option

Makefile.maker.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ metadata:
55

66
golangciLint:
77
createConfig: true
8+
reviveRules:
9+
- name: exported
10+
arguments:
11+
- checkPrivateReceivers
12+
- disableChecksOnConstants
813

914
githubWorkflow:
1015
ci:

castellum/assets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type StandaloneOperation struct {
3333
AssetID string `json:"asset_id,omitempty"`
3434
}
3535

36-
// StandaloneOperation is the API representation for a pending or finished
36+
// Operation is the API representation for a pending or finished
3737
// resize operation when the operation appears within its respective asset.
3838
type Operation struct {
3939
State OperationState `json:"state"`

deployevent/deployevent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ type HelmRelease struct {
8585
DurationSeconds *uint64 `json:"duration,omitempty"`
8686
}
8787

88-
// ActiveDirectory appears in type Event. It describes a deployment of Active
88+
// ActiveDirectoryDeployment appears in type Event. It describes a deployment of Active
8989
// Directory to one of our Windows servers.
9090
type ActiveDirectoryDeployment struct {
9191
Landscape string `json:"landscape"` // e.g. "dev" or "prod"

internal/clone/clone.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Package clone contains helper functions for implementing deep clones.
55
package clone
66

7+
// Cloneable is an interface for types that can be cloned by implementing a Clone() method.
78
type Cloneable[Self any] interface {
89
Clone() Self
910
}

internal/testhelper/testhelper.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ import (
1111
"testing"
1212
)
1313

14+
// AssertNoErr fails the test if the provided error is not nil.
1415
func AssertNoErr(t *testing.T, err error) {
1516
t.Helper()
1617
if err != nil {
1718
t.Errorf("unexpected error: %s", err.Error())
1819
}
1920
}
2021

22+
// AssertErr fails the test if the provided error is nil.
2123
func AssertErr(t *testing.T, expected string, actual error) {
2224
t.Helper()
2325
switch {
@@ -29,6 +31,7 @@ func AssertErr(t *testing.T, expected string, actual error) {
2931
}
3032
}
3133

34+
// CheckEquals fails the test if a simple equal check between expected and actual fails.
3235
func CheckEquals[V comparable](t *testing.T, expected, actual V) {
3336
t.Helper()
3437
if expected != actual {
@@ -37,6 +40,7 @@ func CheckEquals[V comparable](t *testing.T, expected, actual V) {
3740
}
3841
}
3942

43+
// CheckDeepEquals fails the test if a reflect.DeepEqual check between expected and actual fails.
4044
func CheckDeepEquals(t *testing.T, expected, actual any) {
4145
t.Helper()
4246
if !reflect.DeepEqual(expected, actual) {
@@ -45,6 +49,8 @@ func CheckDeepEquals(t *testing.T, expected, actual any) {
4549
}
4650
}
4751

52+
// CheckJSONEquals fails the test if a reflect.DeepEqual check between the marshalled actual value
53+
// and the expectedJSON fails.
4854
func CheckJSONEquals(t *testing.T, expectedJSON string, actual any) {
4955
t.Helper()
5056
actualJSON, err := json.Marshal(actual)
@@ -58,6 +64,7 @@ func CheckJSONEquals(t *testing.T, expectedJSON string, actual any) {
5864
}
5965
}
6066

67+
// decodeJSON is a convenience wrapper around json.Marshal and fails the test if an error occurs.
6168
func decodeJSON(t *testing.T, buf []byte) (data any) {
6269
t.Helper()
6370
err := json.Unmarshal(buf, &data)

limes/rates/input.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
// This type is used to serialize JSON request bodies in PUT requests on projects.
1515
type RateRequest map[limes.ServiceType]ServiceRequest
1616

17-
// ServiceQuotaRequest contains new rate limit values for rates in a single
17+
// ServiceRequest contains new rate limit values for rates in a single
1818
// service. This type appears in type RateRequest.
1919
type ServiceRequest map[RateName]RateLimitRequest
2020

limes/rates/marshal.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,40 @@ import (
88
"github.com/sapcc/go-api-declarations/limes"
99
)
1010

11-
func (r ClusterRateReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(r) }
11+
// MarshalJSON implements the json.Marshaler interface.
12+
func (r ClusterRateReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(r) }
13+
14+
// MarshalJSON implements the json.Marshaler interface.
1215
func (s ClusterServiceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(s) }
13-
func (r ProjectRateReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(r) }
16+
17+
// MarshalJSON implements the json.Marshaler interface.
18+
func (r ProjectRateReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(r) }
19+
20+
// MarshalJSON implements the json.Marshaler interface.
1421
func (s ProjectServiceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(s) }
1522

23+
// UnmarshalJSON implements the json.Unmarshaler interface.
1624
func (r *ClusterRateReports) UnmarshalJSON(buf []byte) error {
1725
m, err := marshal.MapFromList(buf, func(r *ClusterRateReport) RateName { return r.Name })
1826
*r = ClusterRateReports(m)
1927
return err
2028
}
29+
30+
// UnmarshalJSON implements the json.Unmarshaler interface.
2131
func (s *ClusterServiceReports) UnmarshalJSON(buf []byte) error {
2232
m, err := marshal.MapFromList(buf, func(s *ClusterServiceReport) limes.ServiceType { return s.Type })
2333
*s = ClusterServiceReports(m)
2434
return err
2535
}
36+
37+
// UnmarshalJSON implements the json.Unmarshaler interface.
2638
func (r *ProjectRateReports) UnmarshalJSON(buf []byte) error {
2739
m, err := marshal.MapFromList(buf, func(r *ProjectRateReport) RateName { return r.Name })
2840
*r = ProjectRateReports(m)
2941
return err
3042
}
43+
44+
// UnmarshalJSON implements the json.Unmarshaler interface.
3145
func (s *ProjectServiceReports) UnmarshalJSON(buf []byte) error {
3246
m, err := marshal.MapFromList(buf, func(s *ProjectServiceReport) limes.ServiceType { return s.Type })
3347
*s = ProjectServiceReports(m)

limes/resources/marshal.go

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,70 @@ import (
88
"github.com/sapcc/go-api-declarations/limes"
99
)
1010

11+
// MarshalJSON implements the json.Marshaler interface.
1112
func (r ClusterAvailabilityZoneReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(r) }
12-
func (r ClusterResourceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(r) }
13-
func (s ClusterServiceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(s) }
14-
func (r DomainResourceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(r) }
15-
func (s DomainServiceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(s) }
16-
func (r ProjectResourceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(r) }
17-
func (s ProjectServiceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(s) }
1813

14+
// MarshalJSON implements the json.Marshaler interface.
15+
func (r ClusterResourceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(r) }
16+
17+
// MarshalJSON implements the json.Marshaler interface.
18+
func (s ClusterServiceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(s) }
19+
20+
// MarshalJSON implements the json.Marshaler interface.
21+
func (r DomainResourceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(r) }
22+
23+
// MarshalJSON implements the json.Marshaler interface.
24+
func (s DomainServiceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(s) }
25+
26+
// MarshalJSON implements the json.Marshaler interface.
27+
func (r ProjectResourceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(r) }
28+
29+
// MarshalJSON implements the json.Marshaler interface.
30+
func (s ProjectServiceReports) MarshalJSON() ([]byte, error) { return marshal.MapAsList(s) }
31+
32+
// UnmarshalJSON implements the json.Unmarshaler interface.
1933
func (r *ClusterAvailabilityZoneReports) UnmarshalJSON(buf []byte) error {
2034
m, err := marshal.MapFromList(buf, func(r *ClusterAvailabilityZoneReport) limes.AvailabilityZone { return r.Name })
2135
*r = ClusterAvailabilityZoneReports(m)
2236
return err
2337
}
38+
39+
// UnmarshalJSON implements the json.Unmarshaler interface.
2440
func (r *ClusterResourceReports) UnmarshalJSON(buf []byte) error {
2541
m, err := marshal.MapFromList(buf, func(r *ClusterResourceReport) ResourceName { return r.Name })
2642
*r = ClusterResourceReports(m)
2743
return err
2844
}
45+
46+
// UnmarshalJSON implements the json.Unmarshaler interface.
2947
func (s *ClusterServiceReports) UnmarshalJSON(buf []byte) error {
3048
m, err := marshal.MapFromList(buf, func(s *ClusterServiceReport) limes.ServiceType { return s.Type })
3149
*s = ClusterServiceReports(m)
3250
return err
3351
}
52+
53+
// UnmarshalJSON implements the json.Unmarshaler interface.
3454
func (r *DomainResourceReports) UnmarshalJSON(buf []byte) error {
3555
m, err := marshal.MapFromList(buf, func(r *DomainResourceReport) ResourceName { return r.Name })
3656
*r = DomainResourceReports(m)
3757
return err
3858
}
59+
60+
// UnmarshalJSON implements the json.Unmarshaler interface.
3961
func (s *DomainServiceReports) UnmarshalJSON(buf []byte) error {
4062
m, err := marshal.MapFromList(buf, func(s *DomainServiceReport) limes.ServiceType { return s.Type })
4163
*s = DomainServiceReports(m)
4264
return err
4365
}
66+
67+
// UnmarshalJSON implements the json.Unmarshaler interface.
4468
func (r *ProjectResourceReports) UnmarshalJSON(buf []byte) error {
4569
m, err := marshal.MapFromList(buf, func(r *ProjectResourceReport) ResourceName { return r.Name })
4670
*r = ProjectResourceReports(m)
4771
return err
4872
}
73+
74+
// UnmarshalJSON implements the json.Unmarshaler interface.
4975
func (s *ProjectServiceReports) UnmarshalJSON(buf []byte) error {
5076
m, err := marshal.MapFromList(buf, func(s *ProjectServiceReport) limes.ServiceType { return s.Type })
5177
*s = ProjectServiceReports(m)

limes/resources/report_cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ type ClusterResourceReports map[ResourceName]*ClusterResourceReport
9595
// using a map, but serializes to JSON as a list.
9696
type ClusterAvailabilityZoneReports map[limes.AvailabilityZone]*ClusterAvailabilityZoneReport
9797

98-
// ClusterAZResourceReport is a substructure of ClusterResourceReport that breaks
98+
// ClusterAZResourceReports is a substructure of ClusterResourceReport that breaks
9999
// down capacity and usage data for a single resource by availability zone.
100100
type ClusterAZResourceReports map[limes.AvailabilityZone]*ClusterAZResourceReport

0 commit comments

Comments
 (0)