lints

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 21 Imported by: 0

README

internal/lints

The internal/lints directory stores the code that implements the lint rules.

Documentation

Index

Constants

View Source
const (
	GNO_PKG_PREFIX  = "gno.land/"
	GNO_STD_PACKAGE = "std"
)

Variables

View Source
var RepeatedRegexCompilationAnalyzer = &analysis.Analyzer{
	Name: "repeatedregexcompilation",
	Doc:  "Checks for repeated compilation of the same regex pattern",
	Run:  runRepeatedRegexCompilation,
}

Functions

func DetectConstErrorDeclaration

func DetectConstErrorDeclaration(
	filename string,
	node *ast.File,
	fset *token.FileSet,
	severity tt.Severity,
) ([]tt.Issue, error)

func DetectCycle

func DetectCycle(filename string, node *ast.File, fset *token.FileSet, severity tt.Severity) ([]tt.Issue, error)

func DetectDeferIssues

func DetectDeferIssues(filename string, node *ast.File, fset *token.FileSet, severity tt.Severity) ([]tt.Issue, error)

func DetectDeprecatedFunctions

func DetectDeprecatedFunctions(
	filename string,
	node *ast.File,
	fset *token.FileSet,
	severity tt.Severity,
) ([]tt.Issue, error)

func DetectEarlyReturnOpportunities

func DetectEarlyReturnOpportunities(filename string, node *ast.File, fset *token.FileSet, severity tt.Severity) ([]tt.Issue, error)

DetectEarlyReturnOpportunities detects if-else chains that can be simplified using early returns. This rule considers an else block unnecessary if the if block ends with a return statement. In such cases, the else block can be removed and the code can be flattened to improve readability.

func DetectEmitFormat

func DetectEmitFormat(filename string, node *ast.File, fset *token.FileSet, severity tt.Severity) ([]tt.Issue, error)

func DetectGnoPackageImports

func DetectGnoPackageImports(filename string, severity tt.Severity) ([]tt.Issue, error)

func DetectHighCyclomaticComplexity

func DetectHighCyclomaticComplexity(filename string, threshold int, severity tt.Severity) ([]tt.Issue, error)

func DetectLoopAllocation

func DetectLoopAllocation(filename string, node *ast.File, fset *token.FileSet, severity tt.Severity) ([]tt.Issue, error)

func DetectMissingModPackage

func DetectMissingModPackage(filename string, node *ast.File, fset *token.FileSet, severity tt.Severity) ([]tt.Issue, error)

func DetectRepeatedRegexCompilation

func DetectRepeatedRegexCompilation(filename string, node *ast.File, severity tt.Severity) ([]tt.Issue, error)

func DetectSliceBoundCheck

func DetectSliceBoundCheck(filename string, node *ast.File, fset *token.FileSet, severity tt.Severity) ([]tt.Issue, error)

TODO: Make more precisely.

func DetectUnnecessaryConversions

func DetectUnnecessaryConversions(filename string, node *ast.File, fset *token.FileSet, severity tt.Severity) ([]tt.Issue, error)

func DetectUnnecessarySliceLength

func DetectUnnecessarySliceLength(filename string, node *ast.File, fset *token.FileSet, severity tt.Severity) ([]tt.Issue, error)

func DetectUselessBreak

func DetectUselessBreak(filename string, node *ast.File, fset *token.FileSet, severity tt.Severity) ([]tt.Issue, error)

DetectUselessBreak detects useless break statements in switch or select statements.

func ParseFile

func ParseFile(filename string, content []byte) (*ast.File, *token.FileSet, error)

func RemoveUnnecessaryElse

func RemoveUnnecessaryElse(snippet string) (string, error)

func RunGolangciLint

func RunGolangciLint(filename string, severity tt.Severity) ([]tt.Issue, error)

Types

type DeferChecker

type DeferChecker struct {
	// contains filtered or unexported fields
}

func NewDeferChecker

func NewDeferChecker(filename string, fset *token.FileSet, severity tt.Severity) *DeferChecker

func (*DeferChecker) Check

func (dc *DeferChecker) Check(node *ast.File) []tt.Issue

type Dependencies

type Dependencies map[string]*Dependency

type Dependency

type Dependency struct {
	ImportPath string
	IsGno      bool
	IsUsed     bool
	IsIgnored  bool // aliased as `_`
}

Jump to

Keyboard shortcuts

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