Skip to content

Commit e96358f

Browse files
authored
chore: fixes linting errors #525 (#526)
* chore: fixes linting errors #525 * chore: adds tools to devcontainer #525
1 parent 7a9d858 commit e96358f

File tree

352 files changed

+331
-789
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

352 files changed

+331
-789
lines changed

.devcontainer/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ RUN go install github.com/google/addlicense@latest
2222

2323
RUN go install github.com/google/go-licenses@latest
2424

25+
RUN go install mvdan.cc/gofumpt@latest
26+
27+
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.2
28+
2529
RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
2630
RUN sudo apt update
2731
RUN sudo apt install -y goreleaser curl jq

.golangci.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,21 @@ run:
1717
deadline: 20m
1818
issues-exit-code: 1
1919
tests: false
20-
skip-dirs:
20+
exclude-dirs:
2121
- cicd
2222
- docs
2323
- test
2424
- third-party
2525

2626
output:
27-
format: tab
27+
formats: tab
2828
print-issued-lines: true
2929
print-linter-name: true
3030

3131
linters-settings:
3232
errcheck:
3333
check-type-assertions: false
3434
check-blank: false
35-
govet:
36-
check-shadowing: true
3735
golint:
3836
min-confidence: 0.8
3937
gofmt:
@@ -71,8 +69,9 @@ linters-settings:
7169

7270
linters:
7371
enable:
72+
- govet
7473
- errcheck
75-
- exportloopref
74+
# - copyloopvar
7675
- gocritic
7776
- gofumpt
7877
- revive
@@ -112,4 +111,4 @@ issues:
112111
text: "shadows declaration"
113112
- linters:
114113
- staticcheck
115-
text: "SA1019:"
114+
text: "SA1019:"

cmd/apigeecli/apigeecli.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ package main
1616

1717
import (
1818
"fmt"
19-
"os"
20-
2119
"internal/cmd"
20+
"os"
2221
)
2322

2423
// https://goreleaser.com/cookbooks/using-main.version/?h=ldflags

docs/docs.go

+11-9
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@
1515
package main
1616

1717
import (
18-
"io"
19-
"log"
20-
"os"
21-
"path/filepath"
22-
"strings"
23-
24-
apiclient "internal/apiclient"
2518
"internal/cmd"
26-
apicategories "internal/cmd/apicategories"
2719
"internal/cmd/apidocs"
2820
"internal/cmd/apis"
2921
"internal/cmd/appgroups"
@@ -32,10 +24,20 @@ import (
3224
"internal/cmd/developers"
3325
"internal/cmd/keystores"
3426
"internal/cmd/kvm"
35-
products "internal/cmd/products"
3627
"internal/cmd/references"
3728
"internal/cmd/sharedflows"
3829
"internal/cmd/targetservers"
30+
"io"
31+
"log"
32+
"os"
33+
"path/filepath"
34+
"strings"
35+
36+
apiclient "internal/apiclient"
37+
38+
apicategories "internal/cmd/apicategories"
39+
40+
products "internal/cmd/products"
3941

4042
"github.com/spf13/cobra/doc"
4143
)

internal/apiclient/bundles.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ import (
1919
"bytes"
2020
"errors"
2121
"fmt"
22+
"internal/clilog"
23+
"internal/cmd/utils"
2224
"net/url"
2325
"os"
2426
"path"
2527
"path/filepath"
2628
"strings"
2729
"sync"
28-
29-
"internal/clilog"
30-
"internal/cmd/utils"
3130
)
3231

3332
// entityPayloadList stores list of entities
@@ -55,7 +54,6 @@ func ReadArchive(filename string) ([]byte, error) {
5554
}
5655

5756
_, err = zip.NewReader(file, fi.Size())
58-
5957
if err != nil {
6058
clilog.Error.Println("invalid archive format: ", err)
6159
return nil, err
@@ -92,7 +90,6 @@ func ReadBundle(filename string) error {
9290
}
9391

9492
_, err = zip.NewReader(file, fi.Size())
95-
9693
if err != nil {
9794
clilog.Error.Println("invalid API Proxy Bundle: ", err)
9895
return err
@@ -153,7 +150,6 @@ func WriteArrayByteArrayToFile(exportFile string, fileAppend bool, payload [][]b
153150
payloadFromArray = append(payloadFromArray, byte(']'))
154151

155152
_, err = f.Write(payloadFromArray)
156-
157153
if err != nil {
158154
clilog.Error.Println("error writing to file: ", err)
159155
return err

internal/apiclient/clifile.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ package apiclient
1616

1717
import (
1818
"encoding/json"
19+
"internal/clilog"
1920
"os"
2021
"os/user"
2122
"path"
2223
"time"
23-
24-
"internal/clilog"
2524
)
2625

2726
const (

internal/apiclient/httpclient.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"encoding/json"
2121
"errors"
2222
"fmt"
23+
"internal/clilog"
2324
"io"
2425
"mime/multipart"
2526
"net/http"
@@ -29,8 +30,6 @@ import (
2930
"strings"
3031
"time"
3132

32-
"internal/clilog"
33-
3433
"golang.org/x/time/rate"
3534
)
3635

internal/apiclient/iam.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ import (
1818
"encoding/base64"
1919
"encoding/json"
2020
"fmt"
21+
"internal/clilog"
2122
"net/url"
2223
"os"
2324
"path"
2425
"regexp"
2526
"strings"
26-
27-
"internal/clilog"
2827
)
2928

3029
// CrmURL is the endpoint for cloud resource manager
@@ -126,7 +125,6 @@ func CreateIAMServiceAccount(name string, iamRole string) (err error) {
126125
payload := "{" + strings.Join(iamPayload, ",") + "}"
127126

128127
_, err = HttpClient(u.String(), payload)
129-
130128
if err != nil {
131129
clilog.Error.Println(err)
132130
return err

internal/apiclient/options.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ package apiclient
1616

1717
import (
1818
"fmt"
19+
"internal/clilog"
1920
"os"
2021
"sync"
21-
22-
"internal/clilog"
2322
)
2423

2524
// baseURL is the Apigee control plane endpoint

internal/apiclient/shared_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
package apiclient
1616

1717
import (
18-
"testing"
19-
2018
"internal/clilog"
19+
"testing"
2120
)
2221

2322
func TestInit(t *testing.T) {

internal/apiclient/token.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"encoding/pem"
2222
"errors"
2323
"fmt"
24+
"internal/clilog"
2425
"io"
2526
"net/http"
2627
"net/url"
@@ -30,8 +31,6 @@ import (
3031
"strings"
3132
"time"
3233

33-
"internal/clilog"
34-
3534
"github.com/lestrrat-go/jwx/v2/jwa"
3635
"github.com/lestrrat-go/jwx/v2/jwt"
3736
"golang.org/x/oauth2/google"

internal/bundlegen/generateapiv2.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@ import (
1818
"bytes"
1919
"errors"
2020
"fmt"
21+
"internal/apiclient"
22+
"internal/bundlegen/policies"
23+
"internal/bundlegen/proxies"
24+
"internal/clilog"
2125
"io"
2226
"net/url"
2327
"os"
2428
"path/filepath"
2529
"regexp"
2630
"strings"
2731

28-
"internal/apiclient"
2932
apiproxy "internal/bundlegen/apiproxydef"
30-
"internal/bundlegen/policies"
31-
"internal/bundlegen/proxies"
33+
3234
targets "internal/bundlegen/targets"
33-
"internal/clilog"
3435

3536
"github.com/pb33f/libopenapi"
3637
validator "github.com/pb33f/libopenapi-validator"

internal/bundlegen/generateapiv2_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ package bundlegen
1616

1717
import (
1818
"fmt"
19+
"internal/client/clienttest"
1920
"os"
2021
"path"
2122
"regexp"
2223
"testing"
23-
24-
"internal/client/clienttest"
2524
)
2625

2726
var cliPath = os.Getenv("APIGEECLI_PATH")

internal/bundlegen/generategql.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ package bundlegen
1616

1717
import (
1818
"fmt"
19+
"internal/bundlegen/proxies"
1920
"net/url"
2021

2122
apiproxy "internal/bundlegen/apiproxydef"
22-
"internal/bundlegen/proxies"
23+
2324
targets "internal/bundlegen/targets"
2425
)
2526

internal/bundlegen/generateswag.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ package bundlegen
1717
import (
1818
"encoding/json"
1919
"fmt"
20+
"internal/apiclient"
21+
"internal/bundlegen/policies"
22+
"internal/bundlegen/proxies"
23+
"internal/bundlegen/targets"
24+
"internal/clilog"
25+
"internal/cmd/utils"
2026
"net/url"
2127
"os"
2228
"path"
@@ -25,16 +31,7 @@ import (
2531
"strconv"
2632
"strings"
2733

28-
"internal/apiclient"
29-
30-
"internal/clilog"
31-
3234
apiproxy "internal/bundlegen/apiproxydef"
33-
"internal/bundlegen/policies"
34-
"internal/bundlegen/proxies"
35-
"internal/bundlegen/targets"
36-
37-
"internal/cmd/utils"
3835

3936
"github.com/getkin/kin-openapi/openapi2"
4037
"github.com/ghodss/yaml"

internal/bundlegen/generateswag_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ package bundlegen
1616

1717
import (
1818
"fmt"
19+
"internal/client/clienttest"
1920
"path"
2021
"testing"
21-
22-
"internal/client/clienttest"
2322
)
2423

2524
var swagSpecNames = []string{

internal/bundlegen/proxybundle/proxybundle.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ import (
1919
"context"
2020
"errors"
2121
"fmt"
22+
"internal/apiclient"
23+
"internal/bundlegen"
24+
"internal/bundlegen/targets"
25+
"internal/clilog"
2226
"io"
2327
"net/http"
2428
"net/url"
@@ -28,16 +32,12 @@ import (
2832
"regexp"
2933
"strings"
3034

31-
"internal/apiclient"
32-
"internal/clilog"
33-
34-
"internal/bundlegen"
3535
genapi "internal/bundlegen"
3636
apiproxy "internal/bundlegen/apiproxydef"
3737
policies "internal/bundlegen/policies"
3838
proxies "internal/bundlegen/proxies"
3939
sf "internal/bundlegen/sharedflowdef"
40-
"internal/bundlegen/targets"
40+
4141
target "internal/bundlegen/targets"
4242

4343
"github.com/google/go-github/github"

internal/bundlegen/proxybundle/proxybundle_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@
1515
package proxybundle
1616

1717
import (
18+
"internal/bundlegen"
19+
"internal/client/clienttest"
1820
"os"
1921
"path"
2022
"regexp"
2123
"testing"
22-
23-
"internal/bundlegen"
24-
"internal/client/clienttest"
2524
)
2625

2726
var specName = "petstore-v3.1.yaml"

internal/client/apicategories/apicategories.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,15 @@ import (
1818
"encoding/json"
1919
"errors"
2020
"fmt"
21+
"internal/apiclient"
22+
"internal/client/sites"
23+
"internal/clilog"
2124
"io"
2225
"net/url"
2326
"os"
2427
"path"
2528
"strings"
2629

27-
"internal/apiclient"
28-
29-
"internal/client/sites"
30-
"internal/clilog"
31-
3230
"github.com/thedevsaddam/gojsonq"
3331
)
3432

0 commit comments

Comments
 (0)