unusedparam

command module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2019 License: MIT Imports: 5 Imported by: 0

README

unusedparam

A Go static analysis tool to inspect go source files and detect unused function parameters.

It doesn't require to preload Go packages, all you need is files and no need to make preparations anything such as code generation, downloading modules. It allows you to run in CI environments easily even if your project depends on a complicated build system.

Installation

go get -u github.com/nakabonne/unusedparam

Usage

usage: unusedparam [flags] [files ...]
  -json Emit json format
  -v	Verbose output

You can see how it does by using files underneath /testdata.

unusedparam ./testdata/*
Using as a library

With Check(), you can handle the structured issues in your code.

import (
	"github.com/k0kubun/pp"
	"github.com/nakabonne/unusedparam/pkg/unusedparam"
)

func main() {
	issues, _ := unusedparam.Check("./testdata/assign_stmt.go")
	pp.Println(issues)
}

structured issues:

[]*unusedparam.Issue{
  &unusedparam.Issue{
    Text: "m is unused in _",
    Pos:  token.Position{
      Filename: "./testdata/assign_stmt.go",
      Offset:   176,
      Line:     18,
      Column:   11,
    },
  },
  &unusedparam.Issue{
    Text: "n is unused in _",
    Pos:  token.Position{
      Filename: "./testdata/assign_stmt.go",
      Offset:   173,
      Line:     18,
      Column:   8,
    },
  },
}

Inspired by

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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