Description
Proposal Details
Some analyzers need to customize their behavior based on the context in which the code is running, e.g. to restrict certain (inefficient) APIs to only be used in tests.
At the moment analyzers have no way to determine if the file they are analyzing is only used in tests. One way of achieving this today is to check if the file ends in _test.go
. This works for the most part. However it fails for libraries that are not tests themselves but can only be used in tests. Some build systems can enforce this. See bazels testonly
attribute.
One way to support this would be similar to the version support based on go/types.Info.FileVersions
which is a map from *ast.File
to the version string. A map in the analysis.Pass
from *ast.File
to a bollean that says if the file is only used in tests or not would solve this problem.
Note: it is not a property of the package to be analyzed but the individual files because when analyzing a test package it consists of test files and the actual package source files.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status