Skip to content

WIP: refactor: refactor funcs with generics #1895

WIP: refactor: refactor funcs with generics

WIP: refactor: refactor funcs with generics #1895

GitHub Actions / golangci failed Apr 10, 2024 in 1s

reviewdog [golangci] report

reported by reviewdog 🐶

Findings (19)

internal/template/method.go|30 col 1| exported: comment on exported const GetInstanceMethod should be of the form "GetInstanceMethod ..." (revive)
field/export.go|40 col 53| unexported-return: exported func NewField returns unexported type field.genericsField[database/sql/driver.Valuer], which can be annoying to use (revive)
field/time.go|81 col 1| exported: exported method Time.Year should have comment or be unexported (revive)
generics.go|199 col 9| indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
generics.go|208 col 9| indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
generics.go|217 col 9| indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
generics.go|13 col 6| exported: exported type IGenericsDo should have comment or be unexported (revive)
generics.go|74 col 6| exported: exported type GenericsDo should have comment or be unexported (revive)
generics.go|79 col 1| exported: exported method GenericsDo.Debug should have comment or be unexported (revive)
generics.go|83 col 1| exported: exported method GenericsDo.WithContext should have comment or be unexported (revive)
generics.go|87 col 1| exported: exported method GenericsDo.ReadDB should have comment or be unexported (revive)
generics.go|91 col 1| exported: exported method GenericsDo.WriteDB should have comment or be unexported (revive)
generics.go|95 col 1| exported: exported method GenericsDo.Session should have comment or be unexported (revive)
generics.go|99 col 1| exported: exported method GenericsDo.Clauses should have comment or be unexported (revive)
generics.go|103 col 1| exported: exported method GenericsDo.Returning should have comment or be unexported (revive)
generics.go|107 col 1| exported: exported method GenericsDo.Not should have comment or be unexported (revive)
generics.go|111 col 1| exported: exported method GenericsDo.Or should have comment or be unexported (revive)
generics.go|115 col 1| exported: exported method GenericsDo.Select should have comment or be unexported (revive)
generics.go|119 col 1| exported: exported method GenericsDo.Where should have comment or be unexported (revive)

Filtered Findings (47)

internal/utils/common.go|1 col 1| package-comments: should have a package comment (revive)
internal/template/method.go|1 col 1| package-comments: should have a package comment (revive)
internal/parser/method.go|12 col 1| exported: exported function DefaultMethodTableName should have comment or be unexported (revive)
internal/parser/export.go|1 col 1| package-comments: should have a package comment (revive)
field/expr.go|127 col 23| Error return value of builder.WriteString is not checked (errcheck)
field/serializer.go|22 col 13| Error return value of db.AddError is not checked (errcheck)
do.go|263 col 18| Error return value of stmt.WriteByte is not checked (errcheck)
do.go|294 col 18| Error return value of stmt.WriteByte is not checked (errcheck)
field/serializer.go|21 col 33| context-keys-type: should not use basic type string as key in context.WithValue (revive)
field/tag.go|11 col 2| exported: exported const TagKeyGorm should have comment (or a comment on this block) or be unexported (revive)
field/tag.go|14 col 2| exported: comment on exported const TagKeyGormColumn should be of the form "TagKeyGormColumn ..." (revive)
field/tag.go|43 col 6| exported: exported type TagBuilder should have comment or be unexported (revive)
field/tag.go|47 col 6| exported: exported type Tag should have comment or be unexported (revive)
field/tag.go|49 col 1| exported: exported method Tag.Set should have comment or be unexported (revive)
field/tag.go|54 col 1| exported: exported method Tag.Remove should have comment or be unexported (revive)
field/tag.go|59 col 1| exported: exported method Tag.Build should have comment or be unexported (revive)
field/tag.go|87 col 6| exported: exported type GormTag should have comment or be unexported (revive)
field/tag.go|89 col 1| exported: exported method GormTag.Append should have comment or be unexported (revive)
field/tag.go|98 col 1| exported: exported method GormTag.Set should have comment or be unexported (revive)
field/tag.go|103 col 1| exported: exported method GormTag.Remove should have comment or be unexported (revive)
field/tag.go|108 col 1| exported: exported method GormTag.Build should have comment or be unexported (revive)
field/assign_attr.go|13 col 6| exported: exported type IValues should have comment or be unexported (revive)
field/tag.go|12 col 2| var-naming: const TagKeyJson should be TagKeyJSON (revive)
field/export.go|339 col 118| unused-parameter: parameter 'relations' seems to be unused, consider removing or renaming it as _ (revive)
field/assign_attr.go|115 col 1| exported: exported function Attrs should have comment or be unexported (revive)
field/association.go|240 col 1| exported: exported method RelateConfig.GetTag should have comment or be unexported (revive)
field/expr.go|57 col 6| exported: exported type IColumnName should have comment or be unexported (revive)
internal/generate/table.go|74 col 37| unused-parameter: parameter 'schemaName' seems to be unused, consider removing or renaming it as _ (revive)
internal/generate/table.go|86 col 35| unused-parameter: parameter 'schemaName' seems to be unused, consider removing or renaming it as _ (revive)
internal/generate/query.go|17 col 6| exported: exported type FieldParser should have comment or be unexported (revive)
do_options.go|9 col 6| exported: exported type DOConfig should have comment or be unexported (revive)
do_options.go|21 col 36| unused-parameter: parameter 'db' seems to be unused, consider removing or renaming it as _ (revive)
field_options.go|23 col 2| exported: exported var FieldModify should have comment or be unexported (revive)
field_options.go|266 col 2| exported: exported var DefaultMethodTableWithNamer should have comment or be unexported (revive)
do.go|851 col 1| exported: exported method DO.AddError should have comment or be unexported (revive)
internal/generate/section.go|563 col 108| (*Section).checkSQLVar - result err is always nil (unparam)
field/expr.go|422 col 15| func expr.field is unused (unused)
internal/model/options.go|10 col 5| var defaultSchemaNameOpt is unused (unused)
internal/generate/interface.go|446 col 27| func (*InterfaceMethod).checkSQLVarByParams is unused (unused)
internal/generate/interface.go|487 col 27| func (*InterfaceMethod).isParamExist is unused (unused)
internal/generate/section.go|694 col 2| field suffix is unused (unused)
field_options.go|20 col 5| var ns is unused (unused)
generator.go|303 col 4| shadow: declaration of "err" shadows declaration at line 287 (govet)
generator.go|490 col 4| shadow: declaration of "err" shadows declaration at line 470 (govet)
internal/model/base.go|204 col 10| SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)
internal/model/base.go|206 col 10| SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)
internal/model/base.go|208 col 10| SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)

Annotations

Check failure on line 30 in internal/template/method.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] internal/template/method.go#L30

exported: comment on exported const GetInstanceMethod should be of the form "GetInstanceMethod ..." (revive)
Raw output
internal/template/method.go:30:1: exported: comment on exported const GetInstanceMethod should be of the form "GetInstanceMethod ..." (revive)
// GetInstance method
^

Check failure on line 40 in field/export.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] field/export.go#L40

unexported-return: exported func NewField returns unexported type field.genericsField[database/sql/driver.Valuer], which can be annoying to use (revive)
Raw output
field/export.go:40:53: unexported-return: exported func NewField returns unexported type field.genericsField[database/sql/driver.Valuer], which can be annoying to use (revive)
func NewField(table, column string, opts ...Option) genericsField[driver.Valuer] {
                                                    ^

Check failure on line 81 in field/time.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] field/time.go#L81

exported: exported method Time.Year should have comment or be unexported (revive)
Raw output
field/time.go:81:1: exported: exported method Time.Year should have comment or be unexported (revive)
func (field Time) Year() Number[int] {
^

Check failure on line 199 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L199

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
Raw output
generics.go:199:9: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
	} else {
		return result.(E), nil
	}

Check failure on line 208 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L208

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
Raw output
generics.go:208:9: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
	} else {
		return result.(E), nil
	}

Check failure on line 217 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L217

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
Raw output
generics.go:217:9: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) (revive)
	} else {
		return result.(E), nil
	}

Check failure on line 13 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L13

exported: exported type IGenericsDo should have comment or be unexported (revive)
Raw output
generics.go:13:6: exported: exported type IGenericsDo should have comment or be unexported (revive)
type IGenericsDo[T any, E any] interface {
     ^

Check failure on line 74 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L74

exported: exported type GenericsDo should have comment or be unexported (revive)
Raw output
generics.go:74:6: exported: exported type GenericsDo should have comment or be unexported (revive)
type GenericsDo[T IGenericsDo[T, E], E any] struct {
     ^

Check failure on line 79 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L79

exported: exported method GenericsDo.Debug should have comment or be unexported (revive)
Raw output
generics.go:79:1: exported: exported method GenericsDo.Debug should have comment or be unexported (revive)
func (b GenericsDo[T, E]) Debug() T {
^

Check failure on line 83 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L83

exported: exported method GenericsDo.WithContext should have comment or be unexported (revive)
Raw output
generics.go:83:1: exported: exported method GenericsDo.WithContext should have comment or be unexported (revive)
func (b GenericsDo[T, E]) WithContext(ctx context.Context) T {
^

Check failure on line 87 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L87

exported: exported method GenericsDo.ReadDB should have comment or be unexported (revive)
Raw output
generics.go:87:1: exported: exported method GenericsDo.ReadDB should have comment or be unexported (revive)
func (b GenericsDo[T, E]) ReadDB() T {
^

Check failure on line 91 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L91

exported: exported method GenericsDo.WriteDB should have comment or be unexported (revive)
Raw output
generics.go:91:1: exported: exported method GenericsDo.WriteDB should have comment or be unexported (revive)
func (b GenericsDo[T, E]) WriteDB() T {
^

Check failure on line 95 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L95

exported: exported method GenericsDo.Session should have comment or be unexported (revive)
Raw output
generics.go:95:1: exported: exported method GenericsDo.Session should have comment or be unexported (revive)
func (b GenericsDo[T, E]) Session(config *gorm.Session) T {
^

Check failure on line 99 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L99

exported: exported method GenericsDo.Clauses should have comment or be unexported (revive)
Raw output
generics.go:99:1: exported: exported method GenericsDo.Clauses should have comment or be unexported (revive)
func (b GenericsDo[T, E]) Clauses(conds ...clause.Expression) T {
^

Check failure on line 103 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L103

exported: exported method GenericsDo.Returning should have comment or be unexported (revive)
Raw output
generics.go:103:1: exported: exported method GenericsDo.Returning should have comment or be unexported (revive)
func (b GenericsDo[T, E]) Returning(value interface{}, columns ...string) T {
^

Check failure on line 107 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L107

exported: exported method GenericsDo.Not should have comment or be unexported (revive)
Raw output
generics.go:107:1: exported: exported method GenericsDo.Not should have comment or be unexported (revive)
func (b GenericsDo[T, E]) Not(conds ...Condition) T {
^

Check failure on line 111 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L111

exported: exported method GenericsDo.Or should have comment or be unexported (revive)
Raw output
generics.go:111:1: exported: exported method GenericsDo.Or should have comment or be unexported (revive)
func (b GenericsDo[T, E]) Or(conds ...Condition) T {
^

Check failure on line 115 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L115

exported: exported method GenericsDo.Select should have comment or be unexported (revive)
Raw output
generics.go:115:1: exported: exported method GenericsDo.Select should have comment or be unexported (revive)
func (b GenericsDo[T, E]) Select(conds ...field.Expr) T {
^

Check failure on line 119 in generics.go

See this annotation in the file changed.

@github-actions github-actions / golangci

[golangci] generics.go#L119

exported: exported method GenericsDo.Where should have comment or be unexported (revive)
Raw output
generics.go:119:1: exported: exported method GenericsDo.Where should have comment or be unexported (revive)
func (b GenericsDo[T, E]) Where(conds ...Condition) T {
^