nolint

package module
v0.0.0-...-d8eaba5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2022 License: MIT Imports: 4 Imported by: 0

README

nolint

pkg.go.dev

nolint is an analyzer which provides a reporter which ignores diagnostics with nolint comment.

query GetA() {
    a {
	name # nolint: ignore it
    }
}

How to use

nolint.Analyzer can be set to Requires field of an analyzer. (*nolint.Reporters).New creates a reporter which ignore diagnostics with nolint comment. The reporter can be set to (*gqlanalysis.Pass).Report field.

var Analyzer = &gqlanalysis.Analyzer{
	Name: "mylint",
	Doc:  "mylint",
	Requires: []*gqlanalysis.Analyzer{
		nolint.Analyzer,
	},
	Run: func(pass *gqlanalysis.Pass) (interface{}, error) {
		pass.Report = pass.ResultOf[nolint.Analyzer].(*nolint.Reporters).New(pass)

		for _, q := range pass.Queries {
			for _, f := range q.Fragments {
				for _, s := range f.SelectionSet {
					field, _ := s.(*ast.Field)
					if field != nil {
						pass.Reportf(field.Position, "NG")
					}
				}
			}
		}

		return nil, nil
	},
}

Author

Appify Technologies, Inc.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &gqlanalysis.Analyzer{
	Name:       "nolint",
	Doc:        doc,
	Run:        run,
	ResultType: reflect.TypeOf((*Reporters)(nil)),
}

Analyzer provides reporters which report diagnostic which is not related with any nolint comments.

var Analyzer = &gqlanalysis.Analyzer{
	Name: "mylinter",
	Doc:  "document",
	Requires: []*gqlanalysis.Analyzer{
		nolint.Analyzer,
	},
	Run: func(pass *gqlanalysis.Pass) (interface{}, error) {
		pass.Report = pass.ResultOf[nolint.Analyzer].(*nolint.Reporters).New(pass)

		return nil, nil
	},
}

Functions

func Version

func Version() string

Version returns version of nolint.

Types

type Reporters

type Reporters struct {
}

Reporters creates a reporter which reports diagnostic which is not related with any nolint comments.

func (*Reporters) New

func (rs *Reporters) New(pass *gqlanalysis.Pass) func(*gqlanalysis.Diagnostic)

New creates a reporter which reports diagnostic which is not related with any nolint comments.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL