Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plscheck

Externalized versions of gopls internal analyzers from golang.org/x/tools/gopls/internal/analysis.

Purpose

This package allows you to run gopls analyzers in CI pipelines and other tooling outside of gopls itself. The analyzers in gopls are normally only available within the language server, but this package makes them available as standalone checkers.

Versioning

Tags in this repository always match upstream gopls releases. For example, v0.20.0 in this repository corresponds to gopls/v0.20.0 in golang.org/x/tools.

All dependencies (golang.org/x/tools and golang.org/x/tools/gopls) are pinned to the same version to ensure consistency.

Available Analyzers

  • deprecated - checks for usage of deprecated identifiers
  • embeddirective - validates //go:embed directives
  • errorsastypeshadow - reports shadowing of errors.AsType results in if/else chains
  • fillreturns - suggests fixes for incomplete return statements
  • infertypeargs - suggests removing unnecessary type arguments
  • maprange - suggests using maps.Keys/Values/All for map iteration
  • nonewvars - detects := assignments that don't introduce new variables
  • noresultvalues - checks for return statements with unexpected result values
  • recursiveiter - detects recursive iterator patterns that may cause issues
  • simplifycompositelit - simplifies composite literal types
  • simplifyrange - simplifies range statement expressions
  • simplifyslice - simplifies slice expressions
  • unusedfunc - finds unused functions
  • unusedparams - finds unused function parameters
  • unusedvariable - finds unused variables
  • writestring - detects inefficient string concatenation in WriteString calls
  • yield - checks yield function calls in iterator functions

As of v0.23.0 the modernize suite is no longer copied here: upstream promoted it to golang.org/x/tools/go/analysis/passes/modernize, so import it from there.

Usage

# Install
go install lesiw.io/plscheck/cmd/plscheck@latest

# Run all analyzers
plscheck ./...

# Run specific analyzers
plscheck -unusedparams -unusedvariable ./...

Limitations

Some gopls analyzers (fillstruct, fillswitch) are tightly coupled with gopls internals and are not included as they don't export standalone analyzers suitable for command-line use.

About

Package plscheck externalizes gopls analyzers.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages