Skip to content

Commit bd76527

Browse files
committed
More lint fixes that were missed due to VSCode config
1 parent 6b46a63 commit bd76527

File tree

10 files changed

+85
-73
lines changed

10 files changed

+85
-73
lines changed

.golangci.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ linters:
237237
- forbidigo # forbids identifiers
238238
- funlen # tool for detection of long functions
239239
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
240-
- gochecknoglobals # checks that no global variables exist
241240
- gochecknoinits # checks that no init functions are present in Go code
242241
- gochecksumtype # checks exhaustiveness on Go "sum types"
243242
- gocognit # computes and checks the cognitive complexity of functions
@@ -277,7 +276,6 @@ linters:
277276
- tenv # detects using os.Setenv instead of t.Setenv since Go1.17
278277
- testableexamples # checks if examples are testable (have an expected output)
279278
- testifylint # checks usage of github.com/stretchr/testify
280-
- testpackage # makes you use a separate _test package
281279
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
282280
- unconvert # removes unnecessary type conversions
283281
- unparam # reports unused function parameters
@@ -286,6 +284,8 @@ linters:
286284
- whitespace # detects leading and trailing whitespace
287285

288286
## you may want to enable
287+
# - gochecknoglobals # checks that no global variables exist
288+
# - testpackage # makes you use a separate _test package
289289
#- protogetter # reports direct reads from proto message fields when getters should be used
290290
#- nestif # reports deeply nested if statements
291291
#- decorder # checks declaration order and count of types, constants, variables and functions
@@ -338,7 +338,7 @@ issues:
338338
linters: [godot]
339339
- source: "//noinspection"
340340
linters: [gocritic]
341-
- path: "_test\\.go"
341+
- path: "(_test\\.go)"
342342
linters:
343343
- bodyclose
344344
- dupl
@@ -347,3 +347,6 @@ issues:
347347
- gosec
348348
- noctx
349349
- wrapcheck
350+
351+
exclude-dirs:
352+
- test

data/enum.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package data
22

33
// Enum is the data out to render Enums in a file
44
// Enums that nested inside messages will be pulled out to the top level
5-
// Because the way it works in typescript
5+
// Because the way it works in typescript.
66
type Enum struct {
77
// Name will be the package level unique name
88
// Nested names will concat with their parent messages so that it will remain unique

data/file.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import (
99
"github.com/iancoleman/strcase"
1010
)
1111

12-
// File store the information about rendering a file
12+
// File store the information about rendering a file.
1313
type File struct {
14-
// Enums is a list of enums to render, due to the fact that there cannot be any enum defined nested in the class in Typescript.
14+
// Enums is a list of enums to render, due to the fact that there cannot be
15+
// any enum defined nested in the class in Typescript.
1516
// All Enums will be rendered at the top level
1617
Enums []*Enum
1718
// Messages represents top level messages inside the file.
@@ -24,9 +25,12 @@ type File struct {
2425
Name string
2526
// TSFileName is the name of the output file
2627
TSFileName string
27-
// PackageNonScalarType stores the type inside the same packages within the file, which will be used to figure out external dependencies inside the same package (different files)
28+
// PackageNonScalarType stores the type inside the same packages within the
29+
// file, which will be used to figure out external dependencies inside the
30+
// same package (different files)
2831
PackageNonScalarType []Type
29-
// Dependencies is a list of dependencies for the file, which will be rendered at the top of the file as import statements
32+
// Dependencies is a list of dependencies for the file, which will be rendered
33+
// at the top of the file as import statements
3034
dependencies []*Dependency
3135
}
3236

@@ -50,7 +54,7 @@ func (f *File) Dependencies() []*Dependency {
5054
return out
5155
}
5256

53-
// NeedsOneOfSupport indicates the file needs one of support type utilities
57+
// NeedsOneOfSupport indicates the file needs one of support type utilities.
5458
func (f *File) NeedsOneOfSupport() bool {
5559
for _, m := range f.Messages {
5660
if m.HasOneOfFields() {
@@ -71,7 +75,7 @@ func (f *File) NeedsStructPBSupport() bool {
7175
return false
7276
}
7377

74-
// TrackPackageNonScalarType tracks the supplied non scala type in the same package
78+
// TrackPackageNonScalarType tracks the supplied non scala type in the same package.
7579
func (f *File) TrackPackageNonScalarType(t Type) {
7680
isNonScalarType := strings.Index(t.GetType().Type, ".") == 0
7781
if isNonScalarType {
@@ -83,7 +87,7 @@ func (f *File) IsEmpty() bool {
8387
return len(f.Enums) == 0 && len(f.Messages) == 0 && len(f.Services) == 0
8488
}
8589

86-
// NewFile returns an initialised new file
90+
// NewFile returns an initialised new file.
8791
func NewFile() *File {
8892
return &File{
8993
dependencies: make([]*Dependency, 0),
@@ -92,7 +96,6 @@ func NewFile() *File {
9296
Services: make([]*Service, 0),
9397
ExternalDependingTypes: make([]string, 0),
9498
}
95-
9699
}
97100

98101
// Dependency stores the information about dependencies.
@@ -117,23 +120,23 @@ func GetModuleName(packageName, fileName string) string {
117120
return strcase.ToCamel(packageName) + strcase.ToCamel(name)
118121
}
119122

120-
// GetTSFileName gets the typescript filename out of the proto file name
123+
// GetTSFileName gets the typescript filename out of the proto file name.
121124
func GetTSFileName(fileName string) string {
122125
baseName := filepath.Base(fileName)
123126
ext := filepath.Ext(fileName)
124127
name := baseName[0 : len(baseName)-len(ext)]
125128
return path.Join(filepath.Dir(fileName), name+".pb.ts")
126129
}
127130

128-
// Type is an interface to get type out of field and method arguments
131+
// Type is an interface to get type out of field and method arguments.
129132
type Type interface {
130133
// GetType returns some information of the type to aid the rendering
131134
GetType() *TypeInfo
132135
// SetExternal changes the external field inside the data structure
133136
SetExternal(bool)
134137
}
135138

136-
// TypeInfo stores some common type information for rendering
139+
// TypeInfo stores some common type information for rendering.
137140
type TypeInfo struct {
138141
// Type
139142
Type string

data/message.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package data
22

3-
// Message stores the rendering information about message
3+
// Message stores the rendering information about message.
44
type Message struct {
55
// Nested shows whether this message is a nested message and needs to be exported
66
Nested bool
77
// Name is the name of the Message
88
Name string
99
// Message has been marked as deprecated
1010
IsDeprecated bool
11-
//FQType is the fully qualified type name for the message itself
11+
// FQType is the fully qualified type name for the message itself
1212
FQType string
1313
// Enums is a list of NestedEnums inside
1414
Enums []*NestedEnum
@@ -20,9 +20,11 @@ type Message struct {
2020
OptionalFields []*Field
2121
// Message is the nested messages defined inside the message
2222
Messages []*Message
23-
// OneOfFieldsGroups is the grouped list of one of fields with same index. so that renderer can render the clearing of other fields on set.
23+
// OneOfFieldsGroups is the grouped list of one of fields with same index. so
24+
// that renderer can render the clearing of other fields on set.
2425
OneOfFieldsGroups map[int32][]*Field
25-
// OneOfFieldNames is the names of one of fields with same index. so that renderer can render the clearing of other fields on set.
26+
// OneOfFieldNames is the names of one of fields with same index. so that
27+
// renderer can render the clearing of other fields on set.
2628
OneOfFieldsNames map[int32]string
2729
}
2830

@@ -47,7 +49,7 @@ func (m *Message) HasStructPBFields() bool {
4749
return false
4850
}
4951

50-
// NewMessage initialises and return a Message
52+
// NewMessage initialises and return a Message.
5153
func NewMessage() *Message {
5254
return &Message{
5355
Nested: false,
@@ -60,7 +62,7 @@ func NewMessage() *Message {
6062
}
6163
}
6264

63-
// NestedEnum stores the information of enums defined inside a message
65+
// NestedEnum stores the information of enums defined inside a message.
6466
type NestedEnum struct {
6567
// Name of the Enum inside the class, which will be identical to the name
6668
// defined inside the message
@@ -75,7 +77,7 @@ type NestedEnum struct {
7577
Type string
7678
}
7779

78-
// Field stores the information about a field inside message
80+
// Field stores the information about a field inside message.
7981
type Field struct {
8082
Name string
8183
// Type will be similar to NestedEnum.Type. Where scalar type and types inside
@@ -100,7 +102,7 @@ type Field struct {
100102
IsRepeated bool
101103
}
102104

103-
// GetType returns some information of the type to aid the rendering
105+
// GetType returns some information of the type to aid the rendering.
104106
func (f *Field) GetType() *TypeInfo {
105107
return &TypeInfo{
106108
Type: f.Type,
@@ -110,20 +112,20 @@ func (f *Field) GetType() *TypeInfo {
110112
}
111113
}
112114

113-
// SetExternal mutate the IsExternal attribute
115+
// SetExternal mutate the IsExternal attribute.
114116
func (f *Field) SetExternal(external bool) {
115117
f.IsExternal = external
116118
}
117119

118-
// MapEntryType is the generic entry type for both key and value
120+
// MapEntryType is the generic entry type for both key and value.
119121
type MapEntryType struct {
120122
// Type of the map entry
121123
Type string
122124
// IsExternal indicates the field typeis external to its own package
123125
IsExternal bool
124126
}
125127

126-
// GetType returns the type information for the type entry
128+
// GetType returns the type information for the type entry.
127129
func (m *MapEntryType) GetType() *TypeInfo {
128130
return &TypeInfo{
129131
Type: m.Type,
@@ -132,7 +134,7 @@ func (m *MapEntryType) GetType() *TypeInfo {
132134
}
133135
}
134136

135-
// SetExternal mutate the IsExternal attribute inside
137+
// SetExternal mutate the IsExternal attribute inside.
136138
func (m *MapEntryType) SetExternal(external bool) {
137139
m.IsExternal = external
138140
}

data/service.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package data
22

3-
// Service is the data representation of Service in proto
3+
// Service is the data representation of Service in proto.
44
type Service struct {
55
// Name is the name of the Service
66
Name string
77
// Methods is a list of methods data
88
Methods []*Method
99
}
1010

11-
// Services is an alias of Service array
11+
// Services is an alias of Service array.
1212
type Services []*Service
1313

14-
// HasServerStreamingMethod indicates whether there is server side streaming calls inside any of the services
14+
// HasServerStreamingMethod indicates whether there is server side streaming calls inside any of the services.
1515
func (s Services) HasServerStreamingMethod() bool {
1616
for _, service := range s {
1717
for _, method := range service.Methods {
@@ -23,7 +23,7 @@ func (s Services) HasServerStreamingMethod() bool {
2323
return false
2424
}
2525

26-
// HasUnaryCallMethod indicates whether there is unary methods inside any of the services
26+
// HasUnaryCallMethod indicates whether there is unary methods inside any of the services.
2727
func (s Services) HasUnaryCallMethod() bool {
2828
for _, service := range s {
2929
for _, method := range service.Methods {
@@ -35,20 +35,20 @@ func (s Services) HasUnaryCallMethod() bool {
3535
return false
3636
}
3737

38-
// RequiresFetchModule returns whether the given services needs fetch module support
38+
// RequiresFetchModule returns whether the given services needs fetch module support.
3939
func (s Services) RequiresFetchModule() bool {
4040
hasServices := len(s) > 0
4141
return hasServices && (s.HasUnaryCallMethod() || s.HasServerStreamingMethod())
4242
}
4343

44-
// NewService returns an initialised service
44+
// NewService returns an initialised service.
4545
func NewService() *Service {
4646
return &Service{
4747
Methods: make([]*Method, 0),
4848
}
4949
}
5050

51-
// Method represents the rpc calls in protobuf service
51+
// Method represents the rpc calls in protobuf service.
5252
type Method struct {
5353
// Name is the name of the method
5454
Name string
@@ -68,7 +68,7 @@ type Method struct {
6868
HTTPRequestBody *string
6969
}
7070

71-
// MethodArgument stores the type information about method argument
71+
// MethodArgument stores the type information about method argument.
7272
type MethodArgument struct {
7373
// Type is the type of the argument
7474
Type string
@@ -78,7 +78,7 @@ type MethodArgument struct {
7878
IsRepeated bool
7979
}
8080

81-
// GetType returns some information of the type to aid the rendering
81+
// GetType returns some information of the type to aid the rendering.
8282
func (m *MethodArgument) GetType() *TypeInfo {
8383
return &TypeInfo{
8484
Type: m.Type,
@@ -87,7 +87,7 @@ func (m *MethodArgument) GetType() *TypeInfo {
8787
}
8888
}
8989

90-
// SetExternal mutates the IsExternal attribute of the type
90+
// SetExternal mutates the IsExternal attribute of the type.
9191
func (m *MethodArgument) SetExternal(external bool) {
9292
m.IsExternal = external
9393
}

0 commit comments

Comments
 (0)