Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update golangci linter #1612

Merged
merged 2 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .github/workflows/check-linting

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with: { go-version: 1.17 }
- run: go mod download
- run: .github/workflows/check-fmt
- run: .github/workflows/check-linting
- run: .github/workflows/check-generate
- name: golangci-lint
uses: golangci/golangci-lint-action@v2

coverage:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ linters:
- gosimple
- govet
- ineffassign
- interfacer
- misspell
- nakedret
- prealloc
- staticcheck
- structcheck
- typecheck
- unconvert
- unused
- varcheck
Expand Down
2 changes: 1 addition & 1 deletion client/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (p *Client) WebsocketWithPayload(query string, initPayload map[string]inter
}

srv := httptest.NewServer(p.h)
host := strings.Replace(srv.URL, "http://", "ws://", -1)
host := strings.ReplaceAll(srv.URL, "http://", "ws://")
c, _, err := websocket.DefaultDialer.Dial(host+r.URL.Path, r.Header)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion codegen/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type FieldArgument struct {
Value interface{} // value set in Data
}

//ImplDirectives get not Builtin and location ARGUMENT_DEFINITION directive
// ImplDirectives get not Builtin and location ARGUMENT_DEFINITION directive
func (f *FieldArgument) ImplDirectives() []*Directive {
d := make([]*Directive, 0)
for i := range f.Directives {
Expand Down
2 changes: 1 addition & 1 deletion codegen/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Config struct {
Packages *code.Packages `yaml:"-"`
Schema *ast.Schema `yaml:"-"`

// Deprecated use Federation instead. Will be removed next release
// Deprecated: use Federation instead. Will be removed next release
Federated bool `yaml:"federated,omitempty"`
}

Expand Down
4 changes: 2 additions & 2 deletions codegen/directive.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

type DirectiveList map[string]*Directive

//LocationDirectives filter directives by location
// LocationDirectives filter directives by location
func (dl DirectiveList) LocationDirectives(location string) DirectiveList {
return locationDirectives(dl, ast.DirectiveLocation(location))
}
Expand All @@ -23,7 +23,7 @@ type Directive struct {
Builtin bool
}

//IsLocation check location directive
// IsLocation check location directive
func (d *Directive) IsLocation(location ...ast.DirectiveLocation) bool {
for _, l := range d.Locations {
for _, a := range location {
Expand Down
4 changes: 2 additions & 2 deletions codegen/templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ var commonInitialisms = map[string]bool{
}

func rawQuote(s string) string {
return "`" + strings.Replace(s, "`", "`+\"`\"+`", -1) + "`"
return "`" + strings.ReplaceAll(s, "`", "`+\"`\"+`") + "`"
}

func notNil(field string, data interface{}) bool {
Expand Down Expand Up @@ -548,7 +548,7 @@ func Dump(val interface{}) string {
}

func prefixLines(prefix, s string) string {
return prefix + strings.Replace(s, "\n", "\n"+prefix, -1)
return prefix + strings.ReplaceAll(s, "\n", "\n"+prefix)
}

func resolveName(name string, skip int) string {
Expand Down
4 changes: 2 additions & 2 deletions codegen/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func findGoInterface(def types.Type) (*types.Interface, error) {
}

func equalFieldName(source, target string) bool {
source = strings.Replace(source, "_", "", -1)
target = strings.Replace(target, "_", "", -1)
source = strings.ReplaceAll(source, "_", "")
target = strings.ReplaceAll(target, "_", "")
return strings.EqualFold(source, target)
}
2 changes: 1 addition & 1 deletion graphql/handler/transport/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestWebsocketInitFunc(t *testing.T) {
}

func wsConnect(url string) *websocket.Conn {
c, resp, err := websocket.DefaultDialer.Dial(strings.Replace(url, "http://", "ws://", -1), nil)
c, resp, err := websocket.DefaultDialer.Dial(strings.ReplaceAll(url, "http://", "ws://"), nil)
if err != nil {
panic(err)
}
Expand Down
1 change: 0 additions & 1 deletion internal/code/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

// CompatibleTypes isnt a strict comparison, it allows for pointer differences
func CompatibleTypes(expected types.Type, actual types.Type) error {
//fmt.Println("Comparing ", expected.String(), actual.String())

// Special case to deal with pointer mismatches
{
Expand Down
2 changes: 1 addition & 1 deletion internal/imports/prune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestPrune(t *testing.T) {

b, err := Prune("testdata/unused.go", mustReadFile("testdata/unused.go"), &code.Packages{})
require.NoError(t, err)
require.Equal(t, strings.Replace(string(mustReadFile("testdata/unused.expected.go")), "\r\n", "\n", -1), string(b))
require.Equal(t, strings.ReplaceAll(string(mustReadFile("testdata/unused.expected.go")), "\r\n", "\n"), string(b))
}

func mustReadFile(filename string) []byte {
Expand Down
2 changes: 1 addition & 1 deletion internal/rewrite/rewriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestRewriter(t *testing.T) {
m.Field++

// trailing comment
`, strings.Replace(body, "\r\n", "\n", -1))
`, strings.ReplaceAll(body, "\r\n", "\n"))

imps := r.ExistingImports("testdata/example.go")
require.Len(t, imps, 2)
Expand Down
2 changes: 1 addition & 1 deletion plugin/resolvergen/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ type ResolverBuild struct {

type File struct {
// These are separated because the type definition of the resolver object may live in a different file from the
//resolver method implementations, for example when extending a type in a different graphql schema file
// resolver method implementations, for example when extending a type in a different graphql schema file
Objects []*codegen.Object
Resolvers []*Resolver
imports []rewrite.Import
Expand Down