Skip to content

Commit f577918

Browse files
atoulmemx-psi
andauthored
[chore] return by value (#741)
Co-authored-by: Pablo Baeyens <[email protected]>
1 parent 690165e commit f577918

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

checkapi/internal/ast.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ func ExprToString(expr ast.Expr) string {
8787
}
8888
}
8989

90-
func Read(folder string, ignoredFunctions []string, excludedFiles []string) (*API, error) {
90+
func Read(folder string, ignoredFunctions []string, excludedFiles []string) (API, error) {
9191
result := &API{}
9292
set := token.NewFileSet()
9393
packs, err := parser.ParseDir(set, folder, nil, 0)
9494
if err != nil {
95-
return nil, err
95+
return API{}, err
9696
}
9797

9898
for _, pack := range packs {
@@ -101,7 +101,7 @@ func Read(folder string, ignoredFunctions []string, excludedFiles []string) (*AP
101101
for _, exclusionPattern := range excludedFiles {
102102
ok, err2 := filepath.Match(exclusionPattern, filepath.Base(path))
103103
if err2 != nil {
104-
return nil, err2
104+
return API{}, err2
105105
}
106106
if ok {
107107
continue FILE
@@ -111,7 +111,7 @@ func Read(folder string, ignoredFunctions []string, excludedFiles []string) (*AP
111111
}
112112
}
113113

114-
return result, nil
114+
return *result, nil
115115
}
116116

117117
func readFile(ignoredFunctions []string, f *ast.File, result *API) {
@@ -136,7 +136,7 @@ func readFile(ignoredFunctions []string, f *ast.File, result *API) {
136136
}
137137
}
138138
}
139-
result.Structs = append(result.Structs, &Apistruct{
139+
result.Structs = append(result.Structs, Apistruct{
140140
Name: t.Name.String(),
141141
Fields: fieldNames,
142142
})
@@ -182,7 +182,7 @@ func readFile(ignoredFunctions []string, f *ast.File, result *API) {
182182
typeParams = append(typeParams, ExprToString(r.Type))
183183
}
184184
}
185-
f := &Function{
185+
f := Function{
186186
Name: fn.Name.Name,
187187
Receiver: receiver,
188188
Params: params,

checkapi/internal/config.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ type Apistruct struct {
1717
}
1818

1919
type API struct {
20-
Values []string `json:"values,omitempty"`
21-
Structs []*Apistruct `json:"structs,omitempty"`
22-
Functions []*Function `json:"functions,omitempty"`
20+
Values []string `json:"values,omitempty"`
21+
Structs []Apistruct `json:"structs,omitempty"`
22+
Functions []Function `json:"functions,omitempty"`
2323
}
2424

2525
type FunctionDescription struct {

checkapi/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func walkFolder(cfg internal.Config, folder string, componentType string) error
143143
return errors.Join(errs...)
144144
}
145145

146-
func checkStructDisallowUnkeyedLiteral(cfg internal.Config, s *internal.Apistruct, folder string) error {
146+
func checkStructDisallowUnkeyedLiteral(cfg internal.Config, s internal.Apistruct, folder string) error {
147147
if !unicode.IsUpper(rune(s.Name[0])) {
148148
return nil
149149
}

0 commit comments

Comments
 (0)