checkdeprecated

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

README

check-deprecated

check-deprecated is a Go static analysis tool.

It finds malformed deprecated comments, and finds the use of deprecated function/variable/constant/field

Purpose

We need an analyzer that checks deprecated usage. But as this issue says,

Actually it looks like staticcheck does have an appropriate check (SA1019) but for whatever reason it doesn't seem to work. Might open a separate issue to discuss that.

And I think SA1019 is too strict about the deprecated comments, so that some situations cannot be detected.

We use a very loose detection patterns, you can even customize it.

patterns := []string{"MyDeprecated: "}

// MyDeprecated: don't use it.
func AFunc()  {}

Of course, standard comments are always popular, so this repo also provides an analysis to detect malformed deprecated comments.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MarkDeprecatedCommentAnalyzer = &analysis.Analyzer{
		Name:       "mark_deprecated_comment",
		Doc:        "mark deprecated comment",
		Run:        deprecatedCommentRun,
		Flags:      deprecatedCommentFlags(),
		Requires:   []*analysis.Analyzer{inspect.Analyzer},
		ResultType: reflect.TypeOf(DeprecatedMap{}),
		FactTypes:  []analysis.Fact{&Deprecated{}},
	}
)

Functions

func NewCheckDeprecatedAnalyzer

func NewCheckDeprecatedAnalyzer(patterns ...string) *analysis.Analyzer

func NewCheckDeprecatedCommentAnalyzer

func NewCheckDeprecatedCommentAnalyzer(patterns ...string) *analysis.Analyzer

Types

type Deprecated

type Deprecated struct {
	Message         string
	MalformedHeader string
}

func (*Deprecated) AFact

func (*Deprecated) AFact()

func (*Deprecated) String

func (p *Deprecated) String() string

type DeprecatedMap

type DeprecatedMap map[types.Object]*Deprecated

Jump to

Keyboard shortcuts

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