Skip to content

Commit

Permalink
Merge pull request #166 from cflint/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ryaneberly committed May 10, 2016
2 parents 323ca58 + e098fc3 commit 8aeacd9
Show file tree
Hide file tree
Showing 119 changed files with 359 additions and 554 deletions.
1 change: 0 additions & 1 deletion src/main/java/com/cflint/BugCounts.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package com.cflint;

import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Map;
import java.util.Set;

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/cflint/BugInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import java.util.List;

import net.htmlparser.jericho.Element;
import cfml.parsing.cfscript.CFExpression;
import cfml.parsing.cfscript.script.CFParsedStatement;

import com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage;
import com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginParameter;

import cfml.parsing.cfscript.CFExpression;
import cfml.parsing.cfscript.script.CFParsedStatement;
import net.htmlparser.jericho.Element;

public class BugInfo implements Comparable<BugInfo>{

String filename;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/cflint/BugList.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class BugList implements Iterable<BugInfo> {
/**
*
*/
@SuppressWarnings("unused")
private static final long serialVersionUID = -8008927848087276202L;

public BugList(final CFLintFilter filter) {
Expand Down
46 changes: 22 additions & 24 deletions src/main/java/com/cflint/CFLint.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import net.htmlparser.jericho.Element;
import net.htmlparser.jericho.Source;

import org.antlr.runtime.BitSet;
import org.antlr.runtime.IntStream;
import org.antlr.runtime.RecognitionException;
Expand All @@ -26,7 +23,23 @@
import org.antlr.v4.runtime.atn.ATNConfigSet;
import org.antlr.v4.runtime.dfa.DFA;

import cfml.CFSCRIPTLexer;
import com.cflint.BugInfo.BugInfoBuilder;
import com.cflint.config.CFLintConfig;
import com.cflint.config.CFLintPluginInfo;
import com.cflint.config.CFLintPluginInfo.PluginInfoRule;
import com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage;
import com.cflint.config.ConfigRuntime;
import com.cflint.config.ConfigUtils;
import com.cflint.listeners.ProgressMonitorListener;
import com.cflint.listeners.ScanProgressListener;
import com.cflint.plugins.CFLintScanner;
import com.cflint.plugins.CFLintStructureListener;
import com.cflint.plugins.Context;
import com.cflint.plugins.Context.ContextMessage;
import com.cflint.plugins.exceptions.CFLintExceptionListener;
import com.cflint.plugins.exceptions.DefaultCFLintExceptionListener;
import com.cflint.tools.CFLintFilter;

import cfml.CFSCRIPTParser;
import cfml.parsing.CFMLParser;
import cfml.parsing.CFMLSource;
Expand Down Expand Up @@ -55,23 +68,8 @@
import cfml.parsing.cfscript.script.CFScriptStatement;
import cfml.parsing.reporting.IErrorReporter;
import cfml.parsing.reporting.ParseException;

import com.cflint.BugInfo.BugInfoBuilder;
import com.cflint.config.CFLintConfig;
import com.cflint.config.CFLintPluginInfo;
import com.cflint.config.CFLintPluginInfo.PluginInfoRule;
import com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage;
import com.cflint.config.ConfigRuntime;
import com.cflint.config.ConfigUtils;
import com.cflint.listeners.ProgressMonitorListener;
import com.cflint.listeners.ScanProgressListener;
import com.cflint.plugins.CFLintScanner;
import com.cflint.plugins.CFLintStructureListener;
import com.cflint.plugins.Context;
import com.cflint.plugins.Context.ContextMessage;
import com.cflint.plugins.exceptions.CFLintExceptionListener;
import com.cflint.plugins.exceptions.DefaultCFLintExceptionListener;
import com.cflint.tools.CFLintFilter;
import net.htmlparser.jericho.Element;
import net.htmlparser.jericho.Source;

public class CFLint implements IErrorReporter {

Expand Down Expand Up @@ -347,8 +345,8 @@ else if (elem.getName().equalsIgnoreCase("cffunction")) {
}
if (elem.getName().equalsIgnoreCase("cfset") || elem.getName().equalsIgnoreCase("cfif")
|| elem.getName().equalsIgnoreCase("cfelseif")|| elem.getName().equalsIgnoreCase("cfreturn")) {
final int elemLine = elem.getSource().getRow(elem.getBegin());
final int elemColumn = elem.getSource().getColumn(elem.getBegin());
//final int elemLine = elem.getSource().getRow(elem.getBegin());
//final int elemColumn = elem.getSource().getColumn(elem.getBegin());
final Pattern p = Pattern.compile("<\\w+\\s(.*[^/])/?>",Pattern.MULTILINE|Pattern.DOTALL);
final String expr = elem.getFirstStartTag().toString();
final Matcher m = p.matcher(expr);
Expand All @@ -369,7 +367,7 @@ else if (elem.getName().equalsIgnoreCase("cffunction")) {
// }
} catch (final Exception npe) {
final int line = elem.getSource().getRow(elem.getBegin());
final int column = elem.getSource().getColumn(elem.getBegin());
//final int column = elem.getSource().getColumn(elem.getBegin());
if (!quiet) {
System.err.println("Error in: " + shortSource(elem.getSource(), line) + " @ " + line + ":");
if (verbose) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/cflint/HTMLOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;

import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamSource;
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/cflint/JSONOutput.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.cflint;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
Expand All @@ -11,9 +9,7 @@
import java.util.Map.Entry;

import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamSource;

import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;

Expand All @@ -29,7 +25,6 @@ public void setPrettyPrint(boolean prettyPrint) {
this.prettyPrint = prettyPrint;
}

@SuppressWarnings("unchecked")
public void output(final BugList bugList, final Writer writer, final boolean showStats) throws IOException {
BugCounts counts = new BugCounts();
// final StringBuilder sb = new StringBuilder();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/cflint/TextOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import java.io.IOException;
import java.io.Writer;
import java.util.List;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Map;

public class TextOutput {

Expand Down
14 changes: 0 additions & 14 deletions src/main/java/com/cflint/ant/CFLintTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,6 @@ public void execute() {
}
}

private String shorten(String includedFile) {
if (includedFile == null) {
return "";
}
includedFile = includedFile.trim();
if (includedFile.length() < 20) {
return includedFile;
}
return ".." + includedFile.substring(includedFile.length() - 20);
}

public void addFileset(final FileSet fileset) {
filesets.add(fileset);
}
Expand Down Expand Up @@ -205,7 +194,4 @@ public void setConfigFile(File configFile) {
this.configFile = configFile;
}

public void setShowStats(final boolean verbose) {
this.showStats = showStats;
}
}
1 change: 0 additions & 1 deletion src/main/java/com/cflint/config/CFLintPluginInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.cflint.plugins.CFLintScanner;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@XmlRootElement(name = "CFLint-Plugin")
@JsonInclude(Include.NON_NULL)
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/com/cflint/config/ConfigUtils.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
package com.cflint.config;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.HashMap;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

import java.util.HashMap;

import com.cflint.config.CFLintPluginInfo.PluginInfoRule;
import com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginParameter;
import com.cflint.plugins.CFLintScanner;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;

public class ConfigUtils {
Expand Down Expand Up @@ -87,7 +82,6 @@ public static String marshalJson(Object obj) throws JsonGenerationException, Jso
return sw.toString();
}

@SuppressWarnings("unchecked")
public static <E> E unmarshalJson(InputStream inputStream,
Class<E> expectedClass) throws JsonParseException, JsonMappingException, IOException {
ObjectMapper objectMapper = new ObjectMapper();
Expand All @@ -98,7 +92,6 @@ public static <E> E unmarshalJson(InputStream inputStream,
return objectMapper.readValue(inputStream, expectedClass);
}

@SuppressWarnings("unchecked")
public static <E> E unmarshalJson(Reader reader,
Class<E> expectedClass) throws JsonParseException, JsonMappingException, IOException {
ObjectMapper objectMapper = new ObjectMapper();
Expand Down Expand Up @@ -141,8 +134,8 @@ public static CFLintPluginInfo loadDefaultPluginInfo() {
*
* @return MapList&lt;String,String&gt; map of message codes to descriptions
*/
public static HashMap loadDescriptions() {
HashMap descriptions = new HashMap();
public static HashMap<String,String> loadDescriptions() {
HashMap<String,String> descriptions = new HashMap<String,String>();
InputStream inputStream = ConfigUtils.class
.getResourceAsStream("/cflint.description.txt");

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/cflint/main/CFLintMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

Expand All @@ -18,8 +19,6 @@
import javax.xml.bind.JAXBException;
import javax.xml.transform.TransformerException;

import java.util.HashMap;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
Expand Down Expand Up @@ -155,7 +154,7 @@ public static void main(final String[] args) throws ParseException, IOException,
pluginInfo = ConfigUtils.loadDefaultPluginInfo();
}
ConfigRuntime config = new ConfigRuntime(loadConfig(main.configfile), pluginInfo);
HashMap descriptions = ConfigUtils.loadDescriptions();
final HashMap<String,String> descriptions = ConfigUtils.loadDescriptions();
System.out.println("Supported rules");
for (PluginInfoRule rule:config.getRules()) {
System.out.println(" " + rule.getName());
Expand Down Expand Up @@ -288,7 +287,7 @@ private void ui() {
}

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

final int[] indxs = list.getSelectedIndices();
Expand Down Expand Up @@ -347,6 +346,7 @@ private void execute() throws IOException, TransformerException, JAXBException {
FileInputStream fis = new FileInputStream(ffile);
byte b[] = new byte[fis.available()];
fis.read(b);
fis.close();
filter = CFLintFilter.createFilter(new String(b),verbose);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/cflint/plugins/CFLintScanner.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.cflint.plugins;

import net.htmlparser.jericho.Element;
import com.cflint.BugList;

import cfml.parsing.cfscript.CFExpression;
import cfml.parsing.cfscript.script.CFScriptStatement;

import com.cflint.BugList;
import net.htmlparser.jericho.Element;

public interface CFLintScanner {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/cflint/plugins/CFLintScannerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import java.util.HashMap;
import java.util.Map;

import net.htmlparser.jericho.Element;
import com.cflint.BugList;

import cfml.parsing.cfscript.CFExpression;
import cfml.parsing.cfscript.script.CFScriptStatement;

import com.cflint.BugList;
import net.htmlparser.jericho.Element;

/**
* Lint Rule Plugins can extend this adapter instead of implementing all the methods of CFLintScanner
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/cflint/plugins/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import java.util.ArrayList;
import java.util.List;

import net.htmlparser.jericho.Element;
import cfml.parsing.cfscript.CFIdentifier;

import com.cflint.StackHandler;

import cfml.parsing.cfscript.CFIdentifier;
import net.htmlparser.jericho.Element;

public class Context {

String filename;
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/com/cflint/plugins/core/AbortChecker.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package com.cflint.plugins.core;

import ro.fortsoft.pf4j.Extension;
import cfml.parsing.cfscript.CFFunctionExpression;
import cfml.parsing.cfscript.script.CFAbortStatement;
import cfml.parsing.cfscript.script.CFExpressionStatement;
import cfml.parsing.cfscript.script.CFScriptStatement;

import com.cflint.BugInfo;
import com.cflint.BugList;
import com.cflint.plugins.CFLintScannerAdapter;
import com.cflint.plugins.Context;

import cfml.parsing.cfscript.script.CFAbortStatement;
import cfml.parsing.cfscript.script.CFScriptStatement;
import ro.fortsoft.pf4j.Extension;

@Extension
public class AbortChecker extends CFLintScannerAdapter {
final String severity = "WARNING";
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/cflint/plugins/core/ArgDefChecker.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.cflint.plugins.core;

import net.htmlparser.jericho.Element;
import cfml.parsing.cfscript.script.CFFuncDeclStatement;
import cfml.parsing.cfscript.script.CFFunctionParameter;
import cfml.parsing.cfscript.script.CFScriptStatement;

import com.cflint.BugList;
import com.cflint.plugins.CFLintScannerAdapter;
import com.cflint.plugins.Context;
import com.cflint.tools.CFTool;

import cfml.parsing.cfscript.script.CFFuncDeclStatement;
import cfml.parsing.cfscript.script.CFFunctionParameter;
import cfml.parsing.cfscript.script.CFScriptStatement;
import net.htmlparser.jericho.Element;

public class ArgDefChecker extends CFLintScannerAdapter {

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/cflint/plugins/core/ArgHintChecker.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.cflint.plugins.core;

import net.htmlparser.jericho.Element;

import com.cflint.BugInfo;
import com.cflint.BugList;
import com.cflint.plugins.CFLintScannerAdapter;
import com.cflint.plugins.Context;

import net.htmlparser.jericho.Element;

public class ArgHintChecker extends CFLintScannerAdapter {
final String severity = "INFO";

Expand Down
Loading

0 comments on commit 8aeacd9

Please sign in to comment.