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

Analyzer does not have a warning for @VisibleForTesting #28273

Closed
sebastianmalysa-wf opened this issue Jan 5, 2017 · 3 comments
Closed

Analyzer does not have a warning for @VisibleForTesting #28273

sebastianmalysa-wf opened this issue Jan 5, 2017 · 3 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@sebastianmalysa-wf
Copy link

The documentation for the VisibleForTesting annotation suggests that the analyzer will provide feedback if "the annotation is associated with a declaration not in the 'lib' folder of a package or the declaration is referenced outside of its defining library or a library which is in the 'test' folder of the defining package (

sdk/pkg/meta/lib/meta.dart

Lines 123 to 133 in 37890f9

/// Used to annotate an instance member that was made public so that it could be
/// overridden but that is not intended to be referenced from outside the
/// defining library.
///
/// Tools, such as the analyzer, can provide feedback if
///
/// * the annotation is associated with a declaration other than a public
/// instance member in a class, or
/// * the member is referenced outside of the defining library.
const _VisibleForOverriding visibleForOverriding =
const _VisibleForOverriding();
)." The analyzer does not seem to provide any feedback around this annotation. Currently the annotation is great for documentation purposes, but it would be even better if the analyzer caught the circumstances above and provided a warning. Are there any plans to do this?

@bwilkerson bwilkerson added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug labels Jan 5, 2017
@bwilkerson
Copy link
Member

Yes, we plan to provide this warning, but I don't know how quickly we'll get to it.

@sebastianmalysa-wf
Copy link
Author

Thank you for the quick response, knowing that it's in the pipeline is very helpful.

@srawlins srawlins self-assigned this Dec 7, 2017
whesse pushed a commit that referenced this issue Dec 14, 2017
In particular, enforce that a method annotated with @VisibleForTesting can only
be referenced from within the declaring library, or within a file that has
"/test" in its path. This allows @VisibleForTesting methods to be accessed from
test files, or files in "/testing" folders, etc.

Bug: #28273
Change-Id: I3c19f73be330c49face7e3203879742d514bca74
Reviewed-on: https://dart-review.googlesource.com/27201
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
@srawlins
Copy link
Member

Fixed with 1462909.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants