Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reformat files to fix white space and minor formatting issues #458

Merged
merged 3 commits into from
Aug 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/main/java/com/cflint/BugInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public BugInfoBuilder setSeverity(final Levels severity) {

public BugInfoBuilder setExpression(final String expression) {
if (expression == null) {
bugInfo.expression = "";
bugInfo.expression = "";
} else if (expression.length() > 200) {
bugInfo.expression = expression.substring(0, 200);
} else {
Expand Down Expand Up @@ -151,12 +151,12 @@ public BugInfo build(final CFExpression expression, final Element elem) {
elemColumn = elem.getSource().getColumn(elem.getBegin());
}
bugInfo.setLine(elemLine + Math.max(expression == null ? 0 : expression.getLine() - 1, 0));
if(expression == null || expression.getColumn() < 1){
bugInfo.setColumn(elemColumn);
}else if (expression.getLine()>1){
bugInfo.setColumn(expression.getColumn());
}else{
bugInfo.setColumn(elemColumn + expression.getColumn() - 1);
if (expression == null || expression.getColumn() < 1) {
bugInfo.setColumn(elemColumn);
} else if (expression.getLine() > 1) {
bugInfo.setColumn(expression.getColumn());
} else {
bugInfo.setColumn(elemColumn + expression.getColumn() - 1);
}
doMessageText(elem);
return bugInfo;
Expand All @@ -182,7 +182,7 @@ private void doMessageText(final Element elem) {

if (bugInfo.component != null) {
message = message.replace("${component}", bugInfo.component);
}else{
} else {
message = message.replace("${component}", "unknown");
}

Expand All @@ -202,7 +202,7 @@ private void doMessageText(final Element elem) {
@Override
public String toString() {
return "BugInfo [filename=" + filename + ", line=" + line + ", column=" + column + ", message=" + message
+ ", messageCode=" + messageCode + ", expression=" + expression + "]";
+ ", messageCode=" + messageCode + ", expression=" + expression + "]";
}

public String getExpression() {
Expand Down
90 changes: 48 additions & 42 deletions src/main/java/com/cflint/CFLintStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,52 @@

public class CFLintStats {

// Epoch timestamp for XML format output
private long timestamp = System.currentTimeMillis() / 1000L;
// Number of files
private long fileCount;
// Number of lines
private BigInteger totalLines = BigInteger.ZERO;
// Bug counts for current execution
private BugCounts counts = new BugCounts();

public CFLintStats() {
super();
}

public CFLintStats(final long timestamp, long fileCount, BigInteger totalLines) {
super();
this.timestamp = timestamp;
this.fileCount = fileCount;
this.totalLines = totalLines;
}

public CFLintStats(final long timestamp, long fileCount, BigInteger totalLines, BugCounts counts) {
super();
this.timestamp = timestamp;
this.fileCount = fileCount;
this.totalLines = totalLines;
this.counts = counts;
}

public void addFile(final long numberOfLines){
fileCount++;
totalLines = totalLines.add(BigInteger.valueOf(numberOfLines));
}

public long getTimestamp() { return timestamp; }

public long getFileCount() { return fileCount; }

public BigInteger getTotalLines() {
return totalLines;
}

public BugCounts getCounts() { return counts; }
// Epoch timestamp for XML format output
private long timestamp = System.currentTimeMillis() / 1000L;
// Number of files
private long fileCount;
// Number of lines
private BigInteger totalLines = BigInteger.ZERO;
// Bug counts for current execution
private BugCounts counts = new BugCounts();

public CFLintStats() {
super();
}

public CFLintStats(final long timestamp, long fileCount, BigInteger totalLines) {
super();
this.timestamp = timestamp;
this.fileCount = fileCount;
this.totalLines = totalLines;
}

public CFLintStats(final long timestamp, long fileCount, BigInteger totalLines, BugCounts counts) {
super();
this.timestamp = timestamp;
this.fileCount = fileCount;
this.totalLines = totalLines;
this.counts = counts;
}

public void addFile(final long numberOfLines) {
fileCount++;
totalLines = totalLines.add(BigInteger.valueOf(numberOfLines));
}

public long getTimestamp() {
return timestamp;
}

public long getFileCount() {
return fileCount;
}

public BigInteger getTotalLines() {
return totalLines;
}

public BugCounts getCounts() {
return counts;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.cflint.listeners;

/**
* Receives actions when a new source (file) is processed
* Receives actions when a new source (file) is processed.
*
* @author eberlyrh
*
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/com/cflint/main/CFLintMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class CFLintMain {
private String xmlOutFile = "cflint-result.xml";
private String xmlstyle = CFLINT;
private String htmlOutFile = "cflint-result.html";
private String htmlStyle = "plain.xsl";
private String htmlStyle = "plain.xsl";
private String jsonOutFile = "cflint-result.json";
private String textOutFile = null;
private CFLintConfig cmdLineConfig = null;
Expand Down Expand Up @@ -134,7 +134,7 @@ public static void main(final String[] args) throws Exception {
main.strictInclude = cmd.hasOption(Settings.STRICT_INCLUDE);
if (cmd.hasOption(Settings.RULES) || cmd.hasOption(Settings.CONFIG)) {
final CFLintPluginInfo pluginInfo = cmd.hasOption(Settings.RULES) ? ConfigUtils.loadDefaultPluginInfo()
: new CFLintPluginInfo();
: new CFLintPluginInfo();
main.defaultConfig = new CFLintConfig();
main.defaultConfig.setRules(pluginInfo.getRules());

Expand Down Expand Up @@ -274,13 +274,13 @@ public static void main(final String[] args) throws Exception {

/**
* Apply the listed rule groups
*
*
* @param main
* @param pluginInfo
* @param rulegroups
*/
protected static void applyRuleGroups(final CFLintMain main, final CFLintPluginInfo pluginInfo,
final String rulegroups) {
final String rulegroups) {
final boolean include = !rulegroups.startsWith("!");
for (RuleGroup rg : pluginInfo.getRuleGroups()) {
if (rulegroups.contains(rg.getName())) {
Expand All @@ -295,7 +295,7 @@ protected static void applyRuleGroups(final CFLintMain main, final CFLintPluginI

/**
* List the rule groups
*
*
* @param pluginInfo
*/
private static void listRuleGroups(final CFLintPluginInfo pluginInfo) {
Expand Down Expand Up @@ -350,7 +350,7 @@ private void ui() {
return;
}

final String[] slist = new String[] { "xml", "html", "text", "txt", "json" };
final String[] slist = new String[]{"xml", "html", "text", "txt", "json"};
final JList<String> list = new JList<String>(slist);
JOptionPane.showMessageDialog(null, list, "Output Type", JOptionPane.PLAIN_MESSAGE);

Expand Down Expand Up @@ -380,7 +380,7 @@ private static CFLintConfig loadConfig(final String configfile) {
final Object configObj = ConfigUtils.unmarshal(new FileInputStream(configfile));
if (configObj instanceof CFLintPluginInfo)
pluginInfo = (CFLintPluginInfo) configObj;
else if(configObj instanceof CFLintConfig ){
else if (configObj instanceof CFLintConfig) {
return (CFLintConfig) configObj;
}
} else {
Expand Down Expand Up @@ -410,7 +410,7 @@ private void execute() throws IOException, TransformerException, JAXBException,
cflint.setAllowedExtensions(Arrays.asList(extensions.trim().split(",")));
} catch (final Exception e) {
System.err.println(
"Unable to use extensions (" + extensions + ") using default instead. " + e.getMessage());
"Unable to use extensions (" + extensions + ") using default instead. " + e.getMessage());
}
}
final CFLintFilter filter = createBaseFilter();
Expand All @@ -429,7 +429,7 @@ private void execute() throws IOException, TransformerException, JAXBException,
}
scanner.close();
final File starterFile = new File(stdInFile);
if (starterFile.exists() && starterFile.getParentFile().exists()){
if (starterFile.exists() && starterFile.getParentFile().exists()) {
cflint.setupConfigAncestry(starterFile.getParentFile());
}
cflint.process(source.toString(), stdInFile);
Expand Down Expand Up @@ -457,10 +457,10 @@ private void execute() throws IOException, TransformerException, JAXBException,
} catch (final IOException e) {
throw new IOException(e);
} finally {
if (xmlwriter != null) {
xmlwriter.close();
}
}
if (xmlwriter != null) {
xmlwriter.close();
}
}
}
if (textOutput) {
Writer textwriter = null;
Expand All @@ -469,8 +469,8 @@ private void execute() throws IOException, TransformerException, JAXBException,
display("Writing text" + (stdOut ? "." : " to " + textOutFile));
}
textwriter = stdOut || textOutFile == null ? new OutputStreamWriter(System.out)
: new FileWriter(textOutFile);
new TextOutput().output(cflint.getBugs(), textwriter,cflint.getStats());
: new FileWriter(textOutFile);
new TextOutput().output(cflint.getBugs(), textwriter, cflint.getStats());
} catch (final IOException e) {
throw new IOException(e);
} finally {
Expand Down Expand Up @@ -570,9 +570,9 @@ private Writer createWriter(final String xmlOutFile, final Charset encoding) thr
} catch (final IOException e) {
throw new IOException(e);
} finally {
if (out != null) {
out.close();
}
if (out != null) {
out.close();
}
}
return out;
}
Expand Down
Loading