Migrate golanglint-ci config to V2 (#21081)

This commit is contained in:
Taran Pelkey
2025-03-29 20:56:02 -04:00
committed by GitHub
parent b67f0cf721
commit e88d494775
77 changed files with 239 additions and 290 deletions

View File

@@ -82,7 +82,7 @@ func (eDate *ExpirationDate) UnmarshalXML(d *xml.Decoder, startElement xml.Start
hr, m, sec := expDate.Clock()
nsec := expDate.Nanosecond()
loc := expDate.Location()
if !(hr == 0 && m == 0 && sec == 0 && nsec == 0 && loc.String() == time.UTC.String()) {
if hr != 0 || m != 0 || sec != 0 || nsec != 0 || loc.String() != time.UTC.String() {
return errLifecycleDateNotMidnight
}
@@ -93,7 +93,7 @@ func (eDate *ExpirationDate) UnmarshalXML(d *xml.Decoder, startElement xml.Start
// MarshalXML encodes expiration date if it is non-zero and encodes
// empty string otherwise
func (eDate ExpirationDate) MarshalXML(e *xml.Encoder, startElement xml.StartElement) error {
if eDate.Time.IsZero() {
if eDate.IsZero() {
return nil
}
return e.EncodeElement(eDate.Format(time.RFC3339), startElement)
@@ -202,7 +202,7 @@ func (e Expiration) IsDaysNull() bool {
// IsDateNull returns true if date field is null
func (e Expiration) IsDateNull() bool {
return e.Date.Time.IsZero()
return e.Date.IsZero()
}
// IsNull returns true if both date and days fields are null

View File

@@ -53,7 +53,7 @@ func (tDate *TransitionDate) UnmarshalXML(d *xml.Decoder, startElement xml.Start
hr, m, sec := trnDate.Clock()
nsec := trnDate.Nanosecond()
loc := trnDate.Location()
if !(hr == 0 && m == 0 && sec == 0 && nsec == 0 && loc.String() == time.UTC.String()) {
if hr != 0 || m != 0 || sec != 0 || nsec != 0 || loc.String() != time.UTC.String() {
return errTransitionDateNotMidnight
}
@@ -64,7 +64,7 @@ func (tDate *TransitionDate) UnmarshalXML(d *xml.Decoder, startElement xml.Start
// MarshalXML encodes expiration date if it is non-zero and encodes
// empty string otherwise
func (tDate TransitionDate) MarshalXML(e *xml.Encoder, startElement xml.StartElement) error {
if tDate.Time.IsZero() {
if tDate.IsZero() {
return nil
}
return e.EncodeElement(tDate.Format(time.RFC3339), startElement)
@@ -151,7 +151,7 @@ func (t Transition) Validate() error {
// IsDateNull returns true if date field is null
func (t Transition) IsDateNull() bool {
return t.Date.Time.IsZero()
return t.Date.IsZero()
}
// IsNull returns true if both date and days fields are null

View File

@@ -176,7 +176,7 @@ func (c Config) HasExistingObjectReplication(arn string) (hasARN, isEnabled bool
// FilterActionableRules returns the rules actions that need to be executed
// after evaluating prefix/tag filtering
func (c Config) FilterActionableRules(obj ObjectOpts) []Rule {
if obj.Name == "" && !(obj.OpType == ResyncReplicationType || obj.OpType == AllReplicationType) {
if obj.Name == "" && (obj.OpType != ResyncReplicationType && obj.OpType != AllReplicationType) {
return nil
}
var rules []Rule

View File

@@ -29,7 +29,7 @@ type ARN struct {
// String - returns string representation.
func (arn ARN) String() string {
if arn.TargetID.ID == "" && arn.TargetID.Name == "" && arn.region == "" {
if arn.ID == "" && arn.Name == "" && arn.region == "" {
return ""
}

View File

@@ -178,9 +178,7 @@ func (u UUIDHash) Sum(b []byte) []byte {
}
// Reset - implement hash.Hash Reset
func (u UUIDHash) Reset() {
return
}
func (u UUIDHash) Reset() {}
// Size - implement hash.Hash Size
func (u UUIDHash) Size() int {

View File

@@ -30,7 +30,7 @@ type ARN struct {
// String - returns string representation.
func (arn ARN) String() string {
if arn.TargetID.ID == "" && arn.TargetID.Name == "" && arn.region == "" {
if arn.ID == "" && arn.Name == "" && arn.region == "" {
return ""
}

View File

@@ -55,9 +55,11 @@ type AMQPArgs struct {
QueueLimit uint64 `json:"queueLimit"`
}
//lint:file-ignore ST1003 We cannot change these exported names.
// AMQP input constants.
//
// ST1003 We cannot change these exported names.
//
//nolint:staticcheck
const (
AmqpQueueDir = "queue_dir"
AmqpQueueLimit = "queue_limit"

View File

@@ -62,11 +62,11 @@ type XDGSCRAMClient struct {
// and authzID via the SASLprep algorithm, as recommended by RFC-5802. If
// SASLprep fails, the method returns an error.
func (x *XDGSCRAMClient) Begin(userName, password, authzID string) (err error) {
x.Client, err = x.HashGeneratorFcn.NewClient(userName, password, authzID)
x.Client, err = x.NewClient(userName, password, authzID)
if err != nil {
return err
}
x.ClientConversation = x.Client.NewConversation()
x.ClientConversation = x.NewConversation()
return nil
}

View File

@@ -375,7 +375,7 @@ func (target *MySQLTarget) initMySQL() error {
err = target.db.Ping()
if err != nil {
if !(xnet.IsConnRefusedErr(err) || xnet.IsConnResetErr(err)) {
if !xnet.IsConnRefusedErr(err) && !xnet.IsConnResetErr(err) {
target.loggerOnce(context.Background(), err, target.ID().String())
}
} else {

View File

@@ -243,7 +243,7 @@ func (target *NSQTarget) initNSQ() error {
err = target.producer.Ping()
if err != nil {
// To treat "connection refused" errors as errNotConnected.
if !(xnet.IsConnRefusedErr(err) || xnet.IsConnResetErr(err)) {
if !xnet.IsConnRefusedErr(err) && !xnet.IsConnResetErr(err) {
target.loggerOnce(context.Background(), err, target.ID().String())
}
target.producer.Stop()

View File

@@ -376,7 +376,7 @@ func (target *PostgreSQLTarget) initPostgreSQL() error {
err = target.db.Ping()
if err != nil {
if !(xnet.IsConnRefusedErr(err) || xnet.IsConnResetErr(err)) {
if !xnet.IsConnRefusedErr(err) && !xnet.IsConnResetErr(err) {
target.loggerOnce(context.Background(), err, target.ID().String())
}
} else {

View File

@@ -293,7 +293,7 @@ func (target *RedisTarget) initRedis() error {
_, pingErr := conn.Do("PING")
if pingErr != nil {
if !(xnet.IsConnRefusedErr(pingErr) || xnet.IsConnResetErr(pingErr)) {
if !xnet.IsConnRefusedErr(pingErr) && !xnet.IsConnResetErr(pingErr) {
target.loggerOnce(context.Background(), pingErr, target.ID().String())
}
return pingErr

View File

@@ -114,7 +114,6 @@ func (list *TargetList) incCurrentSendCalls(id TargetID) {
stats.currentSendCalls++
list.targetStats[id] = stats
return
}
func (list *TargetList) decCurrentSendCalls(id TargetID) {
@@ -129,7 +128,6 @@ func (list *TargetList) decCurrentSendCalls(id TargetID) {
stats.currentSendCalls--
list.targetStats[id] = stats
return
}
func (list *TargetList) incFailedEvents(id TargetID) {
@@ -143,7 +141,6 @@ func (list *TargetList) incFailedEvents(id TargetID) {
stats.failedEvents++
list.targetStats[id] = stats
return
}
func (list *TargetList) incTotalEvents(id TargetID) {
@@ -157,7 +154,6 @@ func (list *TargetList) incTotalEvents(id TargetID) {
stats.totalEvents++
list.targetStats[id] = stats
return
}
type asyncEvent struct {

View File

@@ -466,19 +466,14 @@ func benchmarkGridStreamTwoway(b *testing.B, n int) {
// Send 10x requests.
Handle: func(ctx context.Context, payload []byte, in <-chan []byte, out chan<- []byte) *RemoteErr {
got := 0
for {
select {
case b, ok := <-in:
if !ok {
if got != messages {
return NewRemoteErrf("wrong number of requests. want %d, got %d", messages, got)
}
return nil
}
out <- b
got++
}
for b := range in {
out <- b
got++
}
if got != messages {
return NewRemoteErrf("wrong number of requests. want %d, got %d", messages, got)
}
return nil
},
Subroute: "some-subroute",

View File

@@ -1511,7 +1511,6 @@ func (c *Connection) handlePing(ctx context.Context, m message) {
pong := pongMsg{NotFound: true, T: ping.T}
gridLogIf(ctx, c.queueMsg(m, &pong))
}
return
}
func (c *Connection) handleDisconnectClientMux(m message) {

View File

@@ -192,7 +192,7 @@ func bytesOrLength(b []byte) string {
if len(b) > 100 {
return fmt.Sprintf("%d bytes", len(b))
}
return fmt.Sprint(b)
return fmt.Sprint(string(b))
}
// ConnDialer is a function that dials a connection to the given address.

View File

@@ -387,15 +387,14 @@ func (u *URLValues) UnmarshalMsg(bts []byte) (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (u URLValues) Msgsize() (s int) {
s = msgp.MapHeaderSize
if u != nil {
for zb0006, zb0007 := range u {
_ = zb0007
s += msgp.StringPrefixSize + len(zb0006) + msgp.ArrayHeaderSize
for zb0008 := range zb0007 {
s += msgp.StringPrefixSize + len(zb0007[zb0008])
}
for zb0006, zb0007 := range u {
_ = zb0007
s += msgp.StringPrefixSize + len(zb0006) + msgp.ArrayHeaderSize
for zb0008 := range zb0007 {
s += msgp.StringPrefixSize + len(zb0007[zb0008])
}
}
return
}

View File

@@ -172,7 +172,7 @@ func (lrw *ResponseRecorder) WriteHeader(code int) {
if !lrw.headersLogged {
lrw.ttfbHeader = time.Now().UTC().Sub(lrw.StartTime)
lrw.StatusCode = code
lrw.writeHeaders(&lrw.headers, code, lrw.ResponseWriter.Header())
lrw.writeHeaders(&lrw.headers, code, lrw.Header())
lrw.headersLogged = true
lrw.ResponseWriter.WriteHeader(code)
}

View File

@@ -129,7 +129,7 @@ func (srv *Server) Init(listenCtx context.Context, listenErrCallback func(listen
}
serve = func() error {
return srv.Server.Serve(l)
return srv.Serve(l)
}
return

View File

@@ -147,8 +147,7 @@ func (w *Writer) compress() error {
}
defer gw.Close()
var wc io.WriteCloser
wc = gzip.NewWriter(gw)
var wc io.WriteCloser = gzip.NewWriter(gw)
if _, err = io.Copy(wc, r); err != nil {
return err
}

View File

@@ -147,7 +147,6 @@ func (r *ReqInfo) PopulateTagsMap(tagsMap map[string]string) {
for _, t := range r.tags {
tagsMap[t.Key] = t.Val
}
return
}
// SetReqInfo sets ReqInfo in the context.

View File

@@ -353,9 +353,9 @@ func (h *Target) startQueueProcessor(ctx context.Context, mainWorker bool) {
if count < h.batchSize {
tickered := false
select {
case _ = <-ticker.C:
case <-ticker.C:
tickered = true
case entry, _ = <-globalBuffer:
case entry = <-globalBuffer:
case entry, ok = <-h.logCh:
if !ok {
return

View File

@@ -63,11 +63,11 @@ type XDGSCRAMClient struct {
// and authzID via the SASLprep algorithm, as recommended by RFC-5802. If
// SASLprep fails, the method returns an error.
func (x *XDGSCRAMClient) Begin(userName, password, authzID string) (err error) {
x.Client, err = x.HashGeneratorFcn.NewClient(userName, password, authzID)
x.Client, err = x.NewClient(userName, password, authzID)
if err != nil {
return err
}
x.ClientConversation = x.Client.NewConversation()
x.ClientConversation = x.NewConversation()
return nil
}

View File

@@ -284,7 +284,6 @@ func (c *Client) dumpHTTP(req *http.Request, resp *http.Response) {
}
// Returns success.
return
}
// ErrClientClosed returned when *Client is closed.

View File

@@ -85,10 +85,8 @@ func (r *RingBuffer) SetBlocking(block bool) *RingBuffer {
// A goroutine will be started and run until the provided context is canceled.
func (r *RingBuffer) WithCancel(ctx context.Context) *RingBuffer {
go func() {
select {
case <-ctx.Done():
r.CloseWithError(ctx.Err())
}
<-ctx.Done()
r.CloseWithError(ctx.Err())
}()
return r
}