Skip to content

Commit

Permalink
Added some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Jakop committed Feb 11, 2015
1 parent 2b8feba commit 2719c5b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

/**
* <p>
* Detector to check the corect usage of <code>@VisibleForTesting</code>.
* Detector to check the correct usage of <code>@VisibleForTesting</code>. This annotation should be allowed only
* for methods and fields with package-private visibility, because the only valid usecase is promoting a private
* method or field to package-private for the use in a unit test in the same package.
* </p>
*
* @author tolina GmbH
Expand Down Expand Up @@ -48,7 +50,7 @@ public boolean apply(final AnnotationEntry input) {
}
};

public MisuseOfVisibleForTestingDetector(final BugReporter reporter) {
public MisuseOfVisibleForTestingDetector(final @Nonnull BugReporter reporter) {
this.reporter = reporter;
}

Expand All @@ -74,7 +76,7 @@ private boolean hasVisibleForTestingAnnotation(final FieldOrMethod obj) {
public void visit(final Method obj) {
if (hasVisibleForTestingAnnotation(obj) && !isPackageVisible(obj)) {
final BugInstance bug = bugInstanceSupplier.get();
bug.addClassAndMethod(this); //.addSourceLine(this);
bug.addClassAndMethod(this);
reporter.reportBug(bug);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/meta/messages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@

<Detector class="jp.co.worksap.oss.findbugs.guava.MisuseOfVisibleForTestingDetector">
<Details>
This detector will find all methods and fields annotated with @VisibleForTesting whose visibility is not
package-private.
</Details>
</Detector>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void test() throws Exception {
when(bugInstanceSupplier.get()).thenAnswer(new Answer<BugInstanceStub>() {
public BugInstanceStub answer(org.mockito.invocation.InvocationOnMock invocation) throws Throwable {
return new BugInstanceStub();
};
}
});

// visit all fields
Expand Down

0 comments on commit 2719c5b

Please sign in to comment.