Skip to content

Commit

Permalink
Merge 74728de into 32ed76c
Browse files Browse the repository at this point in the history
  • Loading branch information
adityatrivedi committed Sep 22, 2016
2 parents 32ed76c + 74728de commit 79bfa31
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/sleekbyte/tailor/Tailor.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ private Optional<CommonTokenStream> getTokenStream(File input) {
lexer.removeErrorListeners();
lexer.addErrorListener(new ErrorListener());
}
inputStream.close();
return Optional.of(new CommonTokenStream(lexer));
} catch (IOException e) {
handleIOException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public String getVersion() throws IOException {
}

protected InputStream getConfigResource() {
return getClass().getResourceAsStream(CONFIG_RESOURCE_PATH);
return ConfigProperties.class.getResourceAsStream(CONFIG_RESOURCE_PATH);
}

private String getProperty(String key, String defaultValue) throws IOException {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/sleekbyte/tailor/common/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ public abstract class Messages {
public static final String MULTI_VIOLATIONS_KEY = "violations";
public static final String NUM_VIOLATIONS_KEY = "num_violations";

// Formatter messages
public static final String FILE_KEY = "file";

// Error messages
public static final String NO_SWIFT_FILES_FOUND = "No Swift source files were found.";
public static final String COULD_NOT_BE_PARSED = " could not be parsed successfully, skipping...";
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/sleekbyte/tailor/format/Formatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.sleekbyte.tailor.common.ColorSettings;
import com.sleekbyte.tailor.common.ExitCode;
import com.sleekbyte.tailor.common.Messages;
import com.sleekbyte.tailor.output.ViolationMessage;

import java.io.File;
Expand Down Expand Up @@ -83,11 +84,11 @@ public static String formatSummary(long numFiles, long numSkipped, long numError
long numFilesAnalyzed = numFiles - numSkipped;
long numViolations = numErrors + numWarnings;
return String.format("%nAnalyzed %s, skipped %s, and detected %s (%s, %s).%n",
pluralize(numFilesAnalyzed, "file", "files"),
pluralize(numSkipped, "file", "files"),
pluralize(numViolations, "violation", "violations"),
pluralize(numErrors, "error", "errors"),
pluralize(numWarnings, "warning", "warnings")
pluralize(numFilesAnalyzed, Messages.FILE_KEY, Messages.FILES_KEY),
pluralize(numSkipped, Messages.FILE_KEY, Messages.FILES_KEY),
pluralize(numViolations, Messages.SINGLE_VIOLATION_KEY, Messages.MULTI_VIOLATIONS_KEY),
pluralize(numErrors, Messages.ERROR, Messages.ERRORS_KEY),
pluralize(numWarnings, Messages.WARNING, Messages.WARNINGS_KEY)
);
}

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/sleekbyte/tailor/format/HTMLFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ public void displaySummary(long numFiles, long numSkipped, long numErrors, long
output.put(Messages.FILES_KEY, FILES);
output.put(Messages.VERSION_LONG_OPT, new ConfigProperties().getVersion());

Mustache mustache = new DefaultMustacheFactory().compile(
new InputStreamReader(this.getClass().getResourceAsStream(TEMPLATE_PATH), Charset.defaultCharset()),
TEMPLATE_PATH
);
InputStreamReader inputStreamReader = new InputStreamReader(
HTMLFormatter.class.getResourceAsStream(TEMPLATE_PATH),
Charset.defaultCharset());
Mustache mustache = new DefaultMustacheFactory().compile(inputStreamReader, TEMPLATE_PATH);
mustache.execute(new OutputStreamWriter(System.out, Charset.defaultCharset()), output).flush();
inputStreamReader.close();
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/sleekbyte/tailor/utils/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ private List<String> getCodeClimateIncludePaths() throws IOException {
/**
* Data object to represent a Code Climate configuration, i.e. "config.json".
*/
private class ConfigJSON {
private static class ConfigJSON {
// Name cannot be camel case because it must match key from Code Climate spec
@SuppressWarnings("checkstyle:membername")
private List<String> include_paths;
Expand Down Expand Up @@ -341,7 +341,7 @@ private static Set<String> findFilesInPaths(List<String> pathNames) throws IOExc
*/
private static Optional<String> getSrcRoot() {
String srcRoot = System.getenv("SRCROOT");
if (srcRoot == null || srcRoot.equals("")) {
if (srcRoot == null || srcRoot.length() == 0) {
return Optional.empty();
}
return Optional.of(srcRoot);
Expand Down

0 comments on commit 79bfa31

Please sign in to comment.