Skip to content

Commit

Permalink
switched version of golangci-lint from v1.55.2 to 1.60.3
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Sep 4, 2024
1 parent 7f269c8 commit de7dd44
Show file tree
Hide file tree
Showing 34 changed files with 55 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:
workflow_dispatch:
env:
GOLANGCI_LINT_VERSION: v1.55.2
GOLANGCI_LINT_VERSION: v1.60.3
jobs:
golangci:
name: golangci-lint
Expand Down
35 changes: 17 additions & 18 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ run:
#build-tags:
# - mytag

# which dirs to skip: they won't be analyzed;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but next dirs are always skipped independently
# from this option's value:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
# skip-dirs:
skip-dirs-use-default: false

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
Expand All @@ -30,7 +22,7 @@ run:
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
format: colored-line-number
formats: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true
Expand All @@ -51,10 +43,7 @@ linters-settings:
check-blank: false
govet:
# report about shadowed variables
check-shadowing: true
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
shadow: true
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
Expand Down Expand Up @@ -222,22 +211,28 @@ linters:
- cyclop
- depguard
- dupl
- err113
- exhaustive
- exhaustivestruct
- exhaustruct
- fatcontext
- forbidigo
- gochecknoglobals
- gocognit
- gocritic
- godot
- goerr113
- golint
- gomnd
- gosec
- interfacebloat
- intrange
- ireturn
- maintidx
- mnd
- nonamedreturns
- paralleltest
- structcheck
- perfsprint
- predeclared
- testableexamples
- testifylint
- testpackage
- thelper
- varnamelen
Expand Down Expand Up @@ -267,6 +262,11 @@ issues:
# Default value for this option is true.
exclude-use-default: true

# Enables exclude of directories:
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
# Default: true
exclude-dirs-use-default: false

# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

Expand Down Expand Up @@ -302,7 +302,6 @@ issues:
text: "ydb.Connection is deprecated"
- path: examples
linters:
- gomnd
- funlen
- path: tests
linters:
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/database_sql/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func getDataForITCrowd(seriesID string) (series types.Value, seasons, episodes [
return series, seasons, episodes
}

func getDataForSiliconValley(seriesID string) (series types.Value, seasons, episodes []types.Value) {
func getDataForSiliconValley(seriesID string) (series types.Value, seasons, episodes []types.Value) { //nolint:funlen
series = seriesData(
seriesID, date("2014-04-06"), "Silicon Valley", ""+
"Silicon Valley is an American comedy television series created by Mike Judge, John Altschuler and "+
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/database_sql/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func selectDefault(ctx context.Context, db *sql.DB) (err error) {
return nil
}

func selectScan(ctx context.Context, db *sql.DB) (err error) {
func selectScan(ctx context.Context, db *sql.DB) (err error) { //nolint:funlen
// scan query
err = retry.Do(
ydb.WithTxControl(ctx, table.StaleReadOnlyTxControl()),
Expand Down Expand Up @@ -216,7 +216,7 @@ func fillTablesWithData(ctx context.Context, db *sql.DB) (err error) {
return nil
}

func prepareSchema(ctx context.Context, db *sql.DB) (err error) {
func prepareSchema(ctx context.Context, db *sql.DB) (err error) { //nolint:funlen
err = retry.Do(ctx, db, func(ctx context.Context, cc *sql.Conn) error {
err = dropTableIfExists(ctx, cc, "series")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/native/query/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func getDataForITCrowd(seriesID string) (series types.Value, seasons, episodes [
return series, seasons, episodes
}

func getDataForSiliconValley(seriesID string) (series types.Value, seasons, episodes []types.Value) {
func getDataForSiliconValley(seriesID string) (series types.Value, seasons, episodes []types.Value) { //nolint:funlen
series = seriesData(
seriesID, date("2014-04-06"), "Silicon Valley", ""+
"Silicon Valley is an American comedy television series created by Mike Judge, John Altschuler and "+
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/native/query/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func read(ctx context.Context, c query.Client, prefix string) error {
)
}

func fillTablesWithData(ctx context.Context, c query.Client, prefix string) error {
func fillTablesWithData(ctx context.Context, c query.Client, prefix string) error { //nolint:funlen
series, seasons, episodes := getData()

return c.Do(ctx,
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/native/table/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func describeTableOptions(ctx context.Context, c table.Client) error {
)
}

func selectSimple(ctx context.Context, c table.Client, prefix string) error {
func selectSimple(ctx context.Context, c table.Client, prefix string) error { //nolint:funlen
query := render(
template.Must(template.New("").Parse(`
PRAGMA TablePathPrefix("{{ .TablePathPrefix }}");
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/xorm/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func getData() (series []*Series, seasons []*Seasons, episodes []*Episodes) {
return
}

func getDataForITCrowd(seriesID string) (series *Series, seasons []*Seasons, episodes []*Episodes) {
func getDataForITCrowd(seriesID string) (series *Series, seasons []*Seasons, episodes []*Episodes) { //nolint:funlen
series = seriesData(
seriesID, date("2006-02-03"), "IT Crowd", ""+
"The IT Crowd is a British sitcom produced by Channel 4, written by Graham Linehan, produced by "+
Expand Down Expand Up @@ -117,7 +117,7 @@ func getDataForITCrowd(seriesID string) (series *Series, seasons []*Seasons, epi
return series, seasons, episodes
}

func getDataForSiliconValley(seriesID string) (series *Series, seasons []*Seasons, episodes []*Episodes) {
func getDataForSiliconValley(seriesID string) (series *Series, seasons []*Seasons, episodes []*Episodes) { //nolint:funlen,lll
series = seriesData(
seriesID, date("2014-04-06"), "Silicon Valley", ""+
"Silicon Valley is an American comedy television series created by Mike Judge, John Altschuler and "+
Expand Down
2 changes: 1 addition & 1 deletion examples/coordination/workers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func init() {
}
}

func main() {
func main() { //nolint:funlen
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer cancel()

Expand Down
2 changes: 1 addition & 1 deletion examples/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module examples

go 1.22
go 1.23

require (
github.com/golang-jwt/jwt/v4 v4.5.0
Expand Down
2 changes: 1 addition & 1 deletion examples/pagination/cities.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/table/types"
)

func selectPaging(
func selectPaging( //nolint:funlen
ctx context.Context,
c table.Client,
prefix string,
Expand Down
2 changes: 1 addition & 1 deletion examples/serverless/url_shortener/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type service struct {

var once sync.Once

func getService(ctx context.Context, dsn string, opts ...ydb.Option) (s *service, err error) {
func getService(ctx context.Context, dsn string, opts ...ydb.Option) (s *service, err error) { //nolint:funlen
once.Do(func() {
var (
registry = prometheus.NewRegistry()
Expand Down
2 changes: 1 addition & 1 deletion examples/topic/topicreader/topicreader_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func ExplicitPartitionStartStopHandler(ctx context.Context, db *ydb.Driver) {

// PartitionStartStopHandlerAndOwnReadProgressStorage example of complex use explicit start/stop partition handler
// and own progress storage in external system
func PartitionStartStopHandlerAndOwnReadProgressStorage(ctx context.Context, db *ydb.Driver) {
func PartitionStartStopHandlerAndOwnReadProgressStorage(ctx context.Context, db *ydb.Driver) { //nolint:funlen
readContext, stopReader := context.WithCancel(context.Background())
defer stopReader()

Expand Down
2 changes: 1 addition & 1 deletion examples/ttl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func init() { //nolint:gochecknoinits
}
}

func main() {
func main() { //nolint:funlen
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
db, err := ydb.Open(ctx, dsn,
Expand Down
2 changes: 1 addition & 1 deletion examples/ttl_readtable/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func init() { //nolint:gochecknoinits
}
}

func main() {
func main() { //nolint:funlen
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
db, err := ydb.Open(ctx, dsn,
Expand Down
18 changes: 9 additions & 9 deletions examples/ttl_readtable/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func deleteExpiredDocuments(ctx context.Context, c table.Client, prefix string,
return err
}

func deleteExpiredRange(ctx context.Context, c table.Client, prefix string, timestamp uint64,
func deleteExpiredRange(ctx context.Context, c table.Client, prefix string, timestamp uint64, //nolint:funlen
keyRange options.KeyRange,
) error {
fmt.Printf("> DeleteExpiredRange: %+v\n", keyRange)
Expand Down Expand Up @@ -98,7 +98,7 @@ func deleteExpiredRange(ctx context.Context, c table.Client, prefix string, time
// As single key range usually represents a single shard, so we batch deletions here
// without introducing distributed transactions.
var (
docIds []uint64
docIDs []uint64
docID uint64
ts uint64
)
Expand All @@ -113,20 +113,20 @@ func deleteExpiredRange(ctx context.Context, c table.Client, prefix string, time
}

if ts <= timestamp {
docIds = append(docIds, docID)
docIDs = append(docIDs, docID)
}
if len(docIds) >= deleteBatchSize {
if err := deleteExpiredDocuments(ctx, c, prefix, docIds, timestamp); err != nil {
if len(docIDs) >= deleteBatchSize {
if err := deleteExpiredDocuments(ctx, c, prefix, docIDs, timestamp); err != nil {
return err
}
docIds = []uint64{}
docIDs = []uint64{}
}
}
if len(docIds) > 0 {
if err := deleteExpiredDocuments(ctx, c, prefix, docIds, timestamp); err != nil {
if len(docIDs) > 0 {
if err := deleteExpiredDocuments(ctx, c, prefix, docIDs, timestamp); err != nil {
return err
}
docIds = []uint64{}
docIDs = []uint64{}
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/balancer/connections_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func TestSelectRandomConnection(t *testing.T) {
case "2":
second++
default:
t.Errorf(c.Endpoint().Address())
t.Error(c.Endpoint().Address())
}
}
require.Equal(t, 100, first+second)
Expand Down
1 change: 0 additions & 1 deletion internal/conn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ func (c *conn) park(ctx context.Context) (err error) {
}

err = c.close(ctx)

if err != nil {
return xerrors.WithStackTrace(err)
}
Expand Down
3 changes: 0 additions & 3 deletions internal/conn/grpc_client_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func (s *grpcClientStream) CloseSend() (err error) {
defer stop()

err = s.stream.CloseSend()

if err != nil {
if xerrors.IsContextError(err) {
return xerrors.WithStackTrace(err)
Expand Down Expand Up @@ -88,7 +87,6 @@ func (s *grpcClientStream) SendMsg(m interface{}) (err error) {
defer stop()

err = s.stream.SendMsg(m)

if err != nil {
if xerrors.IsContextError(err) {
return xerrors.WithStackTrace(err)
Expand Down Expand Up @@ -144,7 +142,6 @@ func (s *grpcClientStream) RecvMsg(m interface{}) (err error) { //nolint:funlen
defer stop()

err = s.stream.RecvMsg(m)

if err != nil {
if xerrors.Is(err, io.EOF) {
return io.EOF
Expand Down
1 change: 0 additions & 1 deletion internal/credentials/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ func GetSupportedOauth2TokenExchangeJwtAlgorithms() []string {
return algs
}

//nolint:musttag
type stringOrArrayConfig struct {
Values []string
}
Expand Down
2 changes: 1 addition & 1 deletion internal/query/execute_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func readMaterializedResultSet(ctx context.Context, r *streamResult) (_ *materia

var rows []query.Row
for {
row, err := rs.nextRow(ctx) //nolint:govet
row, err := rs.nextRow(ctx)
if err != nil {
if xerrors.Is(err, io.EOF) {
break
Expand Down
1 change: 1 addition & 0 deletions internal/query/result_set_range_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ func TestResultSetRange(t *testing.T) {
})
t.Run("CanceledContext", func(t *testing.T) {
childCtx, cancel := context.WithCancel(xtest.Context(t))
defer cancel()
stream := NewMockQueryService_ExecuteQueryClient(ctrl)
stream.EXPECT().Recv().Return(&Ydb_Query.ExecuteQueryResponsePart{
Status: Ydb.StatusIds_SUCCESS,
Expand Down
2 changes: 1 addition & 1 deletion internal/table/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ func TestSessionPoolGetPut(t *testing.T) {
testutil.TableDeleteSession: func(interface{}) (proto.Message, error) {
deleted++

return nil, nil
return nil, nil //nolint:nilnil
},
},
),
Expand Down
1 change: 0 additions & 1 deletion internal/table/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func do(

return op(xcontext.MarkRetryCall(ctx), s)
}()

if err != nil {
return xerrors.WithStackTrace(err)
}
Expand Down
1 change: 0 additions & 1 deletion internal/topic/topicreadercommon/one_time_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func (s *oneTimeReader) Read(p []byte) (n int, err error) {
}

n, err = s.reader.Read(p)

if err != nil {
s.err = err
s.reader = nil
Expand Down
2 changes: 0 additions & 2 deletions internal/topic/topicwriterinternal/writer_grpc_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func (t *topicWriterOperationUnavailable) StreamWrite(server Ydb_Topic_V1.TopicS
},
},
})

if err != nil {
return fmt.Errorf("failed to send error response: %w", err)
}
Expand Down Expand Up @@ -125,7 +124,6 @@ func (t *topicWriterOperationUnavailable) StreamWrite(server Ydb_Topic_V1.TopicS
},
},
})

if err != nil {
return fmt.Errorf("failed to sent write ack: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/value/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -2183,7 +2183,7 @@ func (v *variantValue) Yql() string {
case *types.VariantStruct:
fmt.Fprintf(buffer, "%q", t.Field(int(v.idx)).Name)
case *types.VariantTuple:
fmt.Fprintf(buffer, "\""+strconv.FormatUint(uint64(v.idx), 10)+"\"")
fmt.Fprint(buffer, "\""+strconv.FormatUint(uint64(v.idx), 10)+"\"")
}
buffer.WriteByte(',')
buffer.WriteString(v.Type().Yql())
Expand Down
Loading

0 comments on commit de7dd44

Please sign in to comment.