Revert "Checking existance of config file before processing target file.", due to #1267
This reverts commit 3004b4d881.
This commit is contained in:
parent
0631e2380c
commit
bff2e1754a
|
|
@ -145,13 +145,10 @@ public final class Main {
|
|||
private static List<String> validateCli(CommandLine cmdLine) {
|
||||
final List<String> result = new ArrayList<>();
|
||||
// ensure a configuration file is specified
|
||||
if (cmdLine.hasOption("c")) {
|
||||
final String configLocation = cmdLine.getOptionValue("c");
|
||||
final File configFile = new File(configLocation);
|
||||
if (!configFile.exists()) {
|
||||
result.add(String.format("unable to find '%s'.", configLocation));
|
||||
}
|
||||
|
||||
if (!cmdLine.hasOption("c")) {
|
||||
result.add("Must specify a config XML file.");
|
||||
}
|
||||
else {
|
||||
// validate optional parameters
|
||||
if (cmdLine.hasOption("f")) {
|
||||
final String format = cmdLine.getOptionValue("f");
|
||||
|
|
@ -160,7 +157,6 @@ public final class Main {
|
|||
+ " Found '%s' but expected 'plain' or 'xml'.", format));
|
||||
}
|
||||
}
|
||||
|
||||
if (cmdLine.hasOption("p")) {
|
||||
final String propertiesLocation = cmdLine.getOptionValue("p");
|
||||
final File file = new File(propertiesLocation);
|
||||
|
|
@ -168,7 +164,6 @@ public final class Main {
|
|||
result.add(String.format("Could not find file '%s'.", propertiesLocation));
|
||||
}
|
||||
}
|
||||
|
||||
if (cmdLine.hasOption("o")) {
|
||||
final String outputLocation = cmdLine.getOptionValue("o");
|
||||
final File file = new File(outputLocation);
|
||||
|
|
@ -176,15 +171,11 @@ public final class Main {
|
|||
result.add(String.format("Permission denied : '%s'.", outputLocation));
|
||||
}
|
||||
}
|
||||
|
||||
final List<File> files = getFilesToProcess(cmdLine.getArgs());
|
||||
if (files.isEmpty()) {
|
||||
result.add("Must specify files to process, found 0.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
result.add("Must specify a config XML file.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,8 +105,7 @@ public class MainTest {
|
|||
assertEquals("", errorLog.getLog());
|
||||
}
|
||||
});
|
||||
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml",
|
||||
"NonexistingFile.java");
|
||||
Main.main("-c", "/google_checks.xml", "NonexistingFile.java");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -115,7 +114,8 @@ public class MainTest {
|
|||
exit.expectSystemExitWithStatus(-1);
|
||||
exit.checkAssertionAfterwards(new Assertion() {
|
||||
public void checkAssertion() {
|
||||
assertEquals(String.format("unable to find 'src/main/resources/non_existing_config.xml'.%n"),
|
||||
assertEquals(String.format("unable to find src/main/resources/non_existing_config.xml%n"
|
||||
+ "Checkstyle ends with 1 errors.%n"),
|
||||
standardLog.getLog());
|
||||
assertEquals("", errorLog.getLog());
|
||||
}
|
||||
|
|
@ -135,7 +135,7 @@ public class MainTest {
|
|||
assertEquals("", errorLog.getLog());
|
||||
}
|
||||
});
|
||||
Main.main("-c", "src/test/resources/com/puppycrawl/tools/checkstyle/config-classname.xml", "-f" , "xmlp",
|
||||
Main.main("-c", "/google_checks.xml", "-f" , "xmlp",
|
||||
"src/test/resources/com/puppycrawl/tools/checkstyle/InputMain.java");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue