flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cd...@apache.org
Subject [16/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:09 GMT
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/AbstractPrimaryAstRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/AbstractPrimaryAstRule.java b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/AbstractPrimaryAstRule.java
new file mode 100644
index 0000000..8deff1f
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/AbstractPrimaryAstRule.java
@@ -0,0 +1,76 @@
+/*
+ * 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.core;
+
+import org.apache.flex.pmd.nodes.IFunction;
+import org.apache.flex.pmd.parser.IParserNode;
+
+import java.util.List;
+
+/**
+ * Abstract rule which find a primary (or a couple of primaries) in a body
+ * function.
+ *
+ * @author xagnetti
+ */
+public abstract class AbstractPrimaryAstRule extends AbstractAstFlexRule {
+    /**
+     * @param statement
+     * @param function
+     */
+    protected abstract void addViolation(IParserNode statement,
+                                         IFunction function);
+
+    /*
+     * (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) {
+        final List<IParserNode> firstStatements = function.findPrimaryStatementsInBody(getFirstPrimaryToFind());
+        if (!firstStatements.isEmpty()) {
+            for (final IParserNode firstStatement : firstStatements) {
+                if (getSecondPrimaryToFind() == null) {
+                    addViolation(firstStatement,
+                            function);
+                } else {
+                    final List<IParserNode> secondStatements = function.findPrimaryStatementsInBody(getSecondPrimaryToFind());
+                    if (!secondStatements.isEmpty()) {
+                        for (final IParserNode secondStatement : secondStatements) {
+                            addViolation(secondStatement,
+                                    function);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * @return
+     */
+    protected abstract String getFirstPrimaryToFind();
+
+    /**
+     * @return
+     */
+    protected String getSecondPrimaryToFind() {
+        return null;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/AbstractRegexpBasedRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/AbstractRegexpBasedRule.java b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/AbstractRegexpBasedRule.java
new file mode 100644
index 0000000..3d13afd
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/AbstractRegexpBasedRule.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 org.apache.flex.pmd.rules.core;
+
+import org.apache.flex.pmd.rules.IFlexViolation;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author xagnetti
+ */
+public abstract class AbstractRegexpBasedRule extends AbstractFlexRule {
+    private Pattern pattern;
+
+    /**
+     *
+     */
+    public AbstractRegexpBasedRule() {
+        super();
+        compilePattern();
+    }
+
+    /**
+     *
+     */
+    public final void compilePattern() {
+        pattern = Pattern.compile(getRegexp());
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractFlexRule#findViolationsInCurrentFile()
+     */
+    @Override
+    public final List<IFlexViolation> findViolationsInCurrentFile() {
+        final List<IFlexViolation> violations = new ArrayList<IFlexViolation>();
+
+        if ("".compareTo(getRegexp()) != 0) {
+            for (int i = 1; i <= getCurrentFile().getLinesNb(); i++) {
+                final String line = getCurrentFile().getLineAt(i);
+
+                if (isCurrentLineConcerned(line)
+                        && doesCurrentLineMacthes(line) && isViolationDetectedOnThisMatchingLine(line)
+                        && !line.contains("/*") && !line.contains("//")) {
+                    addViolation(violations,
+                            ViolationPosition.create(i,
+                                    i,
+                                    0,
+                                    line.length()));
+                }
+            }
+        }
+        return violations;
+    }
+
+    /**
+     * @param line
+     * @return
+     */
+    public boolean doesCurrentLineMacthes(final String line) {
+        return getMatcher(line).matches();
+    }
+
+    /**
+     * @param line
+     * @return
+     */
+    protected final Matcher getMatcher(final String line) {
+        final Matcher matcher = pattern.matcher(line);
+
+        return matcher;
+    }
+
+    /**
+     * @return
+     */
+    protected abstract String getRegexp();
+
+    protected boolean isCurrentLineConcerned(final String line) {
+        return true;
+    }
+
+    /**
+     * @param line
+     * @return
+     */
+    protected abstract boolean isViolationDetectedOnThisMatchingLine(final String line);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/AbstractXpathRelatedRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/AbstractXpathRelatedRule.java b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/AbstractXpathRelatedRule.java
new file mode 100644
index 0000000..be76a3d
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/AbstractXpathRelatedRule.java
@@ -0,0 +1,211 @@
+/*
+ * 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.core;
+
+import org.apache.flex.pmd.rules.IFlexViolation;
+import org.apache.flex.pmd.utils.StackTraceUtils;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.*;
+import java.util.logging.Logger;
+
+/**
+ * @author xagnetti
+ */
+public abstract class AbstractXpathRelatedRule extends AbstractFlexRule {
+    /**
+     * @author xagnetti
+     */
+    public class NamespaceContextMap implements NamespaceContext {
+        private final Map<String, String> prefixMap;
+
+        /**
+         * Constructor that takes a map of XML prefix-namespaceURI values. A
+         * defensive copy is made of the map. An IllegalArgumentException will be
+         * thrown if the map attempts to remap the standard prefixes defined in
+         * the NamespaceContext contract.
+         *
+         * @param prefixMappings a map of prefix:namespaceURI values
+         */
+        public NamespaceContextMap(final Map<String, String> prefixMappings) {
+            prefixMap = createPrefixMap(prefixMappings);
+        }
+
+        /**
+         * Convenience constructor.
+         *
+         * @param mappingPairs pairs of prefix-namespaceURI values
+         */
+        public NamespaceContextMap(final String... mappingPairs) {
+            this(toMap(mappingPairs));
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see
+         * javax.xml.namespace.NamespaceContext#getNamespaceURI(java.lang.String)
+         */
+        public String getNamespaceURI(final String prefix) {
+            prefixMap.get(prefix);
+            return prefixMap.get(prefix);
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see javax.xml.namespace.NamespaceContext#getPrefix(java.lang.String)
+         */
+        public String getPrefix(final String namespaceURI) {
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see javax.xml.namespace.NamespaceContext#getPrefixes(java.lang.String)
+         */
+        public Iterator<String> getPrefixes(final String namespaceURI) {
+            return null;
+        }
+
+        private void addConstant(final Map<String, String> map,
+                                 final String prefix,
+                                 final String nsURI) {
+            map.put(prefix,
+                    nsURI);
+        }
+
+        private Map<String, String> createPrefixMap(final Map<String, String> prefixMappings) {
+            final Map<String, String> map = new LinkedHashMap<String, String>(prefixMappings);
+            addConstant(map,
+                    XMLConstants.XML_NS_PREFIX,
+                    XMLConstants.XML_NS_URI);
+            addConstant(map,
+                    XMLConstants.XMLNS_ATTRIBUTE,
+                    XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
+            return Collections.unmodifiableMap(map);
+        }
+
+    }
+
+    protected static final Logger LOGGER = Logger.getLogger(AbstractXpathRelatedRule.class.getName());
+
+    private static Map<String, String> toMap(final String... mappingPairs) {
+        final Map<String, String> prefixMappings = new LinkedHashMap<String, String>(mappingPairs.length / 2);
+        for (int i = 0; i < mappingPairs.length; i++) {
+            prefixMappings.put(mappingPairs[i],
+                    mappingPairs[++i]);
+        }
+        return prefixMappings;
+    }
+
+    /**
+     * @param doc
+     * @param xPath
+     * @return
+     * @throws javax.xml.xpath.XPathExpressionException
+     */
+    protected abstract Object evaluate(final Document doc,
+                                       final XPath xPath) throws XPathExpressionException;
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractFlexRule#findViolationsInCurrentFile()
+     */
+    @Override
+    protected List<IFlexViolation> findViolationsInCurrentFile() {
+        final ArrayList<IFlexViolation> violations = new ArrayList<IFlexViolation>();
+
+        try {
+            final Document doc = buildDocument();
+            final XPath xPath = buildXPath();
+
+            onEvaluated(violations,
+                    doc,
+                    xPath);
+        } catch (final XPathExpressionException e) {
+            LOGGER.warning(StackTraceUtils.print(getCurrentFile().getFilename(),
+                    e));
+        } catch (final FileNotFoundException e) {
+            LOGGER.warning(StackTraceUtils.print(getCurrentFile().getFilename(),
+                    e));
+        } catch (final ParserConfigurationException e) {
+            LOGGER.warning(StackTraceUtils.print(getCurrentFile().getFilename(),
+                    e));
+        } catch (final SAXException e) {
+            LOGGER.warning(StackTraceUtils.print(getCurrentFile().getFilename(),
+                    e));
+        } catch (final IOException e) {
+            LOGGER.warning(StackTraceUtils.print(getCurrentFile().getFilename(),
+                    e));
+        }
+
+        return violations;
+    }
+
+    /**
+     * @return
+     */
+    protected abstract String getXPathExpression();
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+     */
+    @Override
+    protected boolean isConcernedByTheCurrentFile() {
+        return getCurrentFile().isMxml();
+    }
+
+    /**
+     * @param violations
+     * @param doc
+     * @param xPath
+     * @throws javax.xml.xpath.XPathExpressionException
+     */
+    protected abstract void onEvaluated(final List<IFlexViolation> violations,
+                                        final Document doc,
+                                        final XPath xPath) throws XPathExpressionException;
+
+    private Document buildDocument() throws ParserConfigurationException,
+            SAXException,
+            IOException {
+        final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
+        final DocumentBuilder builder = factory.newDocumentBuilder();
+        return builder.parse(getCurrentFile().getFilePath());
+    }
+
+    private XPath buildXPath() {
+        final XPathFactory xPathFactory = XPathFactory.newInstance();
+        final XPath xPath = xPathFactory.newXPath();
+        xPath.setNamespaceContext(new NamespaceContextMap("mx", "http://www.adobe.com/2006/mxml"));
+        return xPath;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/IFlexAstRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/IFlexAstRule.java b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/IFlexAstRule.java
new file mode 100644
index 0000000..774ddb9
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/IFlexAstRule.java
@@ -0,0 +1,27 @@
+/*
+ * 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.core;
+
+/**
+ * @author xagnetti
+ */
+public interface IFlexAstRule extends IFlexRule {
+    /**
+     * @return true if the current file is concerned
+     */
+    boolean isConcernedByTheCurrentFile();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/IFlexRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/IFlexRule.java b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/IFlexRule.java
new file mode 100644
index 0000000..a0b2ea5
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/IFlexRule.java
@@ -0,0 +1,51 @@
+/*
+ * 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.core;
+
+import net.sourceforge.pmd.Rule;
+import org.apache.flex.pmd.files.IFlexFile;
+import org.apache.flex.pmd.nodes.IPackage;
+import org.apache.flex.pmd.rules.IFlexViolation;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author xagnetti
+ */
+public interface IFlexRule extends Rule {
+    /**
+     * @return ruleName
+     */
+    String getRuleName();
+
+    /**
+     * @param file
+     * @param rootNode
+     * @param files
+     * @return
+     */
+    List<IFlexViolation> processFile(final IFlexFile file,
+                                     final IPackage rootNode,
+                                     final Map<String, IFlexFile> files);
+
+    /**
+     * @param excludes
+     */
+    void setExcludes(final Set<String> excludes);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/Violation.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/Violation.java b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/Violation.java
new file mode 100644
index 0000000..e7d0c79
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/Violation.java
@@ -0,0 +1,284 @@
+/*
+ * 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.core;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.flex.pmd.files.IFlexFile;
+import org.apache.flex.pmd.rules.IFlexViolation;
+
+import java.util.Formatter;
+
+/**
+ * @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 StringBuilder message = new StringBuilder(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().getPriority() > otherViolation.getRule().getPriority().getPriority()) {
+            res = 1;
+        } else if (rule.getPriority().getPriority() < otherViolation.getRule().getPriority().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/ff722d6f/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/ViolationPosition.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/ViolationPosition.java b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/ViolationPosition.java
new file mode 100644
index 0000000..c614473
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/ViolationPosition.java
@@ -0,0 +1,97 @@
+/*
+ * 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.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/ff722d6f/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/ViolationPriority.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/ViolationPriority.java b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/ViolationPriority.java
new file mode 100644
index 0000000..d46fc16
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/ViolationPriority.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.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/ff722d6f/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/AbstractMaximizedAstFlexRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/AbstractMaximizedAstFlexRule.java b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/AbstractMaximizedAstFlexRule.java
new file mode 100644
index 0000000..d04260c
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/AbstractMaximizedAstFlexRule.java
@@ -0,0 +1,43 @@
+/*
+ * 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.core.thresholded;
+
+import org.apache.flex.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 1;//getIntProperty( propertyDescriptorFor( getThresholdName() ) );
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getThresholdName
+     * ()
+     */
+    public final String getThresholdName() {
+        return MAXIMUM;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/AbstractMaximizedFlexRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/AbstractMaximizedFlexRule.java b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/AbstractMaximizedFlexRule.java
new file mode 100644
index 0000000..22b293c
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/AbstractMaximizedFlexRule.java
@@ -0,0 +1,43 @@
+/*
+ * 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.core.thresholded;
+
+import org.apache.flex.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 0;//getIntProperty( propertyDescriptorFor( getThresholdName() ) );
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getThresholdName
+     * ()
+     */
+    public final String getThresholdName() {
+        return MAXIMUM;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/AbstractMaximizedRegexpBasedRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/AbstractMaximizedRegexpBasedRule.java b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/AbstractMaximizedRegexpBasedRule.java
new file mode 100644
index 0000000..7187789
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/AbstractMaximizedRegexpBasedRule.java
@@ -0,0 +1,44 @@
+/*
+ * 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.core.thresholded;
+
+import org.apache.flex.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 1;//getIntProperty( propertyDescriptorFor( getThresholdName() ) );
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getThresholdName
+     * ()
+     */
+    public final String getThresholdName() {
+        return MAXIMUM;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/ff722d6f/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/IThresholdedRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/IThresholdedRule.java b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/IThresholdedRule.java
new file mode 100644
index 0000000..5216a5c
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-api/src/main/java/org/apache/flex/pmd/rules/core/thresholded/IThresholdedRule.java
@@ -0,0 +1,44 @@
+/*
+ * 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.core.thresholded;
+
+import org.apache.flex.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/ff722d6f/FlexPMD/language-module/ruleset/ruleset-flex-basic/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/pom.xml b/FlexPMD/language-module/ruleset/ruleset-flex-basic/pom.xml
new file mode 100644
index 0000000..b60a384
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/pom.xml
@@ -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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.flex.pmd.ruleset</groupId>
+        <artifactId>ruleset</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>ruleset-flex-basic</artifactId>
+    <version>2.0.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.flex.pmd.ruleset</groupId>
+            <artifactId>ruleset-api</artifactId>
+            <version>2.0.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.flex.pmd.parser</groupId>
+            <artifactId>parser-impl</artifactId>
+            <version>2.0.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>6.8.8</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>

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/architecture/MonkeyPatchingRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/architecture/MonkeyPatchingRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/architecture/MonkeyPatchingRule.java
new file mode 100644
index 0000000..5445cdb
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/architecture/MonkeyPatchingRule.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.architecture;
+
+import org.apache.flex.pmd.rules.IFlexViolation;
+import org.apache.flex.pmd.rules.core.AbstractFlexRule;
+import org.apache.flex.pmd.rules.core.ViolationPosition;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author xagnetti
+ */
+public class MonkeyPatchingRule extends AbstractFlexRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractFlexRule#findViolationsInCurrentFile()
+     */
+    @Override
+    protected final List<IFlexViolation> findViolationsInCurrentFile() {
+        final List<IFlexViolation> violations = new ArrayList<IFlexViolation>();
+
+        if (getCurrentFile().getPackageName().startsWith("mx.")
+                && !getCurrentFile().getClassName().equals("Version.as")
+                && !getCurrentFile().getClassName().endsWith("Style.as")) {
+            addViolation(violations,
+                    new ViolationPosition(0));
+        }
+        return violations;
+    }
+
+    /*
+     * (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.AbstractFlexRule#isConcernedByTheCurrentFile()
+     */
+    @Override
+    protected final boolean isConcernedByTheCurrentFile() {
+        return !getCurrentFile().isMxml();
+    }
+}

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/architecture/UseInternalClassOutsideApiClass.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/architecture/UseInternalClassOutsideApiClass.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/architecture/UseInternalClassOutsideApiClass.java
new file mode 100644
index 0000000..ae2144b
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/architecture/UseInternalClassOutsideApiClass.java
@@ -0,0 +1,113 @@
+/*
+ * 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.architecture;
+
+import org.apache.commons.lang3.StringUtils;
+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;
+
+/**
+ * @author xagnetti
+ */
+public class UseInternalClassOutsideApiClass extends AbstractAstFlexRule {
+    private static final String API_PACKAGE_NAME = "api";
+    private static final String INTERNAL_PACKAGE_NAME = "restricted";
+    private static final String PACKAGE_SEPARATOR = ".";
+
+    /*
+     * (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 String packageName = packageNode.getName();
+        final boolean isApiClass = isApiClass(packageName);
+        final boolean isInternalClass = isInternalClass(packageName);
+        String functionAreaName = null;
+
+        if (isApiClass
+                || isInternalClass) {
+            functionAreaName = extractFunctionalArea(packageName,
+                    false);
+        }
+        for (final IParserNode importNode : packageNode.getImports()) {
+            final String importName = importNode.getStringValue();
+            final String importFunctionalArea = extractFunctionalArea(importName,
+                    true);
+
+            if (doesLineContainPackageReference(importName,
+                    INTERNAL_PACKAGE_NAME)
+                    && (functionAreaName == null || !functionAreaName.equals(importFunctionalArea))) {
+                addViolation(importNode,
+                        importName,
+                        importFunctionalArea);
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.HIGH;
+    }
+
+    private boolean doesLineContainPackageReference(final String line,
+                                                    final String packageName) {
+        return line.contains(PACKAGE_SEPARATOR
+                + packageName);
+    }
+
+    private String extractFunctionalArea(final String packageName,
+                                         final boolean isInImport) {
+        if (packageName.contains(INTERNAL_PACKAGE_NAME)) {
+            return extractFunctionArea(packageName,
+                    INTERNAL_PACKAGE_NAME,
+                    isInImport);
+        }
+        return extractFunctionArea(packageName,
+                API_PACKAGE_NAME,
+                isInImport);
+    }
+
+    private String extractFunctionArea(final String packageName,
+                                       final String visibilityPackageName,
+                                       final boolean isInImport) {
+        return StringUtils.substringAfterLast(StringUtils.substringBeforeLast(packageName,
+                        PACKAGE_SEPARATOR
+                                + visibilityPackageName
+                                + (isInImport ? PACKAGE_SEPARATOR
+                                : "")),
+                PACKAGE_SEPARATOR);
+    }
+
+    private boolean isApiClass(final String packageName) {
+        return doesLineContainPackageReference(packageName,
+                API_PACKAGE_NAME);
+    }
+
+    private boolean isInternalClass(final String packageName) {
+        return doesLineContainPackageReference(packageName,
+                INTERNAL_PACKAGE_NAME);
+    }
+}

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/architecture/ViewComponentReferencedInModelRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/architecture/ViewComponentReferencedInModelRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/architecture/ViewComponentReferencedInModelRule.java
new file mode 100644
index 0000000..a8f9bfb
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/architecture/ViewComponentReferencedInModelRule.java
@@ -0,0 +1,83 @@
+/*
+ * 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.architecture;
+
+import org.apache.flex.pmd.rules.core.AbstractRegexpBasedRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.Locale;
+import java.util.regex.Matcher;
+
+/**
+ * @author xagnetti
+ */
+public class ViewComponentReferencedInModelRule extends AbstractRegexpBasedRule // NO_UCD
+{
+    private static final String ALERT_CLASS_NAME = "Alert";
+    private static final String FLEX_CONTROLS_PACKAGE_NAME = "mx.controls";
+    private static final String MODEL_CLASS_SUFFIX = "model";
+    private static final String MODEL_PACKAGE_NAME = ".model";
+    private static final String VIEW_PACKAGE_NAME = ".view";
+
+    /*
+     * (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 ".*import (.*);?.*";
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+     */
+    @Override
+    protected final boolean isConcernedByTheCurrentFile() {
+        return !getCurrentFile().isMxml()
+                && getCurrentFile().getFullyQualifiedName()
+                .toLowerCase(Locale.ENGLISH)
+                .contains(MODEL_CLASS_SUFFIX);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @seecom.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#
+     * isViolationDetectedOnThisMatchingLine(java.lang.String)
+     */
+    @Override
+    protected final boolean isViolationDetectedOnThisMatchingLine(final String line) {
+        final Matcher matcher = getMatcher(line);
+
+        matcher.matches();
+        final String importedClass = matcher.group(1);
+
+        return importedClass.contains(FLEX_CONTROLS_PACKAGE_NAME)
+                && !importedClass.contains(ALERT_CLASS_NAME) || importedClass.contains(VIEW_PACKAGE_NAME)
+                && !importedClass.contains(MODEL_PACKAGE_NAME);
+    }
+}

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/asdocs/AbstractAsDocRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/asdocs/AbstractAsDocRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/asdocs/AbstractAsDocRule.java
new file mode 100644
index 0000000..7a0d08a
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/asdocs/AbstractAsDocRule.java
@@ -0,0 +1,34 @@
+/*
+ * 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.asdocs;
+
+import org.apache.flex.pmd.nodes.IAsDocHolder;
+import org.apache.flex.pmd.rules.core.AbstractAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+abstract class AbstractAsDocRule extends AbstractAstFlexRule {
+    /**
+     * @param asDocHolder
+     */
+    protected void addViolationIfAsDocMissing(final IAsDocHolder asDocHolder) {
+        if (asDocHolder.getAsDoc() == null) {
+            addViolation(asDocHolder);
+        }
+    }
+}
\ 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/asdocs/AttributeAsDocMissingRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/asdocs/AttributeAsDocMissingRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/asdocs/AttributeAsDocMissingRule.java
new file mode 100644
index 0000000..575ee45
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/asdocs/AttributeAsDocMissingRule.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.asdocs;
+
+import org.apache.flex.pmd.nodes.IAttribute;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+import java.util.List;
+
+/**
+ * @author xagnetti
+ */
+public class AttributeAsDocMissingRule extends AbstractAsDocRule {
+    /*
+     * (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) {
+            addViolationIfAsDocMissing(attribute);
+        }
+    }
+
+    /*
+     * (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/asdocs/ClassAsDocMissingRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/asdocs/ClassAsDocMissingRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/asdocs/ClassAsDocMissingRule.java
new file mode 100644
index 0000000..918d230
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/asdocs/ClassAsDocMissingRule.java
@@ -0,0 +1,56 @@
+/*
+ * 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.asdocs;
+
+import org.apache.flex.pmd.nodes.IClass;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class ClassAsDocMissingRule extends AbstractAsDocRule {
+    /*
+     * (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#findViolations(com.adobe
+     * .ac.pmd.nodes.IClass)
+     */
+    @Override
+    protected void findViolations(final IClass classNode) {
+        addViolationIfAsDocMissing(classNode);
+    }
+
+    /*
+     * (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/asdocs/MethodAsDocMissingRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/asdocs/MethodAsDocMissingRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/asdocs/MethodAsDocMissingRule.java
new file mode 100644
index 0000000..6797828
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/asdocs/MethodAsDocMissingRule.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.asdocs;
+
+import org.apache.flex.pmd.nodes.IFunction;
+import org.apache.flex.pmd.nodes.Modifier;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class MethodAsDocMissingRule extends AbstractAsDocRule {
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+     * .ac.pmd.nodes.IFunction)
+     */
+    @Override
+    protected void findViolations(final IFunction function) {
+        if ((function.isPublic() || function.is(Modifier.PROTECTED))
+                && !function.isGetter() && !function.isSetter() && function.getAsDoc() == null) {
+            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/binding/BindingUtilsRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/binding/BindingUtilsRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/binding/BindingUtilsRule.java
new file mode 100644
index 0000000..e5629d6
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/binding/BindingUtilsRule.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.binding;
+
+import org.apache.flex.pmd.rules.core.AbstractForbiddenImportRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class BindingUtilsRule extends AbstractForbiddenImportRule // NO_UCD
+{
+    /*
+     * (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.AbstractForbiddenImportRule#getForbiddenImport
+     * ()
+     */
+    @Override
+    protected String getForbiddenImport() {
+        return "BindingUtils";
+    }
+}

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/binding/ChangeWatcherRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/binding/ChangeWatcherRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/binding/ChangeWatcherRule.java
new file mode 100644
index 0000000..da5b105
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/binding/ChangeWatcherRule.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 org.apache.flex.pmd.rules.binding;
+
+import org.apache.flex.pmd.rules.core.AbstractForbiddenImportRule;
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class ChangeWatcherRule extends AbstractForbiddenImportRule {
+    /*
+     * (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.AbstractForbiddenImportRule#getForbiddenImport
+     * ()
+     */
+    @Override
+    protected String getForbiddenImport() {
+        return "ChangeWatcher";
+    }
+}

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/binding/TooLongBindingExpressionRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/binding/TooLongBindingExpressionRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/binding/TooLongBindingExpressionRule.java
new file mode 100644
index 0000000..0d58ec0
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/binding/TooLongBindingExpressionRule.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 org.apache.flex.pmd.rules.binding;
+
+import org.apache.flex.pmd.rules.core.ViolationPriority;
+import org.apache.flex.pmd.rules.core.thresholded.AbstractMaximizedRegexpBasedRule;
+
+import java.util.regex.Matcher;
+
+/**
+ * @author xagnetti
+ */
+public class TooLongBindingExpressionRule extends AbstractMaximizedRegexpBasedRule // NO_UCD
+{
+    private int currentCount;
+
+    /*
+     * (non-Javadoc)
+     * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+     * getActualValueForTheCurrentViolation()
+     */
+    public final int getActualValueForTheCurrentViolation() {
+        return currentCount;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getDefaultThreshold
+     * ()
+     */
+    public final int getDefaultThreshold() {
+        return 2;
+    }
+
+    /*
+     * (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 ".*=\"\\{[^']([^\\}]*)[^']\\}\".*";
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+     */
+    @Override
+    protected final boolean isConcernedByTheCurrentFile() {
+        return getCurrentFile().isMxml();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @seecom.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#
+     * isViolationDetectedOnThisMatchingLine(java.lang.String)
+     */
+    @Override
+    protected final boolean isViolationDetectedOnThisMatchingLine(final String line) {
+        final Matcher matcher = getMatcher(line);
+
+        matcher.matches();
+        currentCount = countChar(matcher.group(1),
+                '.');
+        return matcher.matches()
+                && currentCount > getThreshold();
+    }
+
+    private int countChar(final String input,
+                          final char charToSearch) {
+        int charCount = 0;
+
+        for (int i = 0; i < input.length(); i++) {
+            if (input.charAt(i) == charToSearch) {
+                charCount++;
+            }
+        }
+
+        return charCount;
+    }
+}

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/BadCairngormEventNameFormatRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/BadCairngormEventNameFormatRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/BadCairngormEventNameFormatRule.java
new file mode 100644
index 0000000..0a81fac
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/BadCairngormEventNameFormatRule.java
@@ -0,0 +1,105 @@
+/*
+ * 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.commons.lang3.StringUtils;
+import org.apache.flex.pmd.nodes.IClass;
+import org.apache.flex.pmd.nodes.IField;
+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 BadCairngormEventNameFormatRule extends AbstractAstFlexRule // NO_UCD
+{
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+     * ()
+     */
+    @Override
+    public final boolean isConcernedByTheCurrentFile() {
+        return getCurrentFile().getClassName().endsWith("Event.as");
+    }
+
+    /*
+     * (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 (isExtendedClassCairngormEvent(classNode)) {
+            final String eventName = extractEventName(classNode);
+
+            if (StringUtils.isEmpty(eventName)
+                    || !eventName.contains(".")) {
+                addViolation(classNode);
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+     */
+    @Override
+    protected final ViolationPriority getDefaultPriority() {
+        return ViolationPriority.NORMAL;
+    }
+
+    private String extractEventName(final IClass classNode) {
+        String eventName = "";
+
+        for (final IField constantNode : classNode.getConstants()) {
+            if (constantNode.getName().startsWith("EVENT")) {
+                eventName = extractEventNameFromConstant(constantNode.getInitializationExpression()
+                        .getInternalNode());
+            }
+        }
+        if (StringUtils.isEmpty(eventName)
+                && classNode.getConstructor() != null) {
+            eventName = extractEventNameFromConstructor(classNode.getConstructor());
+        }
+        return eventName;
+    }
+
+    private String extractEventNameFromConstant(final IParserNode initExpressionNode) {
+        return initExpressionNode.getChild(0).getStringValue();
+    }
+
+    private String extractEventNameFromConstructor(final IFunction constructor) {
+        String eventName = "";
+        final IParserNode superCall = constructor.getSuperCall();
+
+        if (superCall != null) {
+            eventName = superCall.getChild(1).getChild(0).getStringValue();
+        }
+        return eventName;
+    }
+
+    private boolean isExtendedClassCairngormEvent(final IClass classNode) {
+        return classNode.getExtensionName() != null
+                && classNode.getExtensionName().contains("Cairngorm")
+                && classNode.getExtensionName().contains("Event");
+    }
+}

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/BindableModelLocatorRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/BindableModelLocatorRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/BindableModelLocatorRule.java
new file mode 100644
index 0000000..bc99c08
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/BindableModelLocatorRule.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.cairngorm;
+
+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 BindableModelLocatorRule extends AbstractAstFlexRule // NO_UCD
+{
+    /*
+     * (non-Javadoc)
+     * @see
+     * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+     * ()
+     */
+    @Override
+    public final boolean isConcernedByTheCurrentFile() {
+        return getCurrentFile().getClassName().endsWith("ModelLocator.as");
+    }
+
+    /*
+     * (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.isBindable()) {
+            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/cairngorm/CairngormEventDispatcherCallExplicitlyRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/CairngormEventDispatcherCallExplicitlyRule.java b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/CairngormEventDispatcherCallExplicitlyRule.java
new file mode 100644
index 0000000..64c2b9f
--- /dev/null
+++ b/FlexPMD/language-module/ruleset/ruleset-flex-basic/src/main/java/org/apache/flex/pmd/rules/cairngorm/CairngormEventDispatcherCallExplicitlyRule.java
@@ -0,0 +1,71 @@
+/*
+ * 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.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 CairngormEventDispatcherCallExplicitlyRule extends AbstractPrimaryAstRule // NO_UCD
+{
+    private static final String ADD_EVENT_LISTENER_MESSAGE = "The Cairngorm event is listened directly. "
+            + "The Controller is then avoided, and "
+            + "the MVC pattern is broken.";
+    private static final String DISPATCH_EVENT = "dispatchEvent";
+    private static final String DISPATCH_EVENT_MESSAGE = "Use cairngormEvent.dispatch instead";
+    private static final String EVENT_DISPATCHER = "CairngormEventDispatcher";
+
+    /*
+     * (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) {
+        final String violationLine = getCurrentFile().getLineAt(statement.getLine());
+        final String messageToAppend = violationLine.contains(DISPATCH_EVENT) ? ADD_EVENT_LISTENER_MESSAGE
+                : DISPATCH_EVENT_MESSAGE;
+
+        addViolation(statement,
+                messageToAppend);
+    }
+
+    /*
+     * (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.AbstractPrimaryAstRule#getFirstPrimaryToFind()
+     */
+    @Override
+    protected String getFirstPrimaryToFind() {
+        return EVENT_DISPATCHER;
+    }
+}


Mime
View raw message