Skip to content

Commit

Permalink
chore: fixes linting errors #525 (#526)
Browse files Browse the repository at this point in the history
* chore: fixes linting errors #525

* chore: adds tools to devcontainer #525
  • Loading branch information
srinandan authored Aug 21, 2024
1 parent 7a9d858 commit e96358f
Show file tree
Hide file tree
Showing 352 changed files with 331 additions and 789 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ RUN go install github.com/google/addlicense@latest

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

RUN go install mvdan.cc/gofumpt@latest

RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.2

RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
RUN sudo apt update
RUN sudo apt install -y goreleaser curl jq
Expand Down
11 changes: 5 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,21 @@ run:
deadline: 20m
issues-exit-code: 1
tests: false
skip-dirs:
exclude-dirs:
- cicd
- docs
- test
- third-party

output:
format: tab
formats: tab
print-issued-lines: true
print-linter-name: true

linters-settings:
errcheck:
check-type-assertions: false
check-blank: false
govet:
check-shadowing: true
golint:
min-confidence: 0.8
gofmt:
Expand Down Expand Up @@ -71,8 +69,9 @@ linters-settings:

linters:
enable:
- govet
- errcheck
- exportloopref
# - copyloopvar
- gocritic
- gofumpt
- revive
Expand Down Expand Up @@ -112,4 +111,4 @@ issues:
text: "shadows declaration"
- linters:
- staticcheck
text: "SA1019:"
text: "SA1019:"
3 changes: 1 addition & 2 deletions cmd/apigeecli/apigeecli.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ package main

import (
"fmt"
"os"

"internal/cmd"
"os"
)

// https://goreleaser.com/cookbooks/using-main.version/?h=ldflags
Expand Down
20 changes: 11 additions & 9 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@
package main

import (
"io"
"log"
"os"
"path/filepath"
"strings"

apiclient "internal/apiclient"
"internal/cmd"
apicategories "internal/cmd/apicategories"
"internal/cmd/apidocs"
"internal/cmd/apis"
"internal/cmd/appgroups"
Expand All @@ -32,10 +24,20 @@ import (
"internal/cmd/developers"
"internal/cmd/keystores"
"internal/cmd/kvm"
products "internal/cmd/products"
"internal/cmd/references"
"internal/cmd/sharedflows"
"internal/cmd/targetservers"
"io"
"log"
"os"
"path/filepath"
"strings"

apiclient "internal/apiclient"

apicategories "internal/cmd/apicategories"

products "internal/cmd/products"

"github.com/spf13/cobra/doc"
)
Expand Down
8 changes: 2 additions & 6 deletions internal/apiclient/bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ import (
"bytes"
"errors"
"fmt"
"internal/clilog"
"internal/cmd/utils"
"net/url"
"os"
"path"
"path/filepath"
"strings"
"sync"

"internal/clilog"
"internal/cmd/utils"
)

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

_, err = zip.NewReader(file, fi.Size())

if err != nil {
clilog.Error.Println("invalid archive format: ", err)
return nil, err
Expand Down Expand Up @@ -92,7 +90,6 @@ func ReadBundle(filename string) error {
}

_, err = zip.NewReader(file, fi.Size())

if err != nil {
clilog.Error.Println("invalid API Proxy Bundle: ", err)
return err
Expand Down Expand Up @@ -153,7 +150,6 @@ func WriteArrayByteArrayToFile(exportFile string, fileAppend bool, payload [][]b
payloadFromArray = append(payloadFromArray, byte(']'))

_, err = f.Write(payloadFromArray)

if err != nil {
clilog.Error.Println("error writing to file: ", err)
return err
Expand Down
3 changes: 1 addition & 2 deletions internal/apiclient/clifile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ package apiclient

import (
"encoding/json"
"internal/clilog"
"os"
"os/user"
"path"
"time"

"internal/clilog"
)

const (
Expand Down
3 changes: 1 addition & 2 deletions internal/apiclient/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/json"
"errors"
"fmt"
"internal/clilog"
"io"
"mime/multipart"
"net/http"
Expand All @@ -29,8 +30,6 @@ import (
"strings"
"time"

"internal/clilog"

"golang.org/x/time/rate"
)

Expand Down
4 changes: 1 addition & 3 deletions internal/apiclient/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"internal/clilog"
"net/url"
"os"
"path"
"regexp"
"strings"

"internal/clilog"
)

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

_, err = HttpClient(u.String(), payload)

if err != nil {
clilog.Error.Println(err)
return err
Expand Down
3 changes: 1 addition & 2 deletions internal/apiclient/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ package apiclient

import (
"fmt"
"internal/clilog"
"os"
"sync"

"internal/clilog"
)

// baseURL is the Apigee control plane endpoint
Expand Down
3 changes: 1 addition & 2 deletions internal/apiclient/shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
package apiclient

import (
"testing"

"internal/clilog"
"testing"
)

func TestInit(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/apiclient/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/pem"
"errors"
"fmt"
"internal/clilog"
"io"
"net/http"
"net/url"
Expand All @@ -30,8 +31,6 @@ import (
"strings"
"time"

"internal/clilog"

"github.com/lestrrat-go/jwx/v2/jwa"
"github.com/lestrrat-go/jwx/v2/jwt"
"golang.org/x/oauth2/google"
Expand Down
9 changes: 5 additions & 4 deletions internal/bundlegen/generateapiv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ import (
"bytes"
"errors"
"fmt"
"internal/apiclient"
"internal/bundlegen/policies"
"internal/bundlegen/proxies"
"internal/clilog"
"io"
"net/url"
"os"
"path/filepath"
"regexp"
"strings"

"internal/apiclient"
apiproxy "internal/bundlegen/apiproxydef"
"internal/bundlegen/policies"
"internal/bundlegen/proxies"

targets "internal/bundlegen/targets"
"internal/clilog"

"github.com/pb33f/libopenapi"
validator "github.com/pb33f/libopenapi-validator"
Expand Down
3 changes: 1 addition & 2 deletions internal/bundlegen/generateapiv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ package bundlegen

import (
"fmt"
"internal/client/clienttest"
"os"
"path"
"regexp"
"testing"

"internal/client/clienttest"
)

var cliPath = os.Getenv("APIGEECLI_PATH")
Expand Down
3 changes: 2 additions & 1 deletion internal/bundlegen/generategql.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ package bundlegen

import (
"fmt"
"internal/bundlegen/proxies"
"net/url"

apiproxy "internal/bundlegen/apiproxydef"
"internal/bundlegen/proxies"

targets "internal/bundlegen/targets"
)

Expand Down
15 changes: 6 additions & 9 deletions internal/bundlegen/generateswag.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ package bundlegen
import (
"encoding/json"
"fmt"
"internal/apiclient"
"internal/bundlegen/policies"
"internal/bundlegen/proxies"
"internal/bundlegen/targets"
"internal/clilog"
"internal/cmd/utils"
"net/url"
"os"
"path"
Expand All @@ -25,16 +31,7 @@ import (
"strconv"
"strings"

"internal/apiclient"

"internal/clilog"

apiproxy "internal/bundlegen/apiproxydef"
"internal/bundlegen/policies"
"internal/bundlegen/proxies"
"internal/bundlegen/targets"

"internal/cmd/utils"

"github.com/getkin/kin-openapi/openapi2"
"github.com/ghodss/yaml"
Expand Down
3 changes: 1 addition & 2 deletions internal/bundlegen/generateswag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ package bundlegen

import (
"fmt"
"internal/client/clienttest"
"path"
"testing"

"internal/client/clienttest"
)

var swagSpecNames = []string{
Expand Down
10 changes: 5 additions & 5 deletions internal/bundlegen/proxybundle/proxybundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import (
"context"
"errors"
"fmt"
"internal/apiclient"
"internal/bundlegen"
"internal/bundlegen/targets"
"internal/clilog"
"io"
"net/http"
"net/url"
Expand All @@ -28,16 +32,12 @@ import (
"regexp"
"strings"

"internal/apiclient"
"internal/clilog"

"internal/bundlegen"
genapi "internal/bundlegen"
apiproxy "internal/bundlegen/apiproxydef"
policies "internal/bundlegen/policies"
proxies "internal/bundlegen/proxies"
sf "internal/bundlegen/sharedflowdef"
"internal/bundlegen/targets"

target "internal/bundlegen/targets"

"github.com/google/go-github/github"
Expand Down
5 changes: 2 additions & 3 deletions internal/bundlegen/proxybundle/proxybundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
package proxybundle

import (
"internal/bundlegen"
"internal/client/clienttest"
"os"
"path"
"regexp"
"testing"

"internal/bundlegen"
"internal/client/clienttest"
)

var specName = "petstore-v3.1.yaml"
Expand Down
8 changes: 3 additions & 5 deletions internal/client/apicategories/apicategories.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@ import (
"encoding/json"
"errors"
"fmt"
"internal/apiclient"
"internal/client/sites"
"internal/clilog"
"io"
"net/url"
"os"
"path"
"strings"

"internal/apiclient"

"internal/client/sites"
"internal/clilog"

"github.com/thedevsaddam/gojsonq"
)

Expand Down
Loading

0 comments on commit e96358f

Please sign in to comment.