Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't falsely report Test methods in main package #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Dieterbe
Copy link

@Dieterbe Dieterbe commented Dec 27, 2017

i'm new to all the go loader / ast stuff and this tool, but this seems to fix #13

@caarlos0
Copy link

caarlos0 commented Jun 6, 2018

ping @remyoudompheng

@ryboe
Copy link

ryboe commented Jun 17, 2018

This is a serious bug. Thanks for the PR @Dieterbe! I hope this will be reviewed soon.

if !used[obj] && (pkg.Pkg.Name() == "main" || !ast.IsExported(name)) {
_, isSig := obj.Type().(*types.Signature)
pos := ctx.pos(obj.Pos())
isTestMethod := isSig && strings.HasPrefix(obj.Name(), "Test") && strings.HasSuffix(pos.Filename, "_test.go")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, need to check Example and Benchmark prefixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

deadcode: TestXXX is unused ?
4 participants