flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cd...@apache.org
Subject [15/24] git commit: [flex-utilities] [refs/heads/feature/pmd-5.2-language-module] - Initial commit of the PMD language module for Apache Flex
Date Sat, 07 Mar 2015 12:07:08 GMT
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/FatControllerRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/FatControllerRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/FatControllerRule.java
new file mode 100644
index 0000000..5468b61
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/FatControllerRule.java
@@ -0,0 +1,88 @@
+/*
+ * 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 org.apache.flex.pmd.rules.cairngorm;
+
+import org.apache.flex.pmd.nodes.IClass;
+import org.apache.flex.pmd.nodes.IPackage;
+import org.apache.flex.pmd.parser.IParserNode;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.List;
+
+/**
+ * @author xagnetti
+ */
+public class FatControllerRule extends AbstractAstFlexRule // NO_UCD
+{
+    private static final int DEFAULT_THRESHOLD = 5;
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+     * ()
+     */
+    @Override
+    public final boolean isConcernedByTheCurrentFile() {
+        return getCurrentFile().getClassName().endsWith("Controller.as");
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IPackage)
+     */
+    @Override
+    protected final void findViolations(final IPackage packageNode) {
+        final IClass classNode = packageNode.getClassNode();
+
+        if (classNode != null) {
+            final int commandsCount = computeCommandsCountInImport(packageNode.getImports());
+            final int methodsCount = classNode.getFunctions().size();
+
+            if (methodsCount > 0
+                    && commandsCount
+                    / methodsCount > DEFAULT_THRESHOLD) {
+                addViolation(classNode);
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+
+    private int computeCommandsCountInImport(final List<IParserNode> imports) {
+        int commandImport = 0;
+
+        if (imports != null) {
+            for (final IParserNode importNode : imports) {
+                if (importNode.getStringValue().endsWith("Command")) {
+                    commandImport++;
+                }
+            }
+        }
+        return commandImport;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/ModelLocatorReferencedMoreThanOncePerClassRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/ModelLocatorReferencedMoreThanOncePerClassRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/ModelLocatorReferencedMoreThanOncePerClassRule.java
new file mode 100644
index 0000000..d8aba94
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/ModelLocatorReferencedMoreThanOncePerClassRule.java
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.flex.pmd.rules.cairngorm;
+
+/**
+ * @author xagnetti
+ */
+public class ModelLocatorReferencedMoreThanOncePerClassRule extends
+        ReferenceModelLocatorOutsideTheMainApplicationRule {
+    private int referencesPerFile;
+
+    /*
+     * (non-Javadoc)
+     * @seecom.adobe.ac.pmd.rules.cairngorm.
+     * ReferenceModelLocatorOutsideTheMainApplicationRule
+     * #isViolationDetectedOnThisMatchingLine(java.lang.String)
+     */
+    @Override
+    protected final boolean isViolationDetectedOnThisMatchingLine(final String line) {
+        if (!line.contains("import")
+                && !line.contains("return")) {
+            referencesPerFile++;
+        }
+        return referencesPerFile > 1;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#onRuleStart()
+     */
+    @Override
+    protected final void onRuleStart() {
+        referencesPerFile = 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/ReferenceModelLocatorOutsideTheMainApplicationRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/ReferenceModelLocatorOutsideTheMainApplicationRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/ReferenceModelLocatorOutsideTheMainApplicationRule.java
new file mode 100644
index 0000000..02446fc
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/ReferenceModelLocatorOutsideTheMainApplicationRule.java
@@ -0,0 +1,67 @@
+/*
+ * 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 org.apache.flex.pmd.rules.cairngorm;
+
+import org.apache.flex.pmd.parser.KeyWords;
+import org.apache.flex.pmd.rules.core.AbstractRegexpBasedRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class ReferenceModelLocatorOutsideTheMainApplicationRule extends AbstractRegexpBasedRule // NO_UCD
+{
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+     */
+    @Override
+    public final boolean isConcernedByTheCurrentFile() {
+        return !getCurrentFile().getClassName().endsWith("ModelLocator.as")
+                && (!getCurrentFile().isMxml() || !getCurrentFile().isMainApplication());
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+     */
+    @Override
+    protected final String getRegexp() {
+        return ".*ModelLocator.*";
+    }
+
+    /*
+     * (non-Javadoc)
+     * @seecom.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#
+     * isViolationDetectedOnThisMatchingLine(java.lang.String)
+     */
+    @Override
+    protected boolean isViolationDetectedOnThisMatchingLine(final String line) {
+        return true; /*!line.contains(KeyWords.IMPORT.toString())
+                && !line.contains(AS3Parser.SINGLE_LINE_COMMENT);*/
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/component/CallLaterDirectlyRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/component/CallLaterDirectlyRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/component/CallLaterDirectlyRule.java
new file mode 100644
index 0000000..505f0df
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/component/CallLaterDirectlyRule.java
@@ -0,0 +1,58 @@
+/*
+ * 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 org.apache.flex.pmd.rules.component;
+
+import org.apache.flex.pmd.nodes.IFunction;
+import org.apache.flex.pmd.parser.IParserNode;
+import org.apache.flex.pmd.rules.core.AbstractPrimaryAstRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class CallLaterDirectlyRule extends AbstractPrimaryAstRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#addViolation(com.adobe
+     * .ac.pmd.parser.IParserNode, com.adobe.ac.pmd.nodes.IFunction)
+     */
+    @Override
+    protected void addViolation(final IParserNode statement,
+                                final IFunction function) {
+        addViolation(statement);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.HIGH;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#getFirstPrimaryToFind()
+     */
+    @Override
+    protected String getFirstPrimaryToFind() {
+        return "callLater";
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/component/UpdateChildrenNumberInUpdateDisplayListRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/component/UpdateChildrenNumberInUpdateDisplayListRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/component/UpdateChildrenNumberInUpdateDisplayListRule.java
new file mode 100644
index 0000000..59781e7
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/component/UpdateChildrenNumberInUpdateDisplayListRule.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 org.apache.flex.pmd.rules.component;
+
+import org.apache.flex.pmd.nodes.IFunction;
+import org.apache.flex.pmd.parser.IParserNode;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class UpdateChildrenNumberInUpdateDisplayListRule extends AbstractAstFlexRule // NO_UCD
+{
+    private static final String[] METHOD_NAMES =
+            {"addChild",
+                    "addChildAt",
+                    "removeChild",
+                    "removeChildAt"};
+    private static final String UPDATE_DISPLAY_LIST = "updateDisplayList";
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IFunction)
+     */
+    @Override
+    protected final void findViolations(final IFunction function) {
+        if (function.getName().equals(UPDATE_DISPLAY_LIST)) {
+            for (final String methodName : METHOD_NAMES) {
+                for (final IParserNode statement : function.findPrimaryStatementsInBody(methodName)) {
+                    addViolation(statement);
+                }
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.HIGH;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/css/StyleBlockInMxmlRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/css/StyleBlockInMxmlRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/css/StyleBlockInMxmlRule.java
new file mode 100644
index 0000000..240e425
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/css/StyleBlockInMxmlRule.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 org.apache.flex.pmd.rules.css;
+
+import org.apache.flex.pmd.rules.core.AbstractRegexpBasedRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class StyleBlockInMxmlRule extends AbstractRegexpBasedRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+     */
+    @Override
+    public final boolean isConcernedByTheCurrentFile() {
+        return getCurrentFile().isMxml();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+     */
+    @Override
+    protected final String getRegexp() {
+        return ".*<mx:Style>.*";
+    }
+
+    /*
+     * (non-Javadoc)
+     * @seecom.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#
+     * isViolationDetectedOnThisMatchingLine(java.lang.String)
+     */
+    @Override
+    protected final boolean isViolationDetectedOnThisMatchingLine(final String line) {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/css/UseCssInsteadOfEmbedMetaDataRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/css/UseCssInsteadOfEmbedMetaDataRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/css/UseCssInsteadOfEmbedMetaDataRule.java
new file mode 100644
index 0000000..d4de1ad
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/css/UseCssInsteadOfEmbedMetaDataRule.java
@@ -0,0 +1,73 @@
+/*
+ * 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 org.apache.flex.pmd.rules.css;
+
+import org.apache.flex.pmd.nodes.*;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.List;
+
+/**
+ * @author xagnetti
+ */
+public class UseCssInsteadOfEmbedMetaDataRule extends AbstractAstFlexRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromAttributes
+     * (java.util.List)
+     */
+    @Override
+    protected final void findViolationsFromAttributes(final List<IAttribute> variables) {
+        super.findViolationsFromAttributes(variables);
+
+        findViolationsInMetaDataList(variables);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromConstants
+     * (java.util.List)
+     */
+    @Override
+    protected final void findViolationsFromConstants(final List<IConstant> constants) {
+        super.findViolationsFromConstants(constants);
+
+        findViolationsInMetaDataList(constants);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.LOW;
+    }
+
+    private void findViolationsInMetaDataList(final List<? extends IMetaDataListHolder> metaDataList) {
+        for (final IMetaDataListHolder metaData : metaDataList) {
+            final List<IMetaData> embedList = metaData.getMetaData(MetaData.EMBED);
+
+            if (embedList != null) {
+                addViolation(embedList.get(0));
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/empty/AbstractEmptyBlockRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/empty/AbstractEmptyBlockRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/empty/AbstractEmptyBlockRule.java
new file mode 100644
index 0000000..a5def99
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/empty/AbstractEmptyBlockRule.java
@@ -0,0 +1,35 @@
+/*
+ * 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 org.apache.flex.pmd.rules.empty;
+
+import org.apache.flex.pmd.parser.IParserNode;
+import org.apache.flex.pmd.parser.NodeKind;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public abstract class AbstractEmptyBlockRule extends AbstractAstFlexRule {
+    /**
+     * @param block
+     * @return
+     */
+    protected static boolean isBlockEmpty(final IParserNode block) {
+        return block.is(NodeKind.BLOCK)
+                && block.numChildren() == 0 || block.is(NodeKind.STMT_EMPTY);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/empty/EmptyCatchStatementRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/empty/EmptyCatchStatementRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/empty/EmptyCatchStatementRule.java
new file mode 100644
index 0000000..62691fc
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/empty/EmptyCatchStatementRule.java
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.flex.pmd.rules.empty;
+
+import org.apache.flex.pmd.parser.IParserNode;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class EmptyCatchStatementRule extends AbstractEmptyBlockRule {
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitCatch(com.adobe.ac
+     * .pmd.parser.IParserNode)
+     */
+    @Override
+    protected final void visitCatch(final IParserNode ast) {
+        super.visitCatch(ast);
+
+        if (isBlockEmpty(ast.getChild(2))) {
+            addViolation(ast);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/empty/EmptyIfStmtRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/empty/EmptyIfStmtRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/empty/EmptyIfStmtRule.java
new file mode 100644
index 0000000..732c345
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/empty/EmptyIfStmtRule.java
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.flex.pmd.rules.empty;
+
+import org.apache.flex.pmd.parser.IParserNode;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class EmptyIfStmtRule extends AbstractEmptyBlockRule {
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitIf(com.adobe.ac.pmd
+     * .parser.IParserNode)
+     */
+    @Override
+    protected final void visitIf(final IParserNode ast) {
+        super.visitIf(ast);
+
+        if (isBlockEmpty(ast.getChild(1))) {
+            addViolation(ast);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/AbstractEventRelatedRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/AbstractEventRelatedRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/AbstractEventRelatedRule.java
new file mode 100644
index 0000000..c481474
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/AbstractEventRelatedRule.java
@@ -0,0 +1,50 @@
+/*
+ * 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 org.apache.flex.pmd.rules.event;
+
+import org.apache.flex.pmd.nodes.IClass;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public abstract class AbstractEventRelatedRule extends AbstractAstFlexRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+     * ()
+     */
+    @Override
+    public final boolean isConcernedByTheCurrentFile() {
+        return !getCurrentFile().isMxml();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IClass)
+     */
+    @Override
+    protected void findViolations(final IClass classNode) {
+        if (classNode.getExtensionName() != null
+                && classNode.getExtensionName().endsWith("Event")) {
+            super.findViolations(classNode);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/ConstructorDispatchingEventRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/ConstructorDispatchingEventRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/ConstructorDispatchingEventRule.java
new file mode 100644
index 0000000..20b5e07
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/ConstructorDispatchingEventRule.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 org.apache.flex.pmd.rules.event;
+
+import org.apache.flex.pmd.nodes.IFunction;
+import org.apache.flex.pmd.parser.IParserNode;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class ConstructorDispatchingEventRule extends AbstractAstFlexRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+     * ()
+     */
+    @Override
+    public final boolean isConcernedByTheCurrentFile() {
+        return !getCurrentFile().isMxml();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromConstructor
+     * (com.adobe.ac.pmd.nodes.IFunction)
+     */
+    @Override
+    protected final void findViolationsFromConstructor(final IFunction constructor) {
+        for (final IParserNode statement : constructor.findPrimaryStatementsInBody("dispatchEvent")) {
+            addViolation(statement);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.HIGH;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/DefaultEventNameRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/DefaultEventNameRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/DefaultEventNameRule.java
new file mode 100644
index 0000000..28e888e
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/DefaultEventNameRule.java
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.flex.pmd.rules.event;
+
+import org.apache.flex.pmd.nodes.IFunction;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class DefaultEventNameRule extends AbstractEventRelatedRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromConstructor
+     * (com.adobe.ac.pmd.nodes.IFunction)
+     */
+    @Override
+    protected final void findViolationsFromConstructor(final IFunction constructor) {
+        if (constructor.getParameters().size() > 0
+                && constructor.getParameters().get(0).getType().toString().equals("String")
+                && constructor.getParameters().get(0).getInitializationExpression() != null) {
+            addViolation(constructor.getParameters().get(0));
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.HIGH;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/DispatchHardCodedEventNameRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/DispatchHardCodedEventNameRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/DispatchHardCodedEventNameRule.java
new file mode 100644
index 0000000..b9ece3f
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/DispatchHardCodedEventNameRule.java
@@ -0,0 +1,74 @@
+/*
+ * 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 org.apache.flex.pmd.rules.event;
+
+import org.apache.flex.pmd.rules.core.AbstractRegexpBasedRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class DispatchHardCodedEventNameRule extends AbstractRegexpBasedRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+     */
+    @Override
+    public final boolean isConcernedByTheCurrentFile() {
+        return true;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+     */
+    @Override
+    protected final String getRegexp() {
+        return ".*dispatchEvent *\\( *new Event\\( *(\"|\').*(\"|\') *\\) *\\).*";
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#isCurrentLineConcerned
+     * (java.lang.String)
+     */
+    @Override
+    protected boolean isCurrentLineConcerned(final String line) {
+        return line.contains("dispatchEvent");
+    }
+
+    /*
+     * (non-Javadoc)
+     * @seecom.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#
+     * isViolationDetectedOnThisMatchingLine(java.lang.String)
+     */
+    @Override
+    protected final boolean isViolationDetectedOnThisMatchingLine(final String line) {
+        return getMatcher(line).matches();
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/EventMissingCloneFunctionRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/EventMissingCloneFunctionRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/EventMissingCloneFunctionRule.java
new file mode 100644
index 0000000..df5ef10
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/EventMissingCloneFunctionRule.java
@@ -0,0 +1,74 @@
+/*
+ * 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 org.apache.flex.pmd.rules.event;
+
+import org.apache.flex.pmd.nodes.IClass;
+import org.apache.flex.pmd.nodes.IFunction;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.List;
+
+/**
+ * @author xagnetti
+ */
+public class EventMissingCloneFunctionRule extends AbstractEventRelatedRule {
+    private IClass classNode = null;
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.event.AbstractEventRelatedRule#findViolations(com
+     * .adobe.ac.pmd.nodes.IClass)
+     */
+    @Override
+    protected final void findViolations(final IClass classNodeToBeSet) {
+        classNode = classNodeToBeSet;
+        if ("Event".equals(classNode.getExtensionName())) {
+            super.findViolations(classNode);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(java.util
+     * .List)
+     */
+    @Override
+    protected final void findViolations(final List<IFunction> functions) {
+        boolean cloneFound = false;
+
+        for (final IFunction functionNode : functions) {
+            if ("clone".equals(functionNode.getName())) {
+                cloneFound = true;
+                break;
+            }
+        }
+        if (!cloneFound) {
+            addViolation(classNode);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.HIGH;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/ListenForHardCodedEventNameRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/ListenForHardCodedEventNameRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/ListenForHardCodedEventNameRule.java
new file mode 100644
index 0000000..1f241f8
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/ListenForHardCodedEventNameRule.java
@@ -0,0 +1,74 @@
+/*
+ * 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 org.apache.flex.pmd.rules.event;
+
+import org.apache.flex.pmd.rules.core.AbstractRegexpBasedRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class ListenForHardCodedEventNameRule extends AbstractRegexpBasedRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+     */
+    @Override
+    public final boolean isConcernedByTheCurrentFile() {
+        return true;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+     */
+    @Override
+    protected final String getRegexp() {
+        return ".*addEventListener *\\( *(\"|\').*(\"|\').*";
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#isCurrentLineConcerned
+     * (java.lang.String)
+     */
+    @Override
+    protected boolean isCurrentLineConcerned(final String line) {
+        return line.contains("addEventListener");
+    }
+
+    /*
+     * (non-Javadoc)
+     * @seecom.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#
+     * isViolationDetectedOnThisMatchingLine(java.lang.String)
+     */
+    @Override
+    protected final boolean isViolationDetectedOnThisMatchingLine(final String line) {
+        return getMatcher(line).matches();
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/PublicVariableInCustomEventRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/PublicVariableInCustomEventRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/PublicVariableInCustomEventRule.java
new file mode 100644
index 0000000..e120816
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/PublicVariableInCustomEventRule.java
@@ -0,0 +1,52 @@
+/*
+ * 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 org.apache.flex.pmd.rules.event;
+
+import org.apache.flex.pmd.nodes.IAttribute;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.List;
+
+/**
+ * @author xagnetti
+ */
+public class PublicVariableInCustomEventRule extends AbstractEventRelatedRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromAttributes
+     * (java.util.List)
+     */
+    @Override
+    protected final void findViolationsFromAttributes(final List<IAttribute> variables) {
+        for (final IAttribute attribute : variables) {
+            if (attribute.isPublic()) {
+                addViolation(attribute,
+                        attribute.getName());
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/UnboundTypeInMetadataRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/UnboundTypeInMetadataRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/UnboundTypeInMetadataRule.java
new file mode 100644
index 0000000..679ca4f
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/UnboundTypeInMetadataRule.java
@@ -0,0 +1,75 @@
+/*
+ * 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 org.apache.flex.pmd.rules.event;
+
+import org.apache.flex.pmd.files.IFlexFile;
+import org.apache.flex.pmd.nodes.IClass;
+import org.apache.flex.pmd.nodes.IMetaData;
+import org.apache.flex.pmd.nodes.MetaData;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author xagnetti
+ */
+public class UnboundTypeInMetadataRule extends AbstractAstFlexRule {
+    private static final String TYPE = "type";
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IClass)
+     */
+    @Override
+    protected final void findViolations(final IClass classNode) {
+        final List<IMetaData> eventMetaDatas = classNode.getMetaData(MetaData.EVENT);
+
+        if (eventMetaDatas != null) {
+            findViolationsInMetaDataNode(eventMetaDatas,
+                    getFilesInSourcePath());
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+
+    private void findViolationsInMetaDataNode(final List<IMetaData> eventMetaDatas,
+                                              final Map<String, IFlexFile> files) {
+        for (final IMetaData metaData : eventMetaDatas) {
+            if (metaData.getProperty(TYPE).length > 0) {
+                final String type = metaData.getProperty(TYPE)[0];
+
+                if (!files.containsKey(type
+                        + ".as")
+                        && !type.startsWith("mx.") && !type.startsWith("flash.")) {
+                    addViolation(metaData,
+                            type);
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/UntypedEventMetadataRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/UntypedEventMetadataRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/UntypedEventMetadataRule.java
new file mode 100644
index 0000000..c7f88e5
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/event/UntypedEventMetadataRule.java
@@ -0,0 +1,64 @@
+/*
+ * 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 org.apache.flex.pmd.rules.event;
+
+import org.apache.flex.pmd.nodes.IClass;
+import org.apache.flex.pmd.nodes.IMetaData;
+import org.apache.flex.pmd.nodes.MetaData;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.List;
+
+/**
+ * @author xagnetti
+ */
+public class UntypedEventMetadataRule extends AbstractAstFlexRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IClass)
+     */
+    @Override
+    protected final void findViolations(final IClass classNode) {
+        final List<IMetaData> eventMetaData = classNode.getMetaData(MetaData.EVENT);
+
+        if (eventMetaData != null) {
+            findViolationsInMetaDataNode(eventMetaData);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.LOW;
+    }
+
+    private void findViolationsInMetaDataNode(final List<IMetaData> eventMetaDatas) {
+        for (final IMetaData metaData : eventMetaDatas) {
+            final String metaDataValue = metaData.getInternalNode().getStringValue();
+
+            if (!metaDataValue.contains("type = ")) {
+                addViolation(metaData);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/flexunit/EmptyUnitTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/flexunit/EmptyUnitTest.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/flexunit/EmptyUnitTest.java
new file mode 100644
index 0000000..01535e1
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/flexunit/EmptyUnitTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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 org.apache.flex.pmd.rules.flexunit;
+
+import org.apache.flex.pmd.nodes.IClass;
+import org.apache.flex.pmd.nodes.IFunction;
+import org.apache.flex.pmd.nodes.MetaData;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public final class EmptyUnitTest extends AbstractAstFlexRule {
+    private static final String[] ASSERTIONS = new String[]
+            {"assertEquals",
+                    "assertObjectEquals",
+                    "assertMatch",
+                    "assertNoMatch",
+                    "assertContained",
+                    "assertNotContained",
+                    "assertStrictlyEquals",
+                    "assertTrue",
+                    "assertFalse",
+                    "assertNull",
+                    "assertNotNull",
+                    "assertUndefined",
+                    "assertNotUndefined",
+                    "assertThat",
+                    "handleEvent",
+                    "assertEvents",
+                    "fail"};
+
+    private boolean isExtendingTestCase;
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IClass)
+     */
+    @Override
+    protected void findViolations(final IClass classNode) {
+        isExtendingTestCase = classNode.getExtensionName() != null
+                && classNode.getExtensionName().endsWith("TestCase");
+
+        super.findViolations(classNode);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IFunction)
+     */
+    @Override
+    protected void findViolations(final IFunction function) {
+        super.findViolations(function);
+
+        if (isExtendingTestCase
+                && function.getName().startsWith("test")
+                && function.findPrimaryStatementInBody(ASSERTIONS).isEmpty()) {
+            addViolation(function);
+        }
+        if (!function.getMetaData(MetaData.TEST).isEmpty()
+                && function.findPrimaryStatementInBody(ASSERTIONS).isEmpty()) {
+            addViolation(function);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AlertShowRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AlertShowRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AlertShowRule.java
new file mode 100644
index 0000000..5d836a8
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AlertShowRule.java
@@ -0,0 +1,69 @@
+/*
+ * 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 org.apache.flex.pmd.rules.maintanability;
+
+import org.apache.flex.pmd.nodes.IFunction;
+import org.apache.flex.pmd.parser.IParserNode;
+import org.apache.flex.pmd.rules.core.AbstractPrimaryAstRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class AlertShowRule extends AbstractPrimaryAstRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#addViolation(com.adobe
+     * .ac.pmd.parser.IParserNode, com.adobe.ac.pmd.nodes.IFunction)
+     */
+    @Override
+    protected void addViolation(final IParserNode statement,
+                                final IFunction function) {
+        addViolation(statement);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.LOW;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#getFirstPrimaryToFind()
+     */
+    @Override
+    protected String getFirstPrimaryToFind() {
+        return "Alert";
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#getSecondPrimaryToFind
+     * ()
+     */
+    @Override
+    protected String getSecondPrimaryToFind() {
+        return "show";
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/ArrayFieldWithNoArrayElementTypeRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/ArrayFieldWithNoArrayElementTypeRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/ArrayFieldWithNoArrayElementTypeRule.java
new file mode 100644
index 0000000..4f8b0fa
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/ArrayFieldWithNoArrayElementTypeRule.java
@@ -0,0 +1,85 @@
+/*
+ * 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 org.apache.flex.pmd.rules.maintanability;
+
+import org.apache.flex.pmd.nodes.IAttribute;
+import org.apache.flex.pmd.nodes.IConstant;
+import org.apache.flex.pmd.nodes.IField;
+import org.apache.flex.pmd.nodes.MetaData;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.List;
+
+/**
+ * @author xagnetti
+ */
+public class ArrayFieldWithNoArrayElementTypeRule extends AbstractAstFlexRule {
+    private static final String ARRAY_TYPE = "Array";
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+     * ()
+     */
+    @Override
+    public boolean isConcernedByTheCurrentFile() {
+        return getCurrentFile().isMxml();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromAttributes
+     * (java.util.List)
+     */
+    @Override
+    protected final void findViolationsFromAttributes(final List<IAttribute> variables) {
+        findViolationFromFieds(variables);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromConstants
+     * (java.util.List)
+     */
+    @Override
+    protected void findViolationsFromConstants(final List<IConstant> constants) {
+        findViolationFromFieds(constants);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+
+    private void findViolationFromFieds(final List<? extends IField> fields) {
+        for (final IField variable : fields) {
+            if (ARRAY_TYPE.equals(variable.getType().toString())
+                    && variable.getMetaData(MetaData.ARRAY_ELEMENT_TYPE) == null) {
+                addViolation(variable,
+                        variable.getName());
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidProtectedFieldInFinalClassRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidProtectedFieldInFinalClassRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidProtectedFieldInFinalClassRule.java
new file mode 100644
index 0000000..a8c7bae
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidProtectedFieldInFinalClassRule.java
@@ -0,0 +1,81 @@
+/*
+ * 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 org.apache.flex.pmd.rules.maintanability;
+
+import org.apache.flex.pmd.nodes.IAttribute;
+import org.apache.flex.pmd.nodes.IClass;
+import org.apache.flex.pmd.nodes.IFunction;
+import org.apache.flex.pmd.nodes.Modifier;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.List;
+
+/**
+ * @author xagnetti
+ */
+public class AvoidProtectedFieldInFinalClassRule extends AbstractAstFlexRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IClass)
+     */
+    @Override
+    protected final void findViolations(final IClass classNode) {
+        final boolean isClassFinal = classNode.isFinal();
+
+        findProtectedAttributes(classNode.getAttributes(),
+                isClassFinal);
+        findProtectedMethods(classNode.getFunctions(),
+                isClassFinal);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.LOW;
+    }
+
+    private void findProtectedAttributes(final List<IAttribute> atributes,
+                                         final boolean isClassFinal) {
+        if (atributes != null) {
+            for (final IAttribute field : atributes) {
+                if (field.is(Modifier.PROTECTED)
+                        && isClassFinal) {
+                    addViolation(field,
+                            field.getName());
+                }
+            }
+        }
+    }
+
+    private void findProtectedMethods(final List<IFunction> functions,
+                                      final boolean isClassFinal) {
+        if (functions != null) {
+            for (final IFunction function : functions) {
+                if (function.is(Modifier.PROTECTED)
+                        && !function.isOverriden() && isClassFinal) {
+                    addViolation(function);
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidUseOfAsKeywordRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidUseOfAsKeywordRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidUseOfAsKeywordRule.java
new file mode 100644
index 0000000..c76cfea
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidUseOfAsKeywordRule.java
@@ -0,0 +1,42 @@
+/*
+ * 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 org.apache.flex.pmd.rules.maintanability;
+
+import org.apache.flex.pmd.parser.IParserNode;
+import org.apache.flex.pmd.parser.NodeKind;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+public class AvoidUseOfAsKeywordRule extends AbstractAstFlexRule {
+    @Override
+    protected ViolationPriority getDefaultPriority() {
+        return ViolationPriority.LOW;
+    }
+
+    @Override
+    protected void visitRelationalExpression(final IParserNode ast) {
+        super.visitRelationalExpression(ast);
+
+        if (ast.getChildren() != null) {
+            for (final IParserNode child : ast.getChildren()) {
+                if (child.is(NodeKind.AS)) {
+                    addViolation(child);
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidUsingPublicStaticFieldRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidUsingPublicStaticFieldRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidUsingPublicStaticFieldRule.java
new file mode 100644
index 0000000..64c36eb
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidUsingPublicStaticFieldRule.java
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.flex.pmd.rules.maintanability;
+
+import org.apache.flex.pmd.nodes.IAttribute;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.List;
+
+/**
+ * @author xagnetti
+ */
+public class AvoidUsingPublicStaticFieldRule extends AbstractAstFlexRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromAttributes
+     * (java.util.List)
+     */
+    @Override
+    protected void findViolationsFromAttributes(final List<IAttribute> variables) {
+        for (final IAttribute attribute : variables) {
+            if (attribute.isPublic()
+                    && attribute.isStatic() && !attribute.getName().contains("instance")) {
+                addViolation(attribute,
+                        attribute.getName());
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected ViolationPriority getDefaultPriority() {
+        return ViolationPriority.HIGH;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidUsingWithKeyWordRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidUsingWithKeyWordRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidUsingWithKeyWordRule.java
new file mode 100644
index 0000000..67efa8e
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/AvoidUsingWithKeyWordRule.java
@@ -0,0 +1,53 @@
+/*
+ * 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 org.apache.flex.pmd.rules.maintanability;
+
+import org.apache.flex.pmd.nodes.IFunction;
+import org.apache.flex.pmd.parser.IParserNode;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.List;
+
+/**
+ * @author xagnetti
+ */
+public class AvoidUsingWithKeyWordRule extends AbstractAstFlexRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IFunction)
+     */
+    @Override
+    protected void findViolations(final IFunction function) {
+        final List<IParserNode> withStatements = function.findPrimaryStatementsInBody("with");
+
+        for (final IParserNode withStatement : withStatements) {
+            addViolation(withStatement);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected ViolationPriority getDefaultPriority() {
+        return ViolationPriority.HIGH;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/ClassAndExtensionAreIdenticalRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/ClassAndExtensionAreIdenticalRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/ClassAndExtensionAreIdenticalRule.java
new file mode 100644
index 0000000..8bcd154
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/ClassAndExtensionAreIdenticalRule.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 org.apache.flex.pmd.rules.maintanability;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.flex.pmd.nodes.IClass;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class ClassAndExtensionAreIdenticalRule extends AbstractAstFlexRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IClass)
+     */
+    @Override
+    protected final void findViolations(final IClass classNode) {
+        final String extensionName = classNode.getExtensionName();
+
+        if (extensionName != null) {
+            final String extension = extractExtensionName(extensionName);
+
+            if (extension.equals(classNode.getName())) {
+                addViolation(classNode);
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.HIGH;
+    }
+
+    private String extractExtensionName(final String extensionName) {
+        return extensionName.indexOf('.') == -1 ? extensionName
+                : StringUtils.substringAfterLast(extensionName,
+                ".");
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/DynamicClassRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/DynamicClassRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/DynamicClassRule.java
new file mode 100644
index 0000000..608c092
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/DynamicClassRule.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 org.apache.flex.pmd.rules.maintanability;
+
+import org.apache.flex.pmd.nodes.IClass;
+import org.apache.flex.pmd.nodes.Modifier;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class DynamicClassRule extends AbstractAstFlexRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+     * ()
+     */
+    @Override
+    public final boolean isConcernedByTheCurrentFile() {
+        return !getCurrentFile().isMxml();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IClass)
+     */
+    @Override
+    protected final void findViolations(final IClass classNode) {
+        if (classNode.is(Modifier.DYNAMIC)) {
+            addViolation(classNode);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.HIGH;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/EmptyStatementRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/EmptyStatementRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/EmptyStatementRule.java
new file mode 100644
index 0000000..918b9aa
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/EmptyStatementRule.java
@@ -0,0 +1,46 @@
+/*
+ * 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 org.apache.flex.pmd.rules.maintanability;
+
+import org.apache.flex.pmd.parser.IParserNode;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class EmptyStatementRule extends AbstractAstFlexRule {
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected ViolationPriority getDefaultPriority() {
+        return ViolationPriority.LOW;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitEmptyStatetement(
+     * com.adobe.ac.pmd.parser.IParserNode)
+     */
+    @Override
+    protected void visitEmptyStatetement(final IParserNode statementNode) {
+        addViolation(statementNode);
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/ExcessiveImportRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/ExcessiveImportRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/ExcessiveImportRule.java
new file mode 100644
index 0000000..3979310
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/maintanability/ExcessiveImportRule.java
@@ -0,0 +1,74 @@
+/*
+ * 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 org.apache.flex.pmd.rules.maintanability;
+
+import org.apache.flex.pmd.nodes.IPackage;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+import org.apache.flex.pmd.rules.core.thresholded.AbstractMaximizedAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public class ExcessiveImportRule extends AbstractMaximizedAstFlexRule {
+    private static final int DEFAULT_THRESHOLD = 15;
+    private int importNumber;
+
+    /*
+     * (non-Javadoc)
+     * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+     * getActualValueForTheCurrentViolation()
+     */
+    @Override
+    public final int getActualValueForTheCurrentViolation() {
+        return importNumber;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getDefaultThreshold
+     * ()
+     */
+    @Override
+    public final int getDefaultThreshold() {
+        return DEFAULT_THRESHOLD;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IPackage)
+     */
+    @Override
+    protected final void findViolations(final IPackage packageNode) {
+        importNumber = packageNode.getImports().size();
+
+        if (importNumber > getThreshold()) {
+            addViolation(packageNode.getClassNode());
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+}


Mime
View raw message