You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2014/08/27 00:43:46 UTC
[15/51] [partial] Refactored the PMD Maven build - Adjusted the
directory structure - Fixed a lot of compile problems - Fixed the maven setup
- Made PMD build with Flexmojos 7.1.0 and Apache Flex 4.13.0 - Fixed a few
UnitTests
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/Violation.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/Violation.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/Violation.java
new file mode 100644
index 0000000..14f7a79
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/Violation.java
@@ -0,0 +1,323 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.core;
+
+import java.util.Formatter;
+
+import org.apache.commons.lang.StringUtils;
+
+import com.adobe.ac.pmd.IFlexViolation;
+import com.adobe.ac.pmd.files.IFlexFile;
+
+/**
+ * @author xagnetti
+ */
+public final class Violation implements IFlexViolation
+{
+ public static final String RULESET_CREATOR_URL = "http://opensource.adobe.com/svn/opensource/"
+ + "flexpmd/bin/flex-pmd-ruleset-creator.html?rule=";
+ private final int beginColumn;
+ private final int beginLine;
+ private int endColumn;
+ private final int endLine;
+ private final IFlexFile file;
+ private final IFlexRule rule;
+ private String ruleMessage = "";
+
+ /**
+ * @param position
+ * @param violatedRule
+ * @param violatedFile
+ */
+ public Violation( final ViolationPosition position,
+ final IFlexRule violatedRule,
+ final IFlexFile violatedFile )
+ {
+ beginLine = position.getBeginLine();
+ endLine = position.getEndLine();
+ beginColumn = position.getBeginColumn();
+ endColumn = position.getEndColumn();
+ rule = violatedRule;
+ file = violatedFile;
+
+ if ( violatedRule != null )
+ {
+ ruleMessage = violatedRule.getMessage() == null ? ""
+ : violatedRule.getMessage();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.IFlexViolation#appendToMessage(java.lang.String)
+ */
+ public void appendToMessage( final String messageToAppend )
+ {
+ ruleMessage += messageToAppend;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( final IFlexViolation otherViolation ) // NO_UCD
+ {
+ int res;
+ final int priorityOrder = getPrioriyOrder( otherViolation );
+
+ if ( priorityOrder == 0 )
+ {
+ res = getLinePriority( otherViolation );
+ }
+ else
+ {
+ res = priorityOrder;
+ }
+ return res;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.IRuleViolation#getBeginColumn()
+ */
+ public int getBeginColumn()
+ {
+ return beginColumn;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.IRuleViolation#getBeginLine()
+ */
+ public int getBeginLine()
+ {
+ return beginLine;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.IRuleViolation#getClassName()
+ */
+ public String getClassName()
+ {
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.IRuleViolation#getDescription()
+ */
+ public String getDescription()
+ {
+ return ruleMessage;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.IRuleViolation#getEndColumn()
+ */
+ public int getEndColumn()
+ {
+ return endColumn;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.IRuleViolation#getEndLine()
+ */
+ public int getEndLine()
+ {
+ return endLine;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.IRuleViolation#getFilename()
+ */
+ public String getFilename()
+ {
+ return file.getFullyQualifiedName();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.IRuleViolation#getMethodName()
+ */
+ public String getMethodName()
+ {
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.IRuleViolation#getPackageName()
+ */
+ public String getPackageName()
+ {
+ return file.getPackageName();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.IRuleViolation#getRule()
+ */
+ public IFlexRule getRule()
+ {
+ return rule;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.IFlexViolation#getRuleMessage()
+ */
+ public String getRuleMessage()
+ {
+ return ruleMessage.endsWith( "." ) ? ruleMessage.substring( 0,
+ ruleMessage.length() - 1 )
+ : ruleMessage;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.IRuleViolation#getVariableName()
+ */
+ public String getVariableName()
+ {
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.IRuleViolation#isSuppressed()
+ */
+ public boolean isSuppressed()
+ {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.IFlexViolation#replacePlaceholderInMessage(java.lang.
+ * String, int)
+ */
+ public void replacePlaceholderInMessage( final String replacement,
+ final int index )
+ {
+ ruleMessage = ruleMessage.replace( "{"
+ + index + "}",
+ replacement );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.IFlexViolation#setEndColumn(int)
+ */
+ public void setEndColumn( final int column )
+ {
+ endColumn = column;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.IFlexViolation#toXmlString(com.adobe.ac.pmd.files.IFlexFile
+ * , java.lang.String)
+ */
+ public String toXmlString( final IFlexFile violatedFile,
+ final String ruleSetName )
+ {
+ final Formatter formatter = new Formatter();
+
+ if ( rule != null )
+ {
+ final StringBuffer message = new StringBuffer( getRuleMessage() );
+
+ formatter.format( " <violation beginline=\"%d\" "
+ + "endline=\"%d\" begincolumn=\"%d\" " + "endcolumn=\"%d\" rule=\"%s\" "
+ + "ruleset=\"%s\" package=\"%s\" " + "class=\"%s\" externalInfoUrl=\"%s\" "
+ + "priority=\"%s\">%s</violation>" + getNewLine(),
+ beginLine,
+ endLine,
+ beginColumn,
+ endColumn,
+ rule.getRuleName(),
+ ruleSetName,
+ violatedFile.getPackageName(),
+ violatedFile.getClassName(),
+ RULESET_CREATOR_URL
+ + extractShortName( rule.getName() ),
+ rule.getPriority(),
+ message );
+ }
+ return formatter.toString();
+ }
+
+ /**
+ * @return
+ */
+ String getNewLine()
+ {
+ return System.getProperty( "line.separator" );
+ }
+
+ private String extractShortName( final String name )
+ {
+ return StringUtils.substringAfterLast( name,
+ "." );
+ }
+
+ private int getLinePriority( final IFlexViolation otherViolation )
+ {
+ int res;
+
+ if ( beginLine > otherViolation.getBeginLine() )
+ {
+ res = 1;
+ }
+ else if ( beginLine < otherViolation.getBeginLine() )
+ {
+ res = -1;
+ }
+ else
+ {
+ res = 0;
+ }
+
+ return res;
+ }
+
+ private int getPrioriyOrder( final IFlexViolation otherViolation )
+ {
+ int res;
+
+ if ( rule.getPriority() > otherViolation.getRule().getPriority() )
+ {
+ res = 1;
+ }
+ else if ( rule.getPriority() < otherViolation.getRule().getPriority() )
+ {
+ res = -1;
+ }
+ else
+ {
+ res = 0;
+ }
+
+ return res;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/ViolationPosition.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/ViolationPosition.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/ViolationPosition.java
new file mode 100644
index 0000000..2de73ff
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/ViolationPosition.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.core;
+
+/**
+ * @author xagnetti
+ */
+public final class ViolationPosition
+{
+ /**
+ * @param beginLineToBeSet
+ * @param endLineToBeSet
+ * @param beginColumnToBeSet
+ * @param endColumnToBeSet
+ * @return
+ */
+ public static ViolationPosition create( final int beginLineToBeSet,
+ final int endLineToBeSet,
+ final int beginColumnToBeSet,
+ final int endColumnToBeSet )
+ {
+ return new ViolationPosition( beginLineToBeSet, endLineToBeSet, beginColumnToBeSet, endColumnToBeSet );
+ }
+
+ private final int beginColumn;
+ private final int beginLine;
+ private final int endColumn;
+ private final int endLine;
+
+ /**
+ * @param lineToBeSet
+ */
+ public ViolationPosition( final int lineToBeSet )
+ {
+ this( lineToBeSet, lineToBeSet, 0, 0 );
+ }
+
+ /**
+ * @param beginLineToBeSet
+ * @param endLineToBeSet
+ */
+ public ViolationPosition( final int beginLineToBeSet,
+ final int endLineToBeSet )
+ {
+ this( beginLineToBeSet, endLineToBeSet, 0, 0 );
+ }
+
+ private ViolationPosition( final int beginLineToBeSet,
+ final int endLineToBeSet,
+ final int beginColumnToBeSet,
+ final int endColumnToBeSet )
+ {
+ super();
+
+ beginLine = beginLineToBeSet;
+ beginColumn = beginColumnToBeSet;
+ endLine = endLineToBeSet;
+ endColumn = endColumnToBeSet;
+ }
+
+ /**
+ * @return
+ */
+ public int getBeginColumn()
+ {
+ return beginColumn;
+ }
+
+ /**
+ * @return
+ */
+ public int getBeginLine()
+ {
+ return beginLine;
+ }
+
+ /**
+ * @return
+ */
+ public int getEndColumn()
+ {
+ return endColumn;
+ }
+
+ /**
+ * @return
+ */
+ public int getEndLine()
+ {
+ return endLine;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/ViolationPriority.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/ViolationPriority.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/ViolationPriority.java
new file mode 100644
index 0000000..e39ed03
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/ViolationPriority.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.core;
+
+/**
+ * @author xagnetti
+ */
+public enum ViolationPriority
+{
+ HIGH("1"), LOW("5"), NORMAL("3");
+
+ private String priority;
+
+ /**
+ * @param priorityToBeSet
+ */
+ private ViolationPriority( final String priorityToBeSet )
+ {
+ priority = priorityToBeSet;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Enum#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return priority;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/AbstractMaximizedAstFlexRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/AbstractMaximizedAstFlexRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/AbstractMaximizedAstFlexRule.java
new file mode 100644
index 0000000..c1c89c8
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/AbstractMaximizedAstFlexRule.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.core.thresholded;
+
+import java.util.Map;
+
+import net.sourceforge.pmd.PropertyDescriptor;
+
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public abstract class AbstractMaximizedAstFlexRule extends AbstractAstFlexRule implements IThresholdedRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getThreshold()
+ */
+ public final int getThreshold()
+ {
+ return getIntProperty( propertyDescriptorFor( getThresholdName() ) );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getThresholdName
+ * ()
+ */
+ public final String getThresholdName()
+ {
+ return MAXIMUM;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.CommonAbstractRule#propertiesByName()
+ */
+ @Override
+ protected final Map< String, PropertyDescriptor > propertiesByName()
+ {
+ return getThresholdedRuleProperties( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/AbstractMaximizedFlexRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/AbstractMaximizedFlexRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/AbstractMaximizedFlexRule.java
new file mode 100644
index 0000000..d1ce967
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/AbstractMaximizedFlexRule.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.core.thresholded;
+
+import java.util.Map;
+
+import net.sourceforge.pmd.PropertyDescriptor;
+
+import com.adobe.ac.pmd.rules.core.AbstractFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public abstract class AbstractMaximizedFlexRule extends AbstractFlexRule implements IThresholdedRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getThreshold()
+ */
+ public int getThreshold()
+ {
+ return getIntProperty( propertyDescriptorFor( getThresholdName() ) );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getThresholdName
+ * ()
+ */
+ public final String getThresholdName()
+ {
+ return MAXIMUM;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.CommonAbstractRule#propertiesByName()
+ */
+ @Override
+ protected final Map< String, PropertyDescriptor > propertiesByName()
+ {
+ return getThresholdedRuleProperties( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/AbstractMaximizedRegexpBasedRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/AbstractMaximizedRegexpBasedRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/AbstractMaximizedRegexpBasedRule.java
new file mode 100644
index 0000000..7015306
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/AbstractMaximizedRegexpBasedRule.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.core.thresholded;
+
+import java.util.Map;
+
+import net.sourceforge.pmd.PropertyDescriptor;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+
+/**
+ * @author xagnetti
+ */
+public abstract class AbstractMaximizedRegexpBasedRule extends AbstractRegexpBasedRule implements
+ IThresholdedRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getThreshold()
+ */
+ public final int getThreshold()
+ {
+ return getIntProperty( propertyDescriptorFor( getThresholdName() ) );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getThresholdName
+ * ()
+ */
+ public final String getThresholdName()
+ {
+ return MAXIMUM;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.CommonAbstractRule#propertiesByName()
+ */
+ @Override
+ protected final Map< String, PropertyDescriptor > propertiesByName()
+ {
+ return getThresholdedRuleProperties( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/IThresholdedRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/IThresholdedRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/IThresholdedRule.java
new file mode 100644
index 0000000..db4c845
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/java/com/adobe/ac/pmd/rules/core/thresholded/IThresholdedRule.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.core.thresholded;
+
+import com.adobe.ac.pmd.rules.core.IFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public interface IThresholdedRule extends IFlexRule
+{
+ /**
+ * @return
+ */
+ int getActualValueForTheCurrentViolation();
+
+ /**
+ * @return
+ */
+ int getDefaultThreshold();
+
+ /**
+ * @return
+ */
+ int getThreshold();
+
+ /**
+ * @return
+ */
+ String getThresholdName();
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/resources/flexPmd.properties
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/resources/flexPmd.properties b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/resources/flexPmd.properties
new file mode 100644
index 0000000..14ad989
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/main/resources/flexPmd.properties
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+report.flexCpd.name=Flex CPD Report
+report.flexPmd.name=Flex PMD Report
+report.flexPmd.description=List possible code smells in a Flex source directory
+report.flexCpd.description=List all the duplications in a Flex source directory
+report.pmd.title=Flex PMD Report
+report.pmd.pmdlink=
+report.pmd.files=Files
+report.pmd.column.violation=Violation
+report.pmd.column.line=Line
+report.pmd.noProblems=No problems found
+
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/files/FileSetUtilsTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/files/FileSetUtilsTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/files/FileSetUtilsTest.java
new file mode 100644
index 0000000..2302b6d
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/files/FileSetUtilsTest.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.files;
+
+import junit.framework.Assert;
+import net.sourceforge.pmd.PMDException;
+
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+
+public class FileSetUtilsTest extends FlexPmdTestBase
+{
+ @Test
+ public void buildAst() throws PMDException
+ {
+ FileSetUtils.buildAst( getTestFiles().get( "bug.Duane.mxml" ) );
+ }
+
+ @Test
+ public void testBuildMessage()
+ {
+ Assert.assertEquals( "While building AST on bug.Duane.mxml, an error occured: message",
+ FileSetUtils.buildLogMessage( getTestFiles().get( "bug.Duane.mxml" ),
+ "message" ) );
+ }
+
+ @Test
+ public void testComputeAsts() throws PMDException
+ {
+ FileSetUtils.computeAsts( getTestFiles() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/MetaDataTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/MetaDataTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/MetaDataTest.java
new file mode 100644
index 0000000..7bcf658
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/MetaDataTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.nodes;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class MetaDataTest
+{
+ @Test
+ public void testCreate()
+ {
+ assertEquals( MetaData.BINDABLE.toString(),
+ MetaData.create( MetaData.BINDABLE.toString() ).toString() );
+
+ assertEquals( MetaData.ARRAY_ELEMENT_TYPE.toString(),
+ MetaData.create( MetaData.ARRAY_ELEMENT_TYPE.toString() ).toString() );
+
+ assertEquals( MetaData.BEFORE.toString(),
+ MetaData.create( MetaData.BEFORE.toString() ).toString() );
+
+ assertEquals( MetaData.EMBED.toString(),
+ MetaData.create( MetaData.EMBED.toString() ).toString() );
+
+ assertEquals( MetaData.EVENT.toString(),
+ MetaData.create( MetaData.EVENT.toString() ).toString() );
+
+ assertEquals( MetaData.TEST.toString(),
+ MetaData.create( MetaData.TEST.toString() ).toString() );
+
+ final String unknownMetaData = "Unknown";
+ final MetaData other = MetaData.create( unknownMetaData );
+
+ assertEquals( MetaData.OTHER,
+ other );
+
+ assertEquals( unknownMetaData,
+ other.toString() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/ClassNodeTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/ClassNodeTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/ClassNodeTest.java
new file mode 100644
index 0000000..fb272a2
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/ClassNodeTest.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.nodes.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import junit.framework.Assert;
+import net.sourceforge.pmd.PMDException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+import com.adobe.ac.pmd.files.FileSetUtils;
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.MetaData;
+import com.adobe.ac.pmd.nodes.Modifier;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.parser.exceptions.TokenException;
+
+public class ClassNodeTest extends FlexPmdTestBase
+{
+ private IClass bug233;
+ private IClass modelLocator;
+ private IClass nonBindableModelLocator;
+ private IClass radonDataGrid;
+
+ @Before
+ public void setup() throws IOException,
+ TokenException,
+ PMDException
+ {
+ IParserNode ast = FileSetUtils.buildAst( getTestFiles().get( "RadonDataGrid.as" ) );
+ radonDataGrid = NodeFactory.createPackage( ast ).getClassNode();
+ final IFlexFile file = getTestFiles().get( "bug.FlexPMD233a.mxml" );
+ ast = FileSetUtils.buildAst( file );
+ bug233 = NodeFactory.createPackage( ast ).getClassNode();
+ ast = FileSetUtils.buildAst( getTestFiles().get( "cairngorm.BindableModelLocator.as" ) );
+ modelLocator = NodeFactory.createPackage( ast ).getClassNode();
+ ast = FileSetUtils.buildAst( getTestFiles().get( "cairngorm.NonBindableModelLocator.as" ) );
+ nonBindableModelLocator = NodeFactory.createPackage( ast ).getClassNode();
+ }
+
+ @Test
+ public void testBlock()
+ {
+ Assert.assertNull( radonDataGrid.getBlock() );
+ }
+
+ @Test
+ public void testFlexPMD233()
+ {
+ Assert.assertNull( bug233.getBlock() );
+ }
+
+ @Test
+ public void testGetAllMetaData()
+ {
+ assertEquals( 0,
+ radonDataGrid.getAllMetaData().size() );
+ }
+
+ @Test
+ public void testGetAttributes()
+ {
+ assertEquals( 0,
+ radonDataGrid.getAttributes().size() );
+ }
+
+ @Test
+ public void testGetAverageCyclomaticComplexity()
+ {
+ assertEquals( 3.0,
+ radonDataGrid.getAverageCyclomaticComplexity(),
+ 0.1 );
+ }
+
+ @Test
+ public void testGetConstants()
+ {
+ assertEquals( 0,
+ radonDataGrid.getConstants().size() );
+ }
+
+ @Test
+ public void testGetConstructor()
+ {
+ assertNotNull( radonDataGrid.getConstructor() );
+ }
+
+ @Test
+ public void testGetExtensionName()
+ {
+ assertEquals( "DataGrid",
+ radonDataGrid.getExtensionName() );
+ }
+
+ @Test
+ public void testGetImplementations()
+ {
+ assertEquals( 0,
+ radonDataGrid.getImplementations().size() );
+ assertEquals( 1,
+ modelLocator.getImplementations().size() );
+ }
+
+ @Test
+ public void testGetMetaData()
+ {
+ assertEquals( 0,
+ nonBindableModelLocator.getMetaData( MetaData.BINDABLE ).size() );
+ assertEquals( 1,
+ modelLocator.getMetaData( MetaData.BINDABLE ).size() );
+ }
+
+ @Test
+ public void testGetMetaDataList()
+ {
+ assertEquals( 0,
+ radonDataGrid.getMetaDataCount() );
+ assertNotNull( modelLocator.getMetaData( MetaData.BINDABLE ) );
+ assertEquals( 1,
+ modelLocator.getMetaData( MetaData.BINDABLE ).size() );
+ assertTrue( modelLocator.isBindable() );
+ assertFalse( nonBindableModelLocator.isBindable() );
+ }
+
+ @Test
+ public void testGetName()
+ {
+ assertEquals( "RadonDataGrid",
+ radonDataGrid.getName() );
+ }
+
+ @Test
+ public void testIsFinal()
+ {
+ assertFalse( radonDataGrid.isFinal() );
+ }
+
+ @Test
+ public void testVisibility()
+ {
+ assertTrue( radonDataGrid.isPublic() );
+ assertTrue( modelLocator.is( Modifier.PROTECTED ) );
+ assertTrue( nonBindableModelLocator.is( Modifier.PRIVATE ) );
+ assertFalse( nonBindableModelLocator.is( Modifier.PROTECTED ) );
+ assertFalse( nonBindableModelLocator.isPublic() );
+ assertFalse( radonDataGrid.is( Modifier.PROTECTED ) );
+ assertFalse( radonDataGrid.is( Modifier.PRIVATE ) );
+ assertFalse( modelLocator.isPublic() );
+ assertFalse( modelLocator.is( Modifier.PRIVATE ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/CommentNodeTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/CommentNodeTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/CommentNodeTest.java
new file mode 100644
index 0000000..674d4a4
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/CommentNodeTest.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.nodes.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import net.sourceforge.pmd.PMDException;
+
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+import com.adobe.ac.pmd.files.FileSetUtils;
+import com.adobe.ac.pmd.nodes.IPackage;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+public class CommentNodeTest extends FlexPmdTestBase
+{
+ private final IPackage flexPMD60Package;
+
+ public CommentNodeTest() throws PMDException
+ {
+ final IParserNode bug60Ast = FileSetUtils.buildAst( getTestFiles().get( "bug."
+ + "FlexPMD60.as" ) );
+ flexPMD60Package = NodeFactory.createPackage( bug60Ast );
+ }
+
+ @Test
+ public void testClassComment()
+ {
+ assertNotNull( flexPMD60Package.getClassNode().getAsDoc().getStringValue() );
+
+ assertEquals( "/** * AsDoc class */",
+ flexPMD60Package.getClassNode()
+ .getAsDoc()
+ .getStringValue()
+ .replace( "\t",
+ " " )
+ .replace( '\n',
+ ' ' )
+ .replaceAll( " ",
+ " " ) );
+
+ assertEquals( 2,
+ flexPMD60Package.getClassNode().getMultiLinesComment().size() );
+
+ assertNotNull( flexPMD60Package.getClassNode().getMultiLinesComment().get( 0 ) );
+
+ assertEquals( "/* * comment */",
+ flexPMD60Package.getClassNode()
+ .getMultiLinesComment()
+ .get( 0 )
+ .getStringValue()
+ .replace( "\t",
+ " " )
+ .replace( '\n',
+ ' ' )
+ .replaceAll( " ",
+ " " ) );
+ }
+
+ @Test
+ public void testFieldComment()
+ {
+ assertNotNull( flexPMD60Package.getClassNode().getAttributes().get( 0 ).getAsDoc() );
+
+ assertEquals( "/** * AsDoc attribute */",
+ flexPMD60Package.getClassNode()
+ .getAttributes()
+ .get( 0 )
+ .getAsDoc()
+ .getStringValue()
+ .replace( "\t",
+ " " )
+ .replace( '\n',
+ ' ' )
+ .replaceAll( " ",
+ " " ) );
+
+ }
+
+ @Test
+ public void testFunctionComment()
+ {
+ assertNotNull( flexPMD60Package.getClassNode().getFunctions().get( 0 ).getAsDoc() );
+
+ assertEquals( "/** * AsDoc method */",
+ flexPMD60Package.getClassNode()
+ .getFunctions()
+ .get( 0 )
+ .getAsDoc()
+ .getStringValue()
+ .replace( "\t",
+ " " )
+ .replace( '\n',
+ ' ' )
+ .replaceAll( " ",
+ " " ) );
+
+ assertEquals( 2,
+ flexPMD60Package.getClassNode().getMultiLinesComment().size() );
+
+ assertEquals( "/* * comment */",
+ flexPMD60Package.getClassNode()
+ .getMultiLinesComment()
+ .get( 0 )
+ .getStringValue()
+ .replace( "\t",
+ " " )
+ .replace( '\n',
+ ' ' )
+ .replaceAll( " ",
+ " " ) );
+
+ assertEquals( 1,
+ flexPMD60Package.getClassNode().getFunctions().get( 0 ).getMultiLinesComment().size() );
+
+ assertEquals( "/* var i : int = 0;*/",
+ flexPMD60Package.getClassNode()
+ .getFunctions()
+ .get( 0 )
+ .getMultiLinesComment()
+ .get( 0 )
+ .getStringValue()
+ .replace( "\t",
+ " " )
+ .replace( '\n',
+ ' ' )
+ .replaceAll( " ",
+ " " ) );
+ }
+
+ @Test
+ public void testMetadataComment()
+ {
+ assertNotNull( flexPMD60Package.getClassNode().getAsDoc() );
+
+ assertEquals( "/** * AsDoc class */",
+ flexPMD60Package.getClassNode()
+ .getAsDoc()
+ .getStringValue()
+ .replace( "\t",
+ " " )
+ .replace( '\n',
+ ' ' )
+ .replaceAll( " ",
+ " " ) );
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/FieldNodeTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/FieldNodeTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/FieldNodeTest.java
new file mode 100644
index 0000000..6c882d4
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/FieldNodeTest.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.nodes.impl;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import junit.framework.Assert;
+import net.sourceforge.pmd.PMDException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+import com.adobe.ac.pmd.files.FileSetUtils;
+import com.adobe.ac.pmd.nodes.IAttribute;
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.Modifier;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+public class FieldNodeTest extends FlexPmdTestBase
+{
+ private IAttribute first;
+ private IAttribute second;
+ private IAttribute third;
+ private IAttribute withAsDoc;
+
+ @Before
+ public void setup() throws PMDException
+ {
+ final IParserNode nonBindableModelLocatorAst = FileSetUtils.buildAst( getTestFiles().get( "cairngorm.NonBindableModelLocator.as" ) );
+ final IClass nonBindableModelLocator = NodeFactory.createPackage( nonBindableModelLocatorAst )
+ .getClassNode();
+ first = nonBindableModelLocator.getAttributes().get( 0 );
+ second = nonBindableModelLocator.getAttributes().get( 1 );
+ third = nonBindableModelLocator.getAttributes().get( 2 );
+ final IParserNode asDocsAst = FileSetUtils.buildAst( getTestFiles().get( "asDocs.EmptyWithDocClass.as" ) );
+ final IClass asDocs = NodeFactory.createPackage( asDocsAst ).getClassNode();
+ withAsDoc = asDocs.getAttributes().get( 0 );
+
+ }
+
+ @Test
+ public void testBug167()
+ {
+ Assert.assertNotNull( withAsDoc.getAsDoc() );
+ Assert.assertEquals( 1,
+ withAsDoc.getMetaDataCount() );
+ }
+
+ @Test
+ public void testIsStatic()
+ {
+ assertTrue( first.isStatic() );
+ assertFalse( second.isStatic() );
+ }
+
+ @Test
+ public void testVisibility() throws PMDException
+ {
+ assertTrue( first.is( Modifier.PRIVATE ) );
+ assertFalse( first.isPublic() );
+ assertFalse( first.is( Modifier.PROTECTED ) );
+ assertTrue( second.is( Modifier.PROTECTED ) );
+ assertFalse( second.isPublic() );
+ assertFalse( second.is( Modifier.PRIVATE ) );
+ assertTrue( third.isPublic() );
+ assertFalse( third.is( Modifier.PROTECTED ) );
+ assertFalse( third.is( Modifier.PRIVATE ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/FunctionNodeTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/FunctionNodeTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/FunctionNodeTest.java
new file mode 100644
index 0000000..428177d
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/FunctionNodeTest.java
@@ -0,0 +1,271 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.nodes.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import net.sourceforge.pmd.PMDException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+import com.adobe.ac.pmd.files.FileSetUtils;
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.nodes.MetaData;
+import com.adobe.ac.pmd.nodes.Modifier;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.parser.exceptions.TokenException;
+
+public class FunctionNodeTest extends FlexPmdTestBase
+{
+ private IFunction bug88Constructor;
+ private IFunction constructor;
+ private IFunction drawHighlightIndicator;
+ private IFunction drawRowBackground;
+ private IFunction drawSelectionIndicator;
+ private IFunction fDCTQuant;
+ private IFunction flexunit4Test;
+ private IFunction flexunit4TestSetUp;
+ private IFunction getHeight;
+ private IFunction isTrueGetter;
+ private IFunction isTrueSetter;
+ private IFunction placeSortArrow;
+
+ @Test
+ public void modifiers()
+ {
+ assertTrue( constructor.is( Modifier.PUBLIC ) );
+ }
+
+ @Before
+ public void setup() throws IOException,
+ TokenException,
+ PMDException
+ {
+ final IParserNode dataGridAst = FileSetUtils.buildAst( getTestFiles().get( "RadonDataGrid.as" ) );
+ final IParserNode modelLocatorAst = FileSetUtils.buildAst( getTestFiles().get( "cairngorm."
+ + "NonBindableModelLocator.as" ) );
+ final IParserNode flexUnit4TestCaseAst = FileSetUtils.buildAst( getTestFiles().get( "flexunit."
+ + "RaoulTest.as" ) );
+ final IParserNode bug888Ast = FileSetUtils.buildAst( getTestFiles().get( "bug."
+ + "FlexPMD88.as" ) );
+ final IParserNode pngEncoderAst = FileSetUtils.buildAst( getTestFiles().get( "PngEncoder.as" ) );
+
+ final IClass radonDataGrid = NodeFactory.createPackage( dataGridAst ).getClassNode();
+ final IClass nonBindableModelLocator = NodeFactory.createPackage( modelLocatorAst ).getClassNode();
+ final IClass flexUnit4TestCase = NodeFactory.createPackage( flexUnit4TestCaseAst ).getClassNode();
+ final IClass bug88 = NodeFactory.createPackage( bug888Ast ).getClassNode();
+ final IClass pngEncoder = NodeFactory.createPackage( pngEncoderAst ).getClassNode();
+
+ constructor = radonDataGrid.getFunctions().get( 0 );
+ drawHighlightIndicator = radonDataGrid.getFunctions().get( 1 );
+ drawSelectionIndicator = radonDataGrid.getFunctions().get( 2 );
+ drawRowBackground = radonDataGrid.getFunctions().get( 3 );
+ placeSortArrow = radonDataGrid.getFunctions().get( 4 );
+ isTrueGetter = radonDataGrid.getFunctions().get( 5 );
+ isTrueSetter = radonDataGrid.getFunctions().get( 6 );
+ getHeight = nonBindableModelLocator.getFunctions().get( 2 );
+ flexunit4Test = flexUnit4TestCase.getFunctions().get( 1 );
+ flexunit4TestSetUp = flexUnit4TestCase.getFunctions().get( 0 );
+ bug88Constructor = bug88.getConstructor();
+ fDCTQuant = pngEncoder.getFunctions().get( 9 );
+ }
+
+ @Test
+ public void testFindPrimaryStatementFromName()
+ {
+ assertEquals( 0,
+ constructor.findPrimaryStatementsInBody( "" ).size() );
+ assertEquals( 1,
+ drawHighlightIndicator.findPrimaryStatementInBody( new String[]
+ { "super",
+ "" } ).size() );
+ }
+
+ @Test
+ public void testGetAllMetaData()
+ {
+ assertEquals( 0,
+ constructor.getAllMetaData().size() );
+ }
+
+ @Test
+ public void testGetBody()
+ {
+ assertEquals( 1,
+ flexunit4TestSetUp.getBody().numChildren() );
+
+ assertEquals( 38,
+ fDCTQuant.getBody().numChildren() );
+ }
+
+ @Test
+ public void testGetCyclomaticComplexity()
+ {
+ assertEquals( 2,
+ constructor.getCyclomaticComplexity() );
+ assertEquals( 1,
+ drawHighlightIndicator.getCyclomaticComplexity() );
+ assertEquals( 1,
+ drawSelectionIndicator.getCyclomaticComplexity() );
+ assertEquals( 4,
+ drawRowBackground.getCyclomaticComplexity() );
+ assertEquals( 13,
+ placeSortArrow.getCyclomaticComplexity() );
+
+ assertEquals( 3,
+ bug88Constructor.getCyclomaticComplexity() );
+ }
+
+ @Test
+ public void testGetMetaData()
+ {
+ assertEquals( 1,
+ getHeight.getMetaDataCount() );
+ assertEquals( 0,
+ isTrueGetter.getMetaDataCount() );
+ assertEquals( 1,
+ flexunit4Test.getMetaData( MetaData.TEST ).size() );
+ assertEquals( "Test",
+ flexunit4Test.getMetaData( MetaData.TEST ).get( 0 ).getName() );
+ assertEquals( 0,
+ flexunit4Test.getMetaData( MetaData.BEFORE ).size() );
+ }
+
+ @Test
+ public void testGetName()
+ {
+ assertEquals( "RadonDataGrid",
+ constructor.getName() );
+ assertEquals( "drawHighlightIndicator",
+ drawHighlightIndicator.getName() );
+ assertEquals( "drawSelectionIndicator",
+ drawSelectionIndicator.getName() );
+ assertEquals( "drawRowBackground",
+ drawRowBackground.getName() );
+ assertEquals( "placeSortArrow",
+ placeSortArrow.getName() );
+ }
+
+ @Test
+ public void testGetParameters()
+ {
+ assertEquals( 0,
+ constructor.getParameters().size() );
+ assertEquals( 7,
+ drawHighlightIndicator.getParameters().size() );
+ assertEquals( 7,
+ drawSelectionIndicator.getParameters().size() );
+ assertEquals( 6,
+ drawRowBackground.getParameters().size() );
+ assertEquals( 0,
+ placeSortArrow.getParameters().size() );
+ }
+
+ @Test
+ public void testGetReturnType()
+ {
+ assertEquals( "",
+ constructor.getReturnType().getInternalNode().getStringValue() );
+ assertEquals( "void",
+ drawHighlightIndicator.getReturnType().getInternalNode().getStringValue() );
+ assertEquals( "void",
+ drawSelectionIndicator.getReturnType().getInternalNode().getStringValue() );
+ assertEquals( "void",
+ drawRowBackground.getReturnType().getInternalNode().getStringValue() );
+ assertEquals( "void",
+ placeSortArrow.getReturnType().getInternalNode().getStringValue() );
+ assertEquals( "void",
+ flexunit4TestSetUp.getReturnType().getInternalNode().getStringValue() );
+ }
+
+ @Test
+ public void testGetStatementNbInBody()
+ {
+ assertEquals( 7,
+ constructor.getStatementNbInBody() );
+ assertEquals( 9,
+ drawHighlightIndicator.getStatementNbInBody() );
+ assertEquals( 21,
+ placeSortArrow.getStatementNbInBody() );
+ }
+
+ @Test
+ public void testIsGetter()
+ {
+ assertFalse( constructor.isGetter() );
+ assertFalse( drawHighlightIndicator.isGetter() );
+ assertFalse( isTrueSetter.isGetter() );
+ assertTrue( isTrueGetter.isGetter() );
+ }
+
+ @Test
+ public void testIsSetter()
+ {
+ assertFalse( constructor.isSetter() );
+ assertFalse( drawHighlightIndicator.isSetter() );
+ assertFalse( isTrueGetter.isSetter() );
+ assertTrue( isTrueSetter.isSetter() );
+ }
+
+ @Test
+ public void testLocalVariables()
+ {
+ assertEquals( 0,
+ constructor.getLocalVariables().size() );
+ assertEquals( 2,
+ drawHighlightIndicator.getLocalVariables().size() );
+ assertEquals( 13,
+ drawSelectionIndicator.getLocalVariables().size() );
+ assertEquals( 5,
+ drawRowBackground.getLocalVariables().size() );
+ }
+
+ @Test
+ public void testOverride()
+ {
+ assertTrue( drawHighlightIndicator.isOverriden() );
+ assertFalse( isTrueGetter.isOverriden() );
+ }
+
+ @Test
+ public void testSuperCall()
+ {
+ assertNotNull( constructor.getSuperCall() );
+ assertNotNull( drawHighlightIndicator.getSuperCall() );
+ assertNotNull( placeSortArrow.getSuperCall() );
+ assertNull( drawRowBackground.getSuperCall() );
+ }
+
+ @Test
+ public void testVisibility()
+ {
+ assertTrue( constructor.isPublic() );
+ assertTrue( drawHighlightIndicator.is( Modifier.PROTECTED ) );
+ assertTrue( drawSelectionIndicator.is( Modifier.PROTECTED ) );
+ assertTrue( drawRowBackground.is( Modifier.PROTECTED ) );
+ assertTrue( isTrueGetter.is( Modifier.PRIVATE ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/MetaDataNodeTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/MetaDataNodeTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/MetaDataNodeTest.java
new file mode 100644
index 0000000..24bbd9b
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/MetaDataNodeTest.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.nodes.impl;
+
+import static org.junit.Assert.assertEquals;
+import net.sourceforge.pmd.PMDException;
+
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+import com.adobe.ac.pmd.files.FileSetUtils;
+import com.adobe.ac.pmd.nodes.IMetaDataListHolder;
+import com.adobe.ac.pmd.nodes.MetaData;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+public class MetaDataNodeTest extends FlexPmdTestBase
+{
+ private final IMetaDataListHolder modelLocator;
+ private final IMetaDataListHolder unboundMetaData;
+
+ public MetaDataNodeTest() throws PMDException
+ {
+ super();
+
+ IParserNode ast = FileSetUtils.buildAst( getTestFiles().get( "cairngorm.BindableModelLocator.as" ) );
+ modelLocator = NodeFactory.createPackage( ast ).getClassNode();
+ ast = FileSetUtils.buildAst( getTestFiles().get( "UnboundMetadata.as" ) );
+ unboundMetaData = NodeFactory.createPackage( ast ).getClassNode();
+ }
+
+ @Test
+ public void testEmbed() throws PMDException
+ {
+ final IParserNode titleNode = FileSetUtils.buildAst( getTestFiles().get( "Title.as" ) );
+
+ final IMetaDataListHolder show = NodeFactory.createPackage( titleNode )
+ .getClassNode()
+ .getConstants()
+ .get( 0 );
+ assertEquals( MetaData.EMBED.toString(),
+ show.getMetaData( MetaData.EMBED ).get( 0 ).getName() );
+
+ }
+
+ @Test
+ public void testGetAttributeNames()
+ {
+ assertEquals( 2,
+ unboundMetaData.getMetaData( MetaData.EVENT ).get( 0 ).getAttributeNames().size() );
+ assertEquals( "name",
+ unboundMetaData.getMetaData( MetaData.EVENT ).get( 0 ).getAttributeNames().get( 0 ) );
+ assertEquals( "type",
+ unboundMetaData.getMetaData( MetaData.EVENT ).get( 0 ).getAttributeNames().get( 1 ) );
+ }
+
+ @Test
+ public void testGetDefaultValue()
+ {
+ assertEquals( "",
+ modelLocator.getMetaData( MetaData.BINDABLE ).get( 0 ).getDefaultValue() );
+ assertEquals( "name = \"dayChange\" , type = \'mx.events.StateChangeEvent\'",
+ unboundMetaData.getMetaData( MetaData.EVENT ).get( 0 ).getDefaultValue() );
+ }
+
+ @Test
+ public void testGetMetaDataName()
+ {
+ assertEquals( MetaData.BINDABLE.toString(),
+ modelLocator.getMetaData( MetaData.BINDABLE ).get( 0 ).getName() );
+ assertEquals( MetaData.EVENT.toString(),
+ unboundMetaData.getMetaData( MetaData.EVENT ).get( 0 ).getName() );
+ }
+
+ @Test
+ public void testGetProperty()
+ {
+ assertEquals( 1,
+ unboundMetaData.getMetaData( MetaData.EVENT ).get( 0 ).getProperty( "name" ).length );
+ assertEquals( "dayChange",
+ unboundMetaData.getMetaData( MetaData.EVENT ).get( 0 ).getProperty( "name" )[ 0 ] );
+ assertEquals( 1,
+ unboundMetaData.getMetaData( MetaData.EVENT ).get( 0 ).getProperty( "type" ).length );
+ assertEquals( "mx.events.StateChangeEvent",
+ unboundMetaData.getMetaData( MetaData.EVENT ).get( 0 ).getProperty( "type" )[ 0 ] );
+ }
+
+ @Test
+ public void testGetPropertyAsList()
+ {
+ assertEquals( 1,
+ unboundMetaData.getMetaData( MetaData.EVENT ).get( 0 ).getPropertyAsList( "name" ).size() );
+ assertEquals( "dayChange",
+ unboundMetaData.getMetaData( MetaData.EVENT )
+ .get( 0 )
+ .getPropertyAsList( "name" )
+ .get( 0 ) );
+ assertEquals( 1,
+ unboundMetaData.getMetaData( MetaData.EVENT ).get( 0 ).getPropertyAsList( "type" ).size() );
+ assertEquals( "mx.events.StateChangeEvent",
+ unboundMetaData.getMetaData( MetaData.EVENT )
+ .get( 0 )
+ .getPropertyAsList( "type" )
+ .get( 0 ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/PackageNodeTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/PackageNodeTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/PackageNodeTest.java
new file mode 100644
index 0000000..de9dfd9
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/PackageNodeTest.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.nodes.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+
+import net.sourceforge.pmd.PMDException;
+
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+import com.adobe.ac.pmd.files.FileSetUtils;
+import com.adobe.ac.pmd.nodes.IPackage;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.parser.exceptions.TokenException;
+
+public class PackageNodeTest extends FlexPmdTestBase
+{
+ private final IPackage buttonRenderer;
+ private final IPackage FlexPMD115Package;
+ private final IPackage FlexPMD62Package;
+ private final IPackage modelLocator;
+ private final IPackage stylePackage;
+
+ public PackageNodeTest() throws PMDException
+ {
+ final IParserNode ast = FileSetUtils.buildAst( getTestFiles().get( "SkinStyles.as" ) );
+ stylePackage = NodeFactory.createPackage( ast );
+
+ final IParserNode buttonRendererAst = FileSetUtils.buildAst( getTestFiles().get( "DeleteButtonRenderer.mxml" ) );
+ buttonRenderer = NodeFactory.createPackage( buttonRendererAst );
+
+ final IParserNode modelLocatorAst = FileSetUtils.buildAst( getTestFiles().get( "cairngorm."
+ + "NonBindableModelLocator.as" ) );
+ modelLocator = NodeFactory.createPackage( modelLocatorAst );
+
+ final IParserNode bug62Ast = FileSetUtils.buildAst( getTestFiles().get( "bug."
+ + "FlexPMD62.as" ) );
+ FlexPMD62Package = NodeFactory.createPackage( bug62Ast );
+
+ final IParserNode bug115Ast = FileSetUtils.buildAst( getTestFiles().get( "bug."
+ + "FlexPMD115.as" ) );
+ FlexPMD115Package = NodeFactory.createPackage( bug115Ast );
+ }
+
+ @Test
+ public void testConstructMxmlFile() throws IOException,
+ TokenException,
+ PMDException
+ {
+ assertNotNull( buttonRenderer.getClassNode() );
+ assertEquals( "",
+ buttonRenderer.getName() );
+ assertEquals( 0,
+ buttonRenderer.getImports().size() );
+
+ }
+
+ @Test
+ public void testConstructNamespace() throws IOException,
+ TokenException,
+ PMDException
+ {
+ final IParserNode ast = FileSetUtils.buildAst( getTestFiles().get( "schedule_internal.as" ) );
+ final IPackage namespacePackage = NodeFactory.createPackage( ast );
+
+ assertNull( namespacePackage.getClassNode() );
+ assertEquals( "flexlib.scheduling.scheduleClasses",
+ namespacePackage.getName() );
+ assertEquals( 0,
+ namespacePackage.getImports().size() );
+ }
+
+ @Test
+ public void testConstructStyles()
+ {
+ assertNull( stylePackage.getClassNode() );
+ assertEquals( "",
+ stylePackage.getName() );
+ assertEquals( 0,
+ stylePackage.getImports().size() );
+ }
+
+ @Test
+ public void testFullyQualifiedName()
+ {
+ assertEquals( "",
+ stylePackage.getFullyQualifiedClassName() );
+ assertEquals( "DeleteButtonRenderer",
+ buttonRenderer.getFullyQualifiedClassName() );
+ assertEquals( "com.adobe.ac.sample.model.ModelLocator",
+ modelLocator.getFullyQualifiedClassName() );
+ }
+
+ @Test
+ public void testGetFunctions()
+ {
+ assertEquals( 0,
+ stylePackage.getFunctions().size() );
+ }
+
+ @Test
+ public void testGetName()
+ {
+ assertEquals( "com.test.testy.ui.components",
+ FlexPMD62Package.getName() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/VariableNodeTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/VariableNodeTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/VariableNodeTest.java
new file mode 100644
index 0000000..370a012
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/impl/VariableNodeTest.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.nodes.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import net.sourceforge.pmd.PMDException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+import com.adobe.ac.pmd.files.FileSetUtils;
+import com.adobe.ac.pmd.nodes.IAttribute;
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+public class VariableNodeTest extends FlexPmdTestBase
+{
+ private IAttribute first;
+
+ @Before
+ public void setup() throws PMDException
+ {
+ final IParserNode ast = FileSetUtils.buildAst( getTestFiles().get( "cairngorm.NonBindableModelLocator.as" ) );
+ final IClass nonBindableModelLocator = NodeFactory.createPackage( ast ).getClassNode();
+ first = nonBindableModelLocator.getAttributes().get( 0 );
+ }
+
+ @Test
+ public void testGetAllMetaData()
+ {
+ assertEquals( 0,
+ first.getAllMetaData().size() );
+ }
+
+ @Test
+ public void testGetInitializationExpression()
+ {
+ assertNull( first.getInitializationExpression() );
+ }
+
+ @Test
+ public void testGetMetaDataCount()
+ {
+ assertEquals( 0,
+ first.getMetaDataCount() );
+ }
+
+ @Test
+ public void testGetName()
+ {
+ assertEquals( "_instance",
+ first.getName() );
+ }
+
+ @Test
+ public void testGetType()
+ {
+ assertEquals( "ModelLocator",
+ first.getType().toString() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/utils/AsDocUtilsTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/utils/AsDocUtilsTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/utils/AsDocUtilsTest.java
new file mode 100644
index 0000000..28acd8b
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/utils/AsDocUtilsTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.nodes.utils;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.adobe.ac.pmd.nodes.asdoc.impl.ClassAsDocNode;
+import com.adobe.ac.pmd.nodes.asdoc.impl.FunctionAsDocNode;
+import com.adobe.ac.pmd.nodes.asdoc.impl.ParameterAsDocNode;
+
+public class AsDocUtilsTest
+{
+ @Test
+ public void testComputeClassDoc()
+ {
+ final ClassAsDocNode emptyDoc = AsDocUtils.computeClassDoc( "" );
+
+ assertEquals( "",
+ emptyDoc.getDescription() );
+
+ AsDocUtils.computeClassDoc( "/** description \n * description2\n @see mx.kjnerkjlef.btbt*/" );
+ }
+
+ @Test
+ public void testComputeFunctionDoc()
+ {
+ final FunctionAsDocNode emptyDoc = AsDocUtils.computeFunctionDoc( "" );
+
+ assertEquals( "",
+ emptyDoc.getDescription() );
+
+ final FunctionAsDocNode functionDoc = AsDocUtils.computeFunctionDoc( "/** description \n * description2\n @see mx.kjnerkjlef.btbt*/" );
+
+ final ParameterAsDocNode parameter = AsDocUtils.computeParameterDoc( "name",
+ "description" );
+ functionDoc.addParameter( parameter );
+
+ assertEquals( parameter,
+ functionDoc.getParameter( 0 ) );
+
+ assertEquals( "name",
+ parameter.getName() );
+
+ assertEquals( "description",
+ parameter.getDescription() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/utils/FunctionUtilsTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/utils/FunctionUtilsTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/utils/FunctionUtilsTest.java
new file mode 100644
index 0000000..b0ef8de
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/nodes/utils/FunctionUtilsTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.nodes.utils;
+
+import static org.junit.Assert.assertEquals;
+import net.sourceforge.pmd.PMDException;
+
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+import com.adobe.ac.pmd.files.FileSetUtils;
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.impl.NodeFactory;
+import com.adobe.ac.pmd.parser.IParserNode;
+
+public class FunctionUtilsTest extends FlexPmdTestBase
+{
+ @Test
+ public void testComputeFunctionLength() throws PMDException
+ {
+ final IFlexFile file = getTestFiles().get( "RadonDataGrid.as" );
+ final IParserNode dataGridAst = FileSetUtils.buildAst( file );
+ final IClass radonDataGrid = NodeFactory.createPackage( dataGridAst ).getClassNode();
+
+ assertEquals( 6,
+ FunctionUtils.computeFunctionLength( file,
+ radonDataGrid.getFunctions().get( 0 ).getBody() ) );
+
+ assertEquals( 9,
+ FunctionUtils.computeFunctionLength( file,
+ radonDataGrid.getFunctions().get( 1 ).getBody() ) );
+
+ assertEquals( 21,
+ FunctionUtils.computeFunctionLength( file,
+ radonDataGrid.getFunctions().get( 2 ).getBody() ) );
+
+ assertEquals( 16,
+ FunctionUtils.computeFunctionLength( file,
+ radonDataGrid.getFunctions().get( 3 ).getBody() ) );
+
+ assertEquals( 10,
+ FunctionUtils.computeFunctionLength( file,
+ radonDataGrid.getFunctions().get( 4 ).getBody() ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/rules/core/EmptyRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/rules/core/EmptyRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/rules/core/EmptyRule.java
new file mode 100644
index 0000000..43df42d
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/rules/core/EmptyRule.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.adobe.ac.pmd.IFlexViolation;
+import com.adobe.ac.pmd.rules.core.ViolationPosition;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.AbstractMaximizedFlexRule;
+
+public class EmptyRule extends AbstractMaximizedFlexRule
+{
+ public int getActualValueForTheCurrentViolation()
+ {
+ return 0;
+ }
+
+ public int getDefaultThreshold()
+ {
+ return 10;
+ }
+
+ @Override
+ public String getDescription()
+ {
+ return "description";
+ }
+
+ @Override
+ public String getMessage()
+ {
+ return "emptyMessage";
+ }
+
+ @Override
+ public int getThreshold()
+ {
+ return getDefaultThreshold();
+ }
+
+ @Override
+ public final boolean isConcernedByTheCurrentFile()
+ {
+ return true;
+ }
+
+ @Override
+ protected List< IFlexViolation > findViolationsInCurrentFile()
+ {
+ final ArrayList< IFlexViolation > violations = new ArrayList< IFlexViolation >();
+
+ addViolation( violations,
+ new ViolationPosition( 0 ) );
+
+ return violations;
+ }
+
+ @Override
+ protected ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.LOW;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/rules/core/EmptyRuleTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/rules/core/EmptyRuleTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/rules/core/EmptyRuleTest.java
new file mode 100644
index 0000000..18c5c8c
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset-api/src/test/java/com/adobe/ac/pmd/rules/core/EmptyRuleTest.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.core;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+import com.adobe.ac.pmd.FlexPmdTestBase;
+import com.adobe.ac.pmd.IFlexViolation;
+import com.adobe.ac.pmd.rules.core.AbstractFlexRuleTest.AssertPosition;
+
+public class EmptyRuleTest extends FlexPmdTestBase
+{
+ @Test
+ public void addViolationEmptyRule()
+ {
+ final List< IFlexViolation > violatons = new EmptyRule().processFile( null,
+ null,
+ null );
+
+ assertEquals( 1,
+ violatons.size() );
+
+ final IFlexViolation firstViolation = violatons.get( 0 );
+
+ assertEquals( 0,
+ firstViolation.getBeginLine() );
+ assertEquals( 0,
+ firstViolation.getEndLine() );
+ assertEquals( "emptyMessage. description",
+ firstViolation.getRuleMessage() );
+ }
+
+ @Test
+ public void addViolationWarningRule()
+ {
+ final List< IFlexViolation > violatons = new WarningRule().processFile( null,
+ null,
+ null );
+
+ assertEquals( 1,
+ violatons.size() );
+
+ final IFlexViolation firstViolation = violatons.get( 0 );
+
+ assertEquals( 0,
+ firstViolation.getBeginLine() );
+ assertEquals( 0,
+ firstViolation.getEndLine() );
+ assertEquals( "warning message",
+ firstViolation.getRuleMessage() );
+ }
+
+ @Test
+ public void testBuildFailuresMessage()
+ {
+ final ArrayList< AssertPosition > position = new ArrayList< AssertPosition >();
+
+ position.add( AssertPosition.create( "message",
+ 1,
+ 2 ) );
+
+ assertEquals( "message: expected <1> but actually <2>\n",
+ AbstractFlexRuleTest.buildFailuresMessage( position ).toString() );
+ }
+
+ @Test
+ public void testBuildFailureViolations()
+ {
+ final ViolationPosition[] expectedPositions = new ViolationPosition[]
+ { new ViolationPosition( 0 ) };
+ final ArrayList< IFlexViolation > violations = new ArrayList< IFlexViolation >();
+
+ violations.add( new Violation( new ViolationPosition( 1 ), new EmptyRule(), null ) );
+
+ final List< AssertPosition > positions = AbstractFlexRuleTest.buildFailureViolations( "",
+ expectedPositions,
+ violations );
+
+ assertEquals( 2,
+ positions.size() );
+ assertEquals( "Begining line is not correct at 0th violation on ",
+ positions.get( 0 ).message );
+ assertEquals( "Ending line is not correct at 0th violation on ",
+ positions.get( 1 ).message );
+ }
+
+ @Test
+ public void testBuildMessageName()
+ {
+ final Map< String, List< IFlexViolation >> violatedFiles = new LinkedHashMap< String, List< IFlexViolation > >();
+ final ArrayList< IFlexViolation > emptyList = new ArrayList< IFlexViolation >();
+
+ violatedFiles.put( "file1",
+ emptyList );
+
+ violatedFiles.put( "file2",
+ emptyList );
+
+ assertEquals( "file1 should not contain any violations (0 found)\n"
+ + "file2 should not contain any violations (0 found)\n",
+ AbstractFlexRuleTest.buildMessageName( violatedFiles ).toString() );
+
+ final ArrayList< IFlexViolation > oneItemList = new ArrayList< IFlexViolation >();
+
+ oneItemList.add( new Violation( new ViolationPosition( 0 ), new EmptyRule(), null ) );
+ violatedFiles.put( "file2",
+ oneItemList );
+
+ assertEquals( "file1 should not contain any violations (0 found)\n"
+ + "file2 should not contain any violations (1 found at 0:0)\n",
+ AbstractFlexRuleTest.buildMessageName( violatedFiles ).toString() );
+ }
+}