3rf / codecoroner Goto Github PK
View Code? Open in Web Editor NEWtool for detecting unused functions and variables in Go source code
Home Page: http://kyleerf.com
tool for detecting unused functions and variables in Go source code
Home Page: http://kyleerf.com
Since this pkg relies heavily on Google packages with little external usage, it would be nice to vendor things to prevent disasters like the removal of callgraph analysis from the Oracle tool.
Unused variables defined in the signature of a function should not be flagged as unused because those variables names are helpful as documentation even if not referenced in the function body.
For style consistency a method receiver variable might be defined for all methods of a type even for methods where the receiver is not used.
Signaling unused method receivers variables pollutes the output.
Related: #21
anacrolix@Matts-MBP-2:~$ go get -u github.com/3rf/codecoroner
# github.com/3rf/codecoroner/unused
gopath/src/github.com/3rf/codecoroner/unused/funcs.go:89: cannot use pkgs (type []*ssa.Package) as type *ssa.Package in argument to prog.CreateTestMainPackage
gopath/src/github.com/3rf/codecoroner/unused/funcs.go:89: invalid use of ... in call to prog.CreateTestMainPackage
anacrolix@Matts-MBP-2:~$ go version
go version devel +b00b214 Tue Dec 13 03:21:00 2016 +0000 darwin/amd64
We should leverage the token.Position
type to consistently print declaration location for both funcs
and idents
See build #45.1 for Go 1.5
The README doesn't give me any information on why I might choose this tool versus github.com/remyoudompheng/go-misc/deadcode from https://github.com/remyoudompheng/go-misc.
type set f(str string)
str
should not be reported as unused as str
is useful as documentation.
Note: this is a particular subcase of #21.
When using codecoroner it would be useful to use exit code to detect any errors instead of parsing stdout/stderr.
Suggesting to add a non zero exit code if codecoroner found any unused objects.
go get github.com/3rf/codecoroner
work/src/github.com/3rf/codecoroner/unused/idents.go:56: impossible type switch case: kind (type "go/types".Object) cannot have dynamic type *"golang.org/x/tools/go/types".Func (wrong type for Parent method)
have Parent() *"golang.org/x/tools/go/types".Scope
want Parent() *"go/types".Scope
work/src/github.com/3rf/codecoroner/unused/idents.go:79: impossible type switch case: kind (type "go/types".Object) cannot have dynamic type *"golang.org/x/tools/go/types".Func (wrong type for Parent method)
have Parent() *"golang.org/x/tools/go/types".Scope
want Parent() *"go/types".Scope
Hopefully I will get some free time to update this before the end of May 2015. If you're feeling squirrelly, you can get it to compile by checking out an old version of the oracle package.
It'd be great if we can use that tool to then delete those unused functions
Code reachable by tests probably shouldn't be ignored.
Many static analysis tools have ways to explicitly say "don't bother with this" in the code. Is there any way in my code to say "ignore this function please, codecoroner"?
Thanks!
There's a build error when you try to compile the app:
โ go get github.com/3rf/go-unused-funcs
# github.com/3rf/go-unused-funcs/unused
/goprojects/src/github.com/3rf/go-unused-funcs/unused/unused_func_finder.go:91: cannot use serialRes.Callgraph (type []"golang.org/x/tools/oracle/serial".CallGraph) as type []"code.google.com/p/go.tools/oracle/serial".CallGraph in assignment
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.