GithubHelp home page GithubHelp logo

alexkohler / dogsled Goto Github PK

View Code? Open in Web Editor NEW
71.0 4.0 2.0 1.91 MB

dogsled is a Go static analysis tool to find assignments/declarations with too many blank identifiers.

License: MIT License

Go 100.00%

dogsled's Introduction

dogsled Build Status

dogsled is a Go static analysis tool to find assignments/declarations with too many blank identifiers (e.g. x, _, _, _ := f()). Its name was inspired from this reddit post.

Installation

go get -u github.com/alexkohler/dogsled/cmd/dogsled

Usage

Similar to other Go static analysis tools (such as golint, go vet), dogsled can be invoked with one or more filenames, directories, or packages named by its import path. dogsled also supports the ... wildcard. By default, it will search for assignment with more than two blank identifiers.

dogsled [flags] files/directories/packages

Flags

  • -tests (default true) - Include test files in analysis
  • -n (default 2) - Maximum number of blank identifiers allowed in an assignment statement
  • -set_exit_status (default false) - Set exit status to 1 if any issues are found

Example

Some examples from the Go standard library

$ dogsled go/src/...
go/src/crypto/elliptic/elliptic_test.go:553: declaration has 3 blank identifiers: priv, _, _, _ := GenerateKey(p256,go/src/image/names.go:46: declaration has 3 blank identifiers: _, _, _, a := c.C.RGBA()
go/src/image/color/color.go:232: declaration has 3 blank identifiers: _, _, _, a := c.RGBA()
go/src/image/color/color.go:240: declaration has 3 blank identifiers: _, _, _, a := c.RGBA()
go/src/internal/cpu/cpu_x86.go:67: declaration has 3 blank identifiers: maxID, _, _, _ := cpuid(0, 0)
go/src/internal/cpu/cpu_x86.go:100: declaration has 3 blank identifiers: _, ebx7, _, _ := cpuid(7, 0)
go/src/math/big/natconv_test.go:286: declaration has 3 blank identifiers: x, _, _, _ = x.scan(strings.NewReader(pi),go/src/reflect/value.go:172: declaration has 3 blank identifiers: pc, _, _, _ := runtime.Caller(2)
go/src/reflect/makefunc.go:62: declaration has 4 blank identifiers: _, _, _, stack, _ := funcLayout(t, nil)
go/src/reflect/makefunc.go:113: declaration has 4 blank identifiers: _, _, _, stack, _ := funcLayout(funcType, nil)
go/src/runtime/softfloat64.go:309: declaration has 4 blank identifiers: _, _, _, _ = fi, fn, gi, gn
go/src/runtime/symtab_test.go:54: declaration has 3 blank identifiers: _, _, line, _ := runtime.Caller(1)
go/src/syscall/syscall_unix_test.go:182: declaration has 3 blank identifiers: _, oobn, _, _, err := uc.ReadMsgUnixgo/src/time/time.go:498: declaration has 3 blank identifiers: year, _, _, _ := t.date(false)
go/src/time/time.go:504: declaration has 3 blank identifiers: _, month, _, _ := t.date(true)
go/src/time/time.go:510: declaration has 3 blank identifiers: _, _, day, _ := t.date(true)
go/src/time/time.go:624: declaration has 3 blank identifiers: _, _, _, yday := t.date(false)

Contributing

Please open an issue and/or a PR for any features/bugs.

Other static analysis tools

If you've enjoyed dogsled, take a look at my other static anaylsis tools!

  • prealloc - Finds slice declarations that could potentially be preallocated.
  • nakedret - Finds naked returns.
  • identypo - Finds typos in variable names, function names, constants, and more!
  • unimport - Finds unnecessary import aliases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.