Rename field to not interfere with local variable name. #1555

Fixes `LocalVariableHidingMemberVariable` inspection violation in test code.

Description:
>Reports local variables named identically to visible fields of their class or surrounding classes if it is a local variable inside of an inner or anonymous class. Such a variable name may be confusing.
This commit is contained in:
Michal Kordas 2015-08-22 21:51:33 +02:00 committed by Roman Ivanov
parent 0c75b3af74
commit 230cd73883
1 changed files with 7 additions and 7 deletions

View File

@ -15,29 +15,29 @@ public class ClassMethodTypeParameterNameTest extends BaseCheckTestSupport{
private static ConfigurationBuilder builder;
private final String msgKey = "name.invalidPattern";
private static Configuration checkConfig;
private static Configuration configuration;
private static String format;
@BeforeClass
public static void setConfigurationBuilder() throws CheckstyleException, IOException {
builder = new ConfigurationBuilder(new File("src/it/"));
checkConfig = builder.getCheckConfig("ClassTypeParameterName");
format = checkConfig.getAttribute("format");
configuration = builder.getCheckConfig("ClassTypeParameterName");
format = configuration.getAttribute("format");
}
@Test
public void testClassDefault() throws Exception {
final String[] expected = {
"5:31: " + getCheckMessage(checkConfig.getMessages(), msgKey, "t", format),
"13:14: " + getCheckMessage(checkConfig.getMessages(), msgKey, "foo", format),
"27:24: " + getCheckMessage(checkConfig.getMessages(), msgKey, "$foo", format),
"5:31: " + getCheckMessage(configuration.getMessages(), msgKey, "t", format),
"13:14: " + getCheckMessage(configuration.getMessages(), msgKey, "foo", format),
"27:24: " + getCheckMessage(configuration.getMessages(), msgKey, "$foo", format),
};
String filePath = builder.getFilePath("ClassTypeParameterNameInput");
Integer[] warnList = builder.getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
verify(configuration, filePath, expected, warnList);
}
@Test