Skip to content

Commit e74f473

Browse files
authored
[Linter] Fix linting issues (#337)
Fixed by Claude code after running `make go_lint`
1 parent 7cdbeef commit e74f473

29 files changed

+84
-64
lines changed

.github/workflows/run-lint-and-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ jobs:
2323
run: |
2424
git config --global url."https://${{ github.token }}:[email protected]/".insteadOf "https://github.com/"
2525
26-
- name: Run golangci-lint
27-
uses: golangci/golangci-lint-action@v6
26+
- name: golangci-lint
27+
uses: golangci/golangci-lint-action@v8
2828
with:
29-
version: latest
30-
args: --timeout 10m --verbose
29+
version: v2.1
30+
args: --timeout 20m --verbose
3131

3232
run-unit-tests:
3333
name: Run unit tests

.golangci.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
linters-settings:
2-
gocritic:
3-
disabled-checks:
4-
- sloppyTypeAssert
1+
version: "2"
2+
linters:
3+
settings:
4+
gocritic:
5+
disabled-checks:
6+
- sloppyTypeAssert
7+
exclusions:
8+
generated: lax
9+
presets:
10+
- comments
11+
- common-false-positives
12+
- legacy
13+
- std-error-handling
14+
paths:
15+
- third_party$
16+
- builtin$
17+
- examples$
18+
formatters:
19+
exclusions:
20+
generated: lax
21+
paths:
22+
- third_party$
23+
- builtin$
24+
- examples$

cmd/data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func setupHTTPDataReporter(
2323

2424
// Error parsing the specified target URL.
2525
if _, err := url.Parse(config.TargetURL); err != nil {
26-
return nil, fmt.Errorf("Error processing the HTTP Data Reporter's target URL: %w", err)
26+
return nil, fmt.Errorf("error processing the HTTP Data Reporter's target URL: %w", err)
2727
}
2828

2929
return &data.DataReporterHTTP{

data/reporter_http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (drh *DataReporterHTTP) sendRecordOverHTTP(serializedDataRecord []byte) err
8989

9090
// Verify the data processor responded with OK
9191
if resp.StatusCode != http.StatusOK {
92-
return fmt.Errorf("Error sending the data record: got HTTP status %d, expected %d", resp.StatusCode, http.StatusOK)
92+
return fmt.Errorf("error sending the data record: got HTTP status %d, expected %d", resp.StatusCode, http.StatusOK)
9393
}
9494

9595
return nil

gateway/errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66

77
var (
88
// no service ID was provided by the user.
9-
GatewayErrNoServiceIDProvided = errors.New("no service ID provided")
9+
ErrGatewayNoServiceIDProvided = errors.New("no service ID provided")
1010

1111
// QoS instance rejected the request.
1212
// e.g. HTTP payload could not be unmarshaled into a JSONRPC request.
13-
GatewayErrRejectedByQoS = errors.New("QoS instance rejected the request")
13+
ErrGatewayRejectedByQoS = errors.New("QoS instance rejected the request")
1414
)

gateway/hydrator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (eph *EndpointHydrator) performChecks(serviceID protocol.ServiceID, service
136136
// This implies there is no need to specify a specific app.
137137
// TODO_TECHDEBT(@adshmh): support specifying the app(s) used for sending/signing synthetic relay requests by the hydrator.
138138
// TODO_FUTURE(@adshmh): consider publishing observations if endpoint lookup fails.
139-
availableEndpoints, _, err := eph.Protocol.AvailableEndpoints(context.TODO(), serviceID, nil)
139+
availableEndpoints, _, err := eph.AvailableEndpoints(context.TODO(), serviceID, nil)
140140
if err != nil || len(availableEndpoints) == 0 {
141141
// No session found or no endpoints available for service: skip.
142142
logger.Warn().Msg("no session found or no endpoints available for service when running hydrator checks.")
@@ -178,7 +178,7 @@ func (eph *EndpointHydrator) performChecks(serviceID protocol.ServiceID, service
178178
// which means there is no need for specifying a specific app.
179179
// TODO_FUTURE(@adshmh): support specifying the app(s) used for sending/signing synthetic relay requests by the hydrator.
180180
// TODO_FUTURE(@adshmh): consider publishing observations here.
181-
hydratorRequestCtx, _, err := eph.Protocol.BuildRequestContextForEndpoint(context.TODO(), serviceID, endpointAddr, nil)
181+
hydratorRequestCtx, _, err := eph.BuildRequestContextForEndpoint(context.TODO(), serviceID, endpointAddr, nil)
182182
if err != nil {
183183
logger.Error().Err(err).Msg("Failed to build a protocol request context for the endpoint")
184184
continue

gateway/request_context.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (rc *requestContext) updateGatewayObservations(err error) {
140140

141141
switch {
142142
// Service ID not specified
143-
case errors.Is(err, GatewayErrNoServiceIDProvided):
143+
case errors.Is(err, ErrGatewayNoServiceIDProvided):
144144
rc.logger.Error().Err(err).Msg("No service ID specified in the HTTP headers. Request will fail.")
145145
rc.gatewayObservations.RequestError = &observation.GatewayRequestError{
146146
// Set the error kind
@@ -151,7 +151,7 @@ func (rc *requestContext) updateGatewayObservations(err error) {
151151

152152
// Request was rejected by the QoS instance.
153153
// e.g. HTTP payload could not be unmarshaled into a JSONRPC request.
154-
case errors.Is(err, GatewayErrRejectedByQoS):
154+
case errors.Is(err, ErrGatewayRejectedByQoS):
155155
rc.logger.Error().Err(err).Msg("QoS instance rejected the request. Request will fail.")
156156
rc.gatewayObservations.RequestError = &observation.GatewayRequestError{
157157
// Set the error kind
@@ -190,7 +190,7 @@ func (rc *requestContext) BuildQoSContextFromHTTP(httpReq *http.Request) error {
190190
rc.requestRejectedByQoS = true
191191

192192
// Update gateway observations
193-
rc.updateGatewayObservations(GatewayErrRejectedByQoS)
193+
rc.updateGatewayObservations(ErrGatewayRejectedByQoS)
194194
rc.logger.Info().Msg(errHTTPRequestRejectedByQoS.Error())
195195
return errHTTPRequestRejectedByQoS
196196
}

message/qos/qos.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (m *Messenger) Publish(observationSet message.ObservationSet) error {
6363
func (m *Messenger) Start() error {
6464
// TODO_INCOMPLETE: validate the struct.
6565

66-
observationSetMsgCh := m.MessagePlatform.Subscribe(observationSetTopic)
66+
observationSetMsgCh := m.Subscribe(observationSetTopic)
6767

6868
go func() {
6969
m.run(observationSetMsgCh)

protocol/morse/errors.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var (
3838
ErrInvalidResponse = errors.New("invalid response from endpoint")
3939

4040
// ErrPocketCore is returned whan an endpoint returns an SDK or Pocket-core error.
41-
ErrPocketCore = errors.New("endpoint returned SDK/Pocket-Core error.")
41+
ErrPocketCore = errors.New("endpoint returned SDK/Pocket-Core error")
4242

4343
// ErrSDK4XX is the Morse SDK's 4XX error.
4444
// https://github.com/pokt-foundation/pocket-go/blob/0cb5a3a2ab762e7af18b3482f864d2d9d211a71f/provider/provider.go#L24
@@ -57,10 +57,10 @@ var (
5757
// ErrHTTPContentLengthIncorrect is returned when an endpoint returns an HTTP response with a mismatch between:
5858
// - The ContentLength HTTP header
5959
// - Actual body length
60-
ErrHTTPContentLengthIncorrect = errors.New("endpoint returned HTTP response with ContentLength mismatching the actual length.")
60+
ErrHTTPContentLengthIncorrect = errors.New("endpoint returned HTTP response with ContentLength mismatching the actual length")
6161

6262
// ErrExecutingHTTPRequest is returned when an endpoint returned an error indicating it encountered an error executing the HTTP request.
63-
ErrExecutingHTTPRequest = errors.New("endpoint indicated error executing the HTTP request.")
63+
ErrExecutingHTTPRequest = errors.New("endpoint indicated error executing the HTTP request")
6464
)
6565

6666
// NewNoEndpointsError creates a formatted error for when no endpoints are available

protocol/morse/fullnode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type FullNodeConfig struct {
6464

6565
func (c FullNodeConfig) Validate() error {
6666
if c.RelaySigningKey == "" {
67-
return fmt.Errorf("Morse full node config invalid: no signing key specified")
67+
return fmt.Errorf("morse full node config invalid: no signing key specified")
6868
}
6969

7070
return nil

0 commit comments

Comments
 (0)