Issue #1555: Decrease visibility of fields and methods in test code
Fixes some `WeakerAccess` inspection violations. Description: >This inspection reports all fields, methods or classes, found in the specified inspection scope, that may have their access modifier narrowed down.
This commit is contained in:
parent
ef834b210c
commit
94f9754acb
|
|
@ -32,7 +32,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration;
|
|||
public abstract class BaseCheckTestSupport
|
||||
{
|
||||
/** A brief logger that only display info about errors */
|
||||
protected static class BriefLogger
|
||||
static class BriefLogger
|
||||
extends DefaultLogger
|
||||
{
|
||||
public BriefLogger(OutputStream out) throws UnsupportedEncodingException
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class LocalizedMessageTest {
|
|||
classloader, true);
|
||||
}
|
||||
|
||||
public static URL getMockUrl(final URLConnection connection) throws IOException {
|
||||
private static URL getMockUrl(final URLConnection connection) throws IOException {
|
||||
final URLStreamHandler handler = new URLStreamHandler() {
|
||||
@Override
|
||||
protected URLConnection openConnection(final URL arg0) {
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ public class IndentationCheckTest extends BaseCheckTestSupport {
|
|||
private static final Pattern NONSTRICT_LEVEL_COMMENT_REGEX =
|
||||
Pattern.compile("//indent:\\d+ exp:>=(\\d+)( warn)?");
|
||||
|
||||
protected static Integer[] getLinesWithWarnAndCheckComments(String aFileName,
|
||||
final int tabWidth)
|
||||
private static Integer[] getLinesWithWarnAndCheckComments(String aFileName,
|
||||
final int tabWidth)
|
||||
throws IOException {
|
||||
List<Integer> result = new ArrayList<>();
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(aFileName))) {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class JavadocParseTreeTest {
|
|||
private JavadocParser parser;
|
||||
private final BaseErrorListener errorListener = new FailOnErrorListener();
|
||||
|
||||
public ParseTree parseJavadoc(String aBlockComment)
|
||||
private ParseTree parseJavadoc(String aBlockComment)
|
||||
throws IOException {
|
||||
final Charset utf8Charset = Charset.forName("UTF-8");
|
||||
final InputStream in = new ByteArrayInputStream(aBlockComment.getBytes(utf8Charset));
|
||||
|
|
@ -64,7 +64,7 @@ public class JavadocParseTreeTest {
|
|||
return parser.javadoc();
|
||||
}
|
||||
|
||||
public static String getFileContent(File filename)
|
||||
private static String getFileContent(File filename)
|
||||
throws IOException {
|
||||
return Files.toString(filename, Charsets.UTF_8);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ import com.puppycrawl.tools.checkstyle.grammars.javadoc.JavadocParser.TrTagClose
|
|||
import com.puppycrawl.tools.checkstyle.grammars.javadoc.JavadocParser.TrTagOpenContext;
|
||||
|
||||
//@formatter:off
|
||||
public final class ParseTreeBuilder {
|
||||
final class ParseTreeBuilder {
|
||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
private ParseTreeBuilder() {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
|||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
|
||||
public class AllBlockCommentsTest extends BaseCheckTestSupport {
|
||||
protected static final Set<String> ALL_COMMENTS = Sets.newLinkedHashSet();
|
||||
private static final Set<String> ALL_COMMENTS = Sets.newLinkedHashSet();
|
||||
|
||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
|||
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
|
||||
|
||||
public class AllSinglelineCommentsTest extends BaseCheckTestSupport {
|
||||
protected static final Set<String> ALL_COMMENTS = Sets.newLinkedHashSet();
|
||||
private static final Set<String> ALL_COMMENTS = Sets.newLinkedHashSet();
|
||||
|
||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import org.junit.Assert;
|
|||
import com.puppycrawl.tools.checkstyle.api.Check;
|
||||
import com.puppycrawl.tools.checkstyle.api.DetailAST;
|
||||
|
||||
public class CompareTreesWithComments extends Check {
|
||||
class CompareTreesWithComments extends Check {
|
||||
static DetailAST expectedTree;
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -74,12 +74,12 @@ public class SuppressWarningsFilterTest
|
|||
verifySuppressed(filterConfig, suppressed);
|
||||
}
|
||||
|
||||
public static DefaultConfiguration createFilterConfig(Class<?> classObj) {
|
||||
private static DefaultConfiguration createFilterConfig(Class<?> classObj) {
|
||||
return new DefaultConfiguration(classObj.getName());
|
||||
}
|
||||
|
||||
protected void verifySuppressed(Configuration aFilterConfig,
|
||||
String... aSuppressed) throws Exception {
|
||||
private void verifySuppressed(Configuration aFilterConfig,
|
||||
String... aSuppressed) throws Exception {
|
||||
verify(createChecker(aFilterConfig),
|
||||
getPath("filters/InputSuppressWarningsFilter.java"),
|
||||
removeSuppressed(ALL_MESSAGES, aSuppressed));
|
||||
|
|
|
|||
|
|
@ -191,12 +191,12 @@ public class SuppressWithNearbyCommentFilterTest
|
|||
EqualsVerifier.forClass(SuppressWithNearbyCommentFilter.Tag.class).usingGetClass().verify();
|
||||
}
|
||||
|
||||
public static DefaultConfiguration createFilterConfig(Class<?> classObj) {
|
||||
private static DefaultConfiguration createFilterConfig(Class<?> classObj) {
|
||||
return new DefaultConfiguration(classObj.getName());
|
||||
}
|
||||
|
||||
protected void verifySuppressed(Configuration filterConfig,
|
||||
String... suppressed)
|
||||
private void verifySuppressed(Configuration filterConfig,
|
||||
String... suppressed)
|
||||
throws Exception {
|
||||
verify(createChecker(filterConfig),
|
||||
getPath("filters/InputSuppressWithNearbyCommentFilter.java"),
|
||||
|
|
|
|||
|
|
@ -191,12 +191,12 @@ public class SuppressionCommentFilterTest
|
|||
verifySuppressed(filterConfig, suppressed);
|
||||
}
|
||||
|
||||
public static DefaultConfiguration createFilterConfig(Class<?> aClass) {
|
||||
private static DefaultConfiguration createFilterConfig(Class<?> aClass) {
|
||||
return new DefaultConfiguration(aClass.getName());
|
||||
}
|
||||
|
||||
protected void verifySuppressed(Configuration aFilterConfig,
|
||||
String... aSuppressed)
|
||||
private void verifySuppressed(Configuration aFilterConfig,
|
||||
String... aSuppressed)
|
||||
throws Exception {
|
||||
verify(createChecker(aFilterConfig),
|
||||
getPath("filters/InputSuppressionCommentFilter.java"),
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ import com.puppycrawl.tools.checkstyle.api.FilterSet;
|
|||
public class SuppressionsLoaderTest extends BaseCheckTestSupport {
|
||||
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
private final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void testNoSuppressions()
|
||||
|
|
|
|||
Loading…
Reference in New Issue