Git Product home page Git Product logo

deadcode's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

deadcode's Issues

Warn on unused parameter on exported functions

The current snippet gives warning warning: some is unused.

package p

import "fmt"

func some(s string, n int) {
    fmt.Println(s)
    // n is unused
}

However, if the function is exported, then there is no warning.

No warning:

package p

import "fmt"

func Some(s string, n int) {
    fmt.Println(s)
    // n is unused
}

support golang package formats

thanks for ripping this out.

go-style package wildcards would be nice.

$ deadcode ./...
deadcode: not a directory: ./...

In my abundant free time, I'll try to make a PR.

regards,

n

Wrong line numbers reported breaking nolint

If you have an unused constant which is tagged with // nolint: deadcode a warning is still generated

package main
  
import (
        "fmt"
)

const (
        Valid   = iota
        Invalid // nolint: deadcode
        Another
)

func SetState(s int) {
        switch s {
        case Valid:
                fmt.Println("valid")
        default:
                fmt.Println("unknown state %v", s)
        }
}
gometalinter.v1 --disable-all --enable deadcode --debug .
DEBUG: PATH=/data/go/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin:/usr/local/go/bin:/data/go/bin:/data/go/bin
DEBUG: GOPATH=/data/go
DEBUG: GOBIN=/data/go/bin
DEBUG: linting path .
DEBUG: linting with deadcode: deadcode {path} (on .)
DEBUG: executing /data/go/bin/deadcode ["."]
DEBUG: warning: deadcode . returned exit status 2
DEBUG: deadcode hits 2: ^deadcode: (?P<path>.*?\.go):(?P<line>\d+):(?P<col>\d+):\s*(?P<message>.*)$
DEBUG: nolint: parsing job.go for directives
DEBUG: deadcode linter took 11.886236ms
DEBUG: nolint: parsing job.go took 226.93µs
job.go:7:1:warning: Invalid is unused (deadcode)
job.go:12:1:warning: SetState is unused (deadcode)
DEBUG: total elapsed time 22.532206ms

Ignore the fact that SetState is unused, that's just a side effect of the simplified example.

The issue is caused by the fact that deadcode is reporting the issue for line 7 when in fact it should report line 9.

false positive

deadcode
deadcode: oauth_helpers.go:70:1: validateJWS is unused

grep validateJWS *
oauth_helpers.go:// validateJWS gets the access token
oauth_helpers.go:func validateJWS(accessToken string) []byte {
test_cases_test.go: claims := unmarshalJWT(validateJWS(access))
test_cases_test.go: claims := unmarshalJWT(validateJWS(string(validateJWE(access))))

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.