Skip to content

Commit 9c222aa

Browse files
committed
🔨 Versions bumpup
* Upgraded golanglint-ci version and removed deprecated linters + Upgraded go version Signed-off-by: kaynetik <aleksandar@nesovic.dev>
1 parent 94ad09f commit 9c222aa

11 files changed

+41
-52
lines changed

.github/workflows/golangci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ jobs:
1010
- name: golangci-lint
1111
uses: golangci/golangci-lint-action@v2
1212
with:
13-
version: v1.36
13+
version: v1.49

.golangci.yml

-10
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@ linters-settings:
88
- style
99
goimports:
1010
local-prefixes: github.com/golangci/golangci-lint
11-
golint:
12-
min-confidence: 0
1311
govet:
1412
check-shadowing: true
15-
maligned:
16-
suggest-new: true
1713
misspell:
1814
locale: US
1915
nakedret:
@@ -25,7 +21,6 @@ linters:
2521
disable-all: true
2622
enable:
2723
- bodyclose
28-
- deadcode
2924
- depguard
3025
- dogsled
3126
- dupl
@@ -40,30 +35,25 @@ linters:
4035
- godot
4136
- gofmt
4237
- goimports
43-
- golint
4438
- gomnd
4539
- gomodguard
4640
- goprintffuncname
4741
- gosec
4842
- gosimple
4943
- govet
5044
- ineffassign
51-
- interfacer
5245
- lll
53-
- maligned
5446
- misspell
5547
- nakedret
5648
- nestif
5749
- prealloc
5850
- rowserrcheck
5951
- staticcheck
60-
- structcheck
6152
- stylecheck
6253
- typecheck
6354
- unconvert
6455
- unparam
6556
- unused
66-
- varcheck
6757
- whitespace
6858
- wsl
6959
- asciicheck

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
lint:
22
gofumpt -w -s ./..
3-
golint ./...
43
golangci-lint run --fix
54

65
test:

annotations.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ type (
2626
// MapAnnotationsInPath scanIn is relevant from initiator calling it.
2727
//
2828
// It accepts the path in which to scan for annotations within Go files.
29-
func (o *OAS) MapAnnotationsInPath(scanIn string, conf ...configAnnotation) error {
29+
func (oas *OAS) MapAnnotationsInPath(scanIn string, conf ...configAnnotation) error {
3030
filesInPath, err := scanForChangesInPath(scanIn, getWDFn(conf), walkFilepath)
3131
if err != nil {
3232
return fmt.Errorf(" :%w", err)
3333
}
3434

3535
for _, file := range filesInPath {
36-
err = o.mapDocAnnotations(file)
36+
err = oas.mapDocAnnotations(file)
3737
if err != nil {
3838
return fmt.Errorf(" :%w", err)
3939
}
@@ -103,8 +103,8 @@ func walkFilepath(pathToTraverse string, walker walkerFn) ([]string, error) {
103103
return files, nil
104104
}
105105

106-
func (o *OAS) mapDocAnnotations(path string) error {
107-
if o == nil {
106+
func (oas *OAS) mapDocAnnotations(path string) error {
107+
if oas == nil {
108108
return errors.New("pointer to OASHandlers can not be nil")
109109
}
110110

@@ -119,7 +119,7 @@ func (o *OAS) mapDocAnnotations(path string) error {
119119
line := 1
120120

121121
for scanner.Scan() {
122-
mapIfLineContainsOASTag(scanner.Text(), o)
122+
mapIfLineContainsOASTag(scanner.Text(), oas)
123123
line++
124124
}
125125

build.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ func getPathFromFirstElement(cbs []ConfigBuilder) string {
3535
// BuildDocs marshals the OAS struct to YAML and saves it to the chosen output file.
3636
//
3737
// Returns an error if there is any.
38-
func (o *OAS) BuildDocs(conf ...ConfigBuilder) error {
39-
o.initCallStackForRoutes()
38+
func (oas *OAS) BuildDocs(conf ...ConfigBuilder) error {
39+
oas.initCallStackForRoutes()
4040

41-
yml, err := o.marshalToYAML()
41+
yml, err := oas.marshalToYAML()
4242
if err != nil {
4343
return fmt.Errorf("marshaling issue occurred: %w", err)
4444
}
@@ -54,8 +54,8 @@ func (o *OAS) BuildDocs(conf ...ConfigBuilder) error {
5454
// BuildStream marshals the OAS struct to YAML and writes it to a stream.
5555
//
5656
// Returns an error if there is any.
57-
func (o *OAS) BuildStream(w io.Writer) error {
58-
yml, err := o.marshalToYAML()
57+
func (oas *OAS) BuildStream(w io.Writer) error {
58+
yml, err := oas.marshalToYAML()
5959
if err != nil {
6060
return fmt.Errorf("marshaling issue occurred: %w", err)
6161
}
@@ -127,17 +127,17 @@ type hybridOAS struct {
127127
Components componentsMap `yaml:"components"`
128128
}
129129

130-
func (o *OAS) transformToHybridOAS() hybridOAS {
130+
func (oas *OAS) transformToHybridOAS() hybridOAS {
131131
ho := hybridOAS{}
132132

133-
ho.OpenAPI = o.OASVersion
134-
ho.Info = o.Info
135-
ho.ExternalDocs = o.ExternalDocs
136-
ho.Servers = o.Servers
137-
ho.Tags = o.Tags
133+
ho.OpenAPI = oas.OASVersion
134+
ho.Info = oas.Info
135+
ho.ExternalDocs = oas.ExternalDocs
136+
ho.Servers = oas.Servers
137+
ho.Tags = oas.Tags
138138

139-
ho.Paths = makeAllPathsMap(&o.Paths)
140-
ho.Components = makeComponentsMap(&o.Components)
139+
ho.Paths = makeAllPathsMap(&oas.Paths)
140+
ho.Components = makeComponentsMap(&oas.Components)
141141

142142
return ho
143143
}

caller.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
const routePostfix = "Route"
99

1010
// Call is used init registered functions that already exist in the *OAS, and return results if there are any.
11-
func (o *OAS) Call(name string, params ...interface{}) (result []reflect.Value) {
12-
f := reflect.ValueOf(o.RegisteredRoutes[name])
11+
func (oas *OAS) Call(name string, params ...interface{}) (result []reflect.Value) {
12+
f := reflect.ValueOf(oas.RegisteredRoutes[name])
1313

1414
in := make([]reflect.Value, len(params))
1515
for k, param := range params {
@@ -21,8 +21,8 @@ func (o *OAS) Call(name string, params ...interface{}) (result []reflect.Value)
2121
return result
2222
}
2323

24-
func (o *OAS) initCallStackForRoutes() {
25-
for oasPathIndex := range o.Paths {
26-
o.Call(o.Paths[oasPathIndex].HandlerFuncName+routePostfix, oasPathIndex, o)
24+
func (oas *OAS) initCallStackForRoutes() {
25+
for oasPathIndex := range oas.Paths {
26+
oas.Call(oas.Paths[oasPathIndex].HandlerFuncName+routePostfix, oasPathIndex, oas)
2727
}
2828
}

go.mod

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module github.com/go-oas/docs
22

3-
go 1.15
3+
go 1.18
4+
5+
require gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
46

57
require (
68
github.com/kr/pretty v0.1.0 // indirect
79
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
8-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
910
)

routing.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,27 @@ type (
1919
// AttachRoutes if used for attaching pre-defined API documentation routes.
2020
//
2121
// fns param is a slice of functions that satisfy RouteFn signature.
22-
func (o *OAS) AttachRoutes(fns []RouteFn) {
22+
func (oas *OAS) AttachRoutes(fns []RouteFn) {
2323
for _, fn := range fns {
2424
fnDeclaration := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()
2525
fields := strings.SplitAfter(fnDeclaration, ".")
2626
fnName := fields[len(fields)-1]
2727

28-
o.RegisteredRoutes[fnName] = fn
28+
oas.RegisteredRoutes[fnName] = fn
2929
}
3030
}
3131

3232
// GetRegisteredRoutes returns a map of registered RouteFn functions - in layman terms "routes".
33-
func (o *OAS) GetRegisteredRoutes() RegRoutes {
34-
return o.RegisteredRoutes
33+
func (oas *OAS) GetRegisteredRoutes() RegRoutes {
34+
return oas.RegisteredRoutes
3535
}
3636

3737
// GetPathByIndex returns ptr to Path structure, by its index in the parent struct of OAS.
38-
func (o *OAS) GetPathByIndex(index int) *Path {
39-
return &o.Paths[index]
38+
func (oas *OAS) GetPathByIndex(index int) *Path {
39+
return &oas.Paths[index]
4040
}
4141

4242
// AddRoute is used for add API documentation routes.
43-
//
44-
func (o *OAS) AddRoute(path Path) {
45-
o.Paths = append(o.Paths, path)
43+
func (oas *OAS) AddRoute(path Path) {
44+
oas.Paths = append(oas.Paths, path)
4645
}

routing_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ func TestQuickUnitAttachRoutes(t *testing.T) {
270270
}
271271

272272
func TestOAS_AddRoute(t *testing.T) {
273-
274273
var (
275274
respose200 = Response{Code: 200, Description: "Ok"}
276275
respose404 = Response{Code: 404, Description: "Not Found"}

server.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const (
2121
)
2222

2323
// ConfigSwaggerUI represents a structure which will be used to pass required configuration params to
24-
// the ServeSwaggerUI func.
24+
//
25+
// the ServeSwaggerUI func.
2526
type ConfigSwaggerUI struct {
2627
Route string
2728
Port string

setters.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package docs
22

33
// SetOASVersion sets the OAS version, by casting string to OASVersion type.
4-
func (o *OAS) SetOASVersion(ver string) {
5-
o.OASVersion = OASVersion(ver)
4+
func (oas *OAS) SetOASVersion(ver string) {
5+
oas.OASVersion = OASVersion(ver)
66
}
77

88
// GetInfo returns pointer to the Info struct.
9-
func (o *OAS) GetInfo() *Info {
10-
return &o.Info
9+
func (oas *OAS) GetInfo() *Info {
10+
return &oas.Info
1111
}
1212

1313
// SetContact setts the contact on the Info struct.

0 commit comments

Comments
 (0)