Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneberly committed Nov 6, 2015
1 parent fd72688 commit 6d7785a
Show file tree
Hide file tree
Showing 5 changed files with 1,269 additions and 1,111 deletions.
103 changes: 78 additions & 25 deletions src/main/java/com/cflint/config/CFLintPluginInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,83 @@
import javax.xml.bind.annotation.XmlTransient;

import com.cflint.plugins.CFLintScanner;
import com.fasterxml.jackson.annotation.JsonIgnore;
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)
public class CFLintPluginInfo {

List<PluginInfoRule> rules = new ArrayList<CFLintPluginInfo.PluginInfoRule>();
List<PluginInfoGroup> groups = new ArrayList<CFLintPluginInfo.PluginInfoGroup>();

@JsonIgnore
public List<PluginInfoRule> getRules() {
List<PluginInfoRule> rules = new ArrayList<CFLintPluginInfo.PluginInfoRule>();
for (PluginInfoGroup group : groups) {
rules.addAll(group.getRules());
}
return rules;
}

@XmlElement(name = "ruleImpl")
public void setRules(final List<PluginInfoRule> rules) {
this.rules = rules;
public List<PluginInfoGroup> getGroups() {
return groups;
}

@XmlElement(name = "group")
public void setGroups(final List<PluginInfoGroup> groups) {
this.groups = groups;
}

public PluginInfoRule getRuleByName(String ruleName){
for(PluginInfoRule rule: rules){
if(ruleName != null && ruleName.equals(rule.getName())){
return rule;

public PluginInfoRule getRuleByName(String ruleName) {
for (PluginInfoGroup group : groups) {
for (PluginInfoRule rule : group.getRules()) {
if (ruleName != null && ruleName.equals(rule.getName())) {
return rule;
}
}
}
return null;
}

@JsonInclude(Include.NON_NULL)
public static class PluginInfoGroup {
String name;
List<PluginInfoRule> rules = new ArrayList<CFLintPluginInfo.PluginInfoRule>();

public List<PluginInfoRule> getRules() {
return rules;
}

public String getName() {
return name;
}

@XmlAttribute(name = "name")
public void setName(String name) {
this.name = name;
}

@XmlElement(name = "ruleImpl")
public void setRules(final List<PluginInfoRule> rules) {
this.rules = rules;
}
}

@JsonInclude(Include.NON_NULL)
public static class PluginInfoRule {

String name;
String className;
List<PluginMessage> messages = new ArrayList<PluginMessage>();
List<PluginParameter> parameters = new ArrayList<PluginParameter>();
//Associate the pluginInstance with the rule that created it
// Associate the pluginInstance with the rule that created it
CFLintScanner pluginInstance;

public CFLintScanner getPluginInstance() {
return pluginInstance;
}

@XmlTransient
public void setPluginInstance(CFLintScanner pluginInstance) {
this.pluginInstance = pluginInstance;
Expand All @@ -59,7 +95,7 @@ public String getClassName() {
return className;
}

@XmlAttribute(name="className")
@XmlAttribute(name = "className")
public void setClassName(String className) {
this.className = className;
}
Expand All @@ -76,15 +112,15 @@ public void setParameters(List<PluginParameter> parameters) {
public String getName() {
return name;
}
public void addParameter(String name, String value){

public void addParameter(String name, String value) {
PluginParameter p = new PluginParameter();
p.setName(name);
p.setValue(value);
parameters.add(p);
}

@XmlAttribute(name="name")
@XmlAttribute(name = "name")
public void setName(String name) {
this.name = name;
}
Expand Down Expand Up @@ -122,74 +158,91 @@ public List<PluginMessage> getMessages() {
public void setMessages(List<PluginMessage> messages) {
this.messages = messages;
}

public PluginMessage getMessageByCode(String messageCode){
for(PluginMessage message: messages){
if(messageCode != null && messageCode.equals(message.getCode())){

public PluginMessage getMessageByCode(String messageCode) {
for (PluginMessage message : messages) {
if (messageCode != null
&& messageCode.equals(message.getCode())) {
return message;
}
}
return null;
}

public static class PluginParameter {
String name;
String value;

public String getName() {
return name;
}
@XmlAttribute(name="name")

@XmlAttribute(name = "name")
public void setName(String name) {
this.name = name;
}

public String getValue() {
return value;
}
@XmlAttribute(name="value")

@XmlAttribute(name = "value")
public void setValue(String value) {
this.value = value;
}
}

public static class PluginMessage {
String code;

public PluginMessage(String code) {
super();
this.code = code;
}

public PluginMessage() {
super();
}

String messageText;
String severity;

public String getCode() {
return code;
}
@XmlAttribute(name="code")

@XmlAttribute(name = "code")
public void setCode(String code) {
this.code = code;
}

public String getMessageText() {
return messageText;
}

@XmlElement(name = "messageText")
public void setMessageText(String messageText) {
this.messageText = messageText;
}

public String getSeverity() {
return severity;
}

@XmlElement(name = "severity")
public void setSeverity(String severity) {
this.severity = severity;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((code == null) ? 0 : code.hashCode());
result = prime * result
+ ((code == null) ? 0 : code.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
Expand Down
Loading

0 comments on commit 6d7785a

Please sign in to comment.