diff --git a/.golangci.yaml b/.golangci.yaml index f488f8af4f..3cfadf3f7a 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,13 +1,4 @@ linters-settings: - depguard: - # new configuration - rules: - # logger: - # deny: - # # logging is allowed only by logutils.Log, - # # logrus is allowed to use only in logutils package. - # - pkg: "github.com/sirupsen/logrus" - # desc: logging is allowed only by logutils.Log dupl: threshold: 150 funlen: @@ -15,7 +6,7 @@ linters-settings: statements: 50 goconst: min-len: 2 - min-occurrences: 3 + min-occurrences: 10 gocritic: enabled-tags: - diagnostic @@ -34,7 +25,7 @@ linters-settings: rewrite-rules: - pattern: "interface{}" replacement: "any" - gomnd: + mnd: # don't include the "operation" and "assign" checks: - argument @@ -51,15 +42,6 @@ linters-settings: ignored-functions: - strings.SplitN - govet: - check-shadowing: false - # settings: - # printf: - # funcs: - # - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof - # - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf - # - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf - # - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf lll: line-length: 140 misspell: @@ -78,60 +60,42 @@ linters: disable-all: true enable: - bodyclose - # - depguard - dogsled - # - dupl - errcheck - forbidigo - # - funlen - # - gochecknoinits - goconst - gocritic - # - gocyclo - gofmt - goimports - # - gomnd - goprintffuncname - gosec - gosimple - govet - ineffassign - # - lll - misspell - nakedret - noctx - nolintlint - revive - staticcheck - # - stylecheck - typecheck - unconvert - unparam - unused - whitespace - - # don't enable: - # - asciicheck - # - scopelint - # - gochecknoglobals - # - gocognit - # - godot - # - godox - # - goerr113 - # - interfacer - # - maligned - # - nestif - # - prealloc - # - testpackage - # - wsl + - usestdlibvars issues: - excluded-dirs: + exclude-dirs: - frontend - charts - docs - node_modules - backend/gen + - tilt + - scripts + - python + - keycloak # # Excluding configuration per-path, per-linter, per-text and per-source exclude-rules: - path: _test\.go @@ -145,3 +109,4 @@ issues: run: timeout: 10m + tests: false # exclude test files diff --git a/backend/internal/auth/client/client.go b/backend/internal/auth/client/client.go index 7d3bf398d1..0d0fe15357 100644 --- a/backend/internal/auth/client/client.go +++ b/backend/internal/auth/client/client.go @@ -93,7 +93,7 @@ func (c *Client) GetTokenResponse( if err != nil { return nil, err } - req, err := http.NewRequestWithContext(ctx, "POST", tokenurl, payload) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, tokenurl, payload) if err != nil { return nil, fmt.Errorf("unable to request oauth authorization code: %w", err) } @@ -154,7 +154,7 @@ func (c *Client) GetRefreshedAccessToken( if err != nil { return nil, err } - req, err := http.NewRequestWithContext(ctx, "POST", tokenurl, payload) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, tokenurl, payload) if err != nil { return nil, fmt.Errorf("unable to initiate refresh token request: %w", err) @@ -208,7 +208,7 @@ func (c *Client) GetUserInfo( return nil, err } - req, err := http.NewRequestWithContext(ctx, "GET", userinfourl, http.NoBody) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, userinfourl, http.NoBody) if err != nil { return nil, err } @@ -276,7 +276,7 @@ type openIdConfiguration struct { func (c *Client) getOpenIdConfiguration(ctx context.Context) (*openIdConfiguration, error) { configUrl := fmt.Sprintf("%s/.well-known/openid-configuration", strings.TrimSuffix(c.authBaseUrl, "/")) - req, err := http.NewRequestWithContext(ctx, "GET", configUrl, http.NoBody) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, configUrl, http.NoBody) if err != nil { return nil, err } diff --git a/backend/internal/auth/clientcred_token_provider/client.go b/backend/internal/auth/clientcred_token_provider/client.go index 2fb4e82b6a..0e8b284bda 100644 --- a/backend/internal/auth/clientcred_token_provider/client.go +++ b/backend/internal/auth/clientcred_token_provider/client.go @@ -34,7 +34,7 @@ func (c *tokenProviderClient) GetToken(ctx context.Context) (*auth_client.AuthTo payload := strings.NewReader( values.Encode(), ) - req, err := http.NewRequestWithContext(ctx, "POST", c.tokenurl, payload) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.tokenurl, payload) if err != nil { return nil, fmt.Errorf("unable to request oauth authorization code: %w", err) } diff --git a/backend/pkg/metrics/usage.go b/backend/pkg/metrics/usage.go index baa976bd66..f07fc7e467 100644 --- a/backend/pkg/metrics/usage.go +++ b/backend/pkg/metrics/usage.go @@ -156,8 +156,3 @@ func timeToDate(t time.Time) mgmtv1alpha1.Date { Day: uint32(t.Day()), //nolint:gosec // Ignoring for now } } - -// Formats the day into the Neosync Date Format of YYYY-DD-MM -func formatDate(d *mgmtv1alpha1.Date) string { - return fmt.Sprintf("%04d-%02d-%02d", d.Year, d.Month, d.Day) -} diff --git a/backend/pkg/sqlmanager/postgres/postgres-manager.go b/backend/pkg/sqlmanager/postgres/postgres-manager.go index 7e4c526331..4ffb008115 100644 --- a/backend/pkg/sqlmanager/postgres/postgres-manager.go +++ b/backend/pkg/sqlmanager/postgres/postgres-manager.go @@ -438,7 +438,7 @@ func (p *PostgresManager) GetTableInitStatements(ctx context.Context, tables []* DataType: record.DataType, IsNullable: record.IsNullable == "YES", GeneratedType: record.GeneratedType, - IsSerial: record.SequenceType == "SERIAL", //nolint:goconst + IsSerial: record.SequenceType == "SERIAL", Sequence: seqConfig, IdentityType: &record.IdentityGeneration, })) diff --git a/backend/sql/postgresql/models/models.go b/backend/sql/postgresql/models/models.go index cd082dc52a..f8d9fd1d95 100644 --- a/backend/sql/postgresql/models/models.go +++ b/backend/sql/postgresql/models/models.go @@ -1133,7 +1133,7 @@ func (s *PostgresSourceOptions) FromDto(dto *mgmtv1alpha1.PostgresSourceConnecti s.NewColumnAdditionStrategy = &PostgresNewColumnAdditionStrategy{} s.NewColumnAdditionStrategy.FromDto(dto.GetNewColumnAdditionStrategy()) } else if dto.GetHaltOnNewColumnAddition() { - // halt on new column addition is deprecated, so if the new column strat is nil but the deprecated value is true, + // halt on new column addition is deprecated, so if the new column strategy is nil but the deprecated value is true, // we are going to store it in the new strategy format. s.NewColumnAdditionStrategy = &PostgresNewColumnAdditionStrategy{ HaltJob: &PostgresHaltJobStrategy{}, diff --git a/internal/postgres/utils.go b/internal/postgres/utils.go index b2ab73b796..e46d4492ff 100644 --- a/internal/postgres/utils.go +++ b/internal/postgres/utils.go @@ -219,14 +219,14 @@ func CreateMultiDimSlice(dims []int, elements []any) any { // handles multi-dimensional slices subSize := 1 - for _, dim := range dims[1:] { //nolint:gosec + for _, dim := range dims[1:] { subSize *= dim } for i := 0; i < firstDim; i++ { start := i * subSize end := start + subSize - subSlice := CreateMultiDimSlice(dims[1:], elements[start:end]) //nolint:gosec + subSlice := CreateMultiDimSlice(dims[1:], elements[start:end]) slice.Index(i).Set(reflect.ValueOf(subSlice)) } diff --git a/worker/pkg/benthos/transformers/generate_international_phone_number.go b/worker/pkg/benthos/transformers/generate_international_phone_number.go index f10a4a8c62..31efdb0ef5 100644 --- a/worker/pkg/benthos/transformers/generate_international_phone_number.go +++ b/worker/pkg/benthos/transformers/generate_international_phone_number.go @@ -3,7 +3,6 @@ package transformers import ( "errors" "fmt" - "strings" mgmtv1alpha1 "github.com/nucleuscloud/neosync/backend/gen/go/protos/mgmt/v1alpha1" transformer_utils "github.com/nucleuscloud/neosync/worker/pkg/benthos/transformers/utils" @@ -95,10 +94,3 @@ func generateInternationalPhoneNumber(randomizer rng.Rand, minValue, maxValue in return fmt.Sprintf("+%d", val), nil } - -func validateE164(p string) bool { - if len(p) >= 10 && len(p) <= 15 && strings.Contains(p, "+") { - return true - } - return false -}