You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2014/08/27 00:43:41 UTC
[10/51] [partial] Refactored the PMD Maven build - Adjusted the
directory structure - Fixed a lot of compile problems - Fixed the maven setup
- Made PMD build with Flexmojos 7.1.0 and Apache Flex 4.13.0 - Fixed a few
UnitTests
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/AvoidUsingMathCeilRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/AvoidUsingMathCeilRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/AvoidUsingMathCeilRule.java
new file mode 100644
index 0000000..2309360
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/AvoidUsingMathCeilRule.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 com.adobe.ac.pmd.rules.performance;
+
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class AvoidUsingMathCeilRule 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 ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.LOW;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#getFirstPrimaryToFind()
+ */
+ @Override
+ protected String getFirstPrimaryToFind()
+ {
+ return "Math";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#getSecondPrimaryToFind
+ * ()
+ */
+ @Override
+ protected String getSecondPrimaryToFind()
+ {
+ return "ceil";
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/AvoidUsingMathFloorRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/AvoidUsingMathFloorRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/AvoidUsingMathFloorRule.java
new file mode 100644
index 0000000..bdba2d7
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/AvoidUsingMathFloorRule.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 com.adobe.ac.pmd.rules.performance;
+
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class AvoidUsingMathFloorRule 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 ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.LOW;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#getFirstPrimaryToFind()
+ */
+ @Override
+ protected String getFirstPrimaryToFind()
+ {
+ return "Math";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#getSecondPrimaryToFind
+ * ()
+ */
+ @Override
+ protected String getSecondPrimaryToFind()
+ {
+ return "floor";
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/AvoidUsingMathRoundRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/AvoidUsingMathRoundRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/AvoidUsingMathRoundRule.java
new file mode 100644
index 0000000..d1f211e
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/AvoidUsingMathRoundRule.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 com.adobe.ac.pmd.rules.performance;
+
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class AvoidUsingMathRoundRule 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 ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.LOW;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#getFirstPrimaryToFind()
+ */
+ @Override
+ protected String getFirstPrimaryToFind()
+ {
+ return "Math";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#getSecondPrimaryToFind
+ * ()
+ */
+ @Override
+ protected String getSecondPrimaryToFind()
+ {
+ return "round";
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/BindableClassRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/BindableClassRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/BindableClassRule.java
new file mode 100644
index 0000000..54ce012
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/BindableClassRule.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.performance;
+
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.MetaData;
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class BindableClassRule extends AbstractAstFlexRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+ * ()
+ */
+ @Override
+ public final boolean isConcernedByTheCurrentFile()
+ {
+ return !getCurrentFile().isMxml()
+ && !getCurrentFile().getClassName().endsWith( "VO.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.getMetaData( MetaData.BINDABLE ).get( 0 ) );
+ }
+ }
+
+ /*
+ * (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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/CreationPolicySetToAllRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/CreationPolicySetToAllRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/CreationPolicySetToAllRule.java
new file mode 100644
index 0000000..4ad86c5
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/CreationPolicySetToAllRule.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.performance;
+
+import java.util.Locale;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class CreationPolicySetToAllRule 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 ".*creationPolicy.*";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#
+ * isViolationDetectedOnThisMatchingLine(java.lang.String)
+ */
+ @Override
+ protected final boolean isViolationDetectedOnThisMatchingLine( final String line )
+ {
+ return line.toLowerCase( Locale.FRANCE ).contains( "all" );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/CyclomaticComplexityRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/CyclomaticComplexityRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/CyclomaticComplexityRule.java
new file mode 100644
index 0000000..2dcdb4c
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/CyclomaticComplexityRule.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.performance;
+
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.AbstractMaximizedAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public class CyclomaticComplexityRule extends AbstractMaximizedAstFlexRule
+{
+ public static final int DEFAULT_THRESHOLD = 10;
+ private IFunction currentFunction = null;
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+ * getActualValueForTheCurrentViolation()
+ */
+ public final int getActualValueForTheCurrentViolation()
+ {
+ return currentFunction.getCyclomaticComplexity();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getDefaultThreshold
+ * ()
+ */
+ public final int getDefaultThreshold()
+ {
+ return DEFAULT_THRESHOLD;
+ }
+
+ /*
+ * (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 )
+ {
+ currentFunction = function;
+ if ( function.getCyclomaticComplexity() > getThreshold() )
+ {
+ addViolation( function );
+ }
+ }
+
+ /*
+ * (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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/DeeplyNestedIfRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/DeeplyNestedIfRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/DeeplyNestedIfRule.java
new file mode 100644
index 0000000..46b17ef
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/DeeplyNestedIfRule.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.performance;
+
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.AbstractMaximizedAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public class DeeplyNestedIfRule extends AbstractMaximizedAstFlexRule
+{
+ private int ifLevel = 0;
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+ * getActualValueForTheCurrentViolation()
+ */
+ public final int getActualValueForTheCurrentViolation()
+ {
+ return ifLevel;
+ }
+
+ /*
+ * (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.AbstractAstFlexRule#visitElse(com.adobe.ac
+ * .pmd.parser.IParserNode)
+ */
+ @Override
+ protected final void visitElse( final IParserNode ifNode )
+ {
+ beforeVisitingIfBlock();
+
+ super.visitElse( ifNode );
+
+ afterVisitingIfBlock( ifNode );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitFunction(com.adobe
+ * .ac.pmd.parser.IParserNode,
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule.FunctionType)
+ */
+ @Override
+ protected final void visitFunction( final IParserNode ast,
+ final FunctionType type )
+ {
+ ifLevel = 0;
+
+ super.visitFunction( ast,
+ type );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitThen(com.adobe.ac
+ * .pmd.parser.IParserNode)
+ */
+ @Override
+ protected final void visitThen( final IParserNode ifNode )
+ {
+ beforeVisitingIfBlock();
+
+ super.visitThen( ifNode );
+
+ afterVisitingIfBlock( ifNode );
+ }
+
+ private void afterVisitingIfBlock( final IParserNode ifNode )
+ {
+ ifLevel--;
+ if ( ifLevel >= getThreshold() )
+ {
+ addViolation( ifNode );
+ }
+ }
+
+ private void beforeVisitingIfBlock()
+ {
+ ifLevel++;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/DynamicFiltersUsedInPopup.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/DynamicFiltersUsedInPopup.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/DynamicFiltersUsedInPopup.java
new file mode 100644
index 0000000..06aa2ed
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/DynamicFiltersUsedInPopup.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.performance;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class DynamicFiltersUsedInPopup extends AbstractRegexpBasedRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+ */
+ @Override
+ public final boolean isConcernedByTheCurrentFile()
+ {
+ return getCurrentFile().getClassName().contains( "Popup" );
+ }
+
+ /*
+ * (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.AbstractRegexpBasedRule#getRegexp()
+ */
+ @Override
+ protected final String getRegexp()
+ {
+ return ".*Filter.*";
+ }
+
+ /*
+ * (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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/HeavyConstructorRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/HeavyConstructorRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/HeavyConstructorRule.java
new file mode 100644
index 0000000..51d4d3a
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/HeavyConstructorRule.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.performance;
+
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.AbstractMaximizedAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public class HeavyConstructorRule extends AbstractMaximizedAstFlexRule
+{
+ private IFunction currentConstructor = null;
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+ * getActualValueForTheCurrentViolation()
+ */
+ public final int getActualValueForTheCurrentViolation()
+ {
+ return currentConstructor.getCyclomaticComplexity();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getDefaultThreshold
+ * ()
+ */
+ public final int getDefaultThreshold()
+ {
+ return 1;
+ }
+
+ /*
+ * (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 )
+ {
+ currentConstructor = constructor;
+ final int cyclomaticComplexity = constructor.getCyclomaticComplexity();
+ if ( cyclomaticComplexity > getThreshold() )
+ {
+ addViolation( constructor,
+ String.valueOf( cyclomaticComplexity ) );
+ }
+ }
+
+ /*
+ * (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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/RecursiveStyleManagerRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/RecursiveStyleManagerRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/RecursiveStyleManagerRule.java
new file mode 100644
index 0000000..1ccaf27
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/RecursiveStyleManagerRule.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 com.adobe.ac.pmd.rules.performance;
+
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public final class RecursiveStyleManagerRule extends AbstractAstFlexRule
+{
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitMethodCall(com.adobe
+ * .ac.pmd.parser.IParserNode)
+ */
+ @Override
+ protected void visitMethodCall( final IParserNode methodCallNode )
+ {
+ final String methodName = methodCallNode.getChild( 0 ).getStringValue();
+
+ if ( "loadStyles".equals( methodName )
+ && ( methodCallNode.getChild( 1 ).numChildren() != 2 || "true".equals( methodCallNode.getChild( 1 )
+ .getChild( 1 )
+ .getStringValue() ) ) )
+ {
+ addViolation( methodCallNode );
+ }
+ super.visitMethodCall( methodCallNode );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/UseTraceFunctionRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/UseTraceFunctionRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/UseTraceFunctionRule.java
new file mode 100644
index 0000000..55346e7
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/performance/UseTraceFunctionRule.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.performance;
+
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class UseTraceFunctionRule 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 "trace";
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/AllowAllSecureDomainRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/AllowAllSecureDomainRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/AllowAllSecureDomainRule.java
new file mode 100644
index 0000000..f39df22
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/AllowAllSecureDomainRule.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.security;
+
+import java.util.regex.Matcher;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class AllowAllSecureDomainRule 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.HIGH;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+ */
+ @Override
+ protected final String getRegexp()
+ {
+ return "\\s*([a-zA-Z]+)\\.allowDomain\\s*\\(\\s*['\"]\\*['\"]\\s*\\).*";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#isCurrentLineConcerned
+ * (java.lang.String)
+ */
+ @Override
+ protected boolean isCurrentLineConcerned( final String line )
+ {
+ return line.contains( "allowDomain" );
+ }
+
+ /*
+ * (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 );
+ final boolean result = false;
+
+ if ( matcher.matches() )
+ {
+ final String objectName = matcher.group( 1 ).trim();
+
+ if ( objectName == null )
+ {
+ return false;
+ }
+
+ if ( objectName.equalsIgnoreCase( "Security" ) )
+ {
+ return true;
+ }
+ }
+ return result;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/AllowInsecureDomainRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/AllowInsecureDomainRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/AllowInsecureDomainRule.java
new file mode 100644
index 0000000..7729ebf
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/AllowInsecureDomainRule.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.security;
+
+import java.util.regex.Matcher;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class AllowInsecureDomainRule 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.HIGH;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+ */
+ @Override
+ protected final String getRegexp()
+ {
+ return ".*\\.allowInsecureDomain[ \\(]+.*";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#isCurrentLineConcerned
+ * (java.lang.String)
+ */
+ @Override
+ protected boolean isCurrentLineConcerned( final String line )
+ {
+ return line.contains( "allowInsecureDomain" );
+ }
+
+ /*
+ * (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 );
+ final boolean result = false;
+
+ if ( matcher.matches() )
+ {
+ return true;
+ }
+ return result;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/ImportLoadBestPracticeRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/ImportLoadBestPracticeRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/ImportLoadBestPracticeRule.java
new file mode 100644
index 0000000..3d3f058
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/ImportLoadBestPracticeRule.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.security;
+
+import java.util.regex.Matcher;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class ImportLoadBestPracticeRule 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.LOW;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+ */
+ @Override
+ protected final String getRegexp()
+ {
+ return ".*(([,=]\\s*SecurityDomain\\.currentDomain)|(\\.loadBytes\\s?\\()).*";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#isCurrentLineConcerned
+ * (java.lang.String)
+ */
+ @Override
+ protected boolean isCurrentLineConcerned( final String line )
+ {
+ return line.contains( "SecurityDomain.currentDomain" )
+ || line.contains( ".loadBytes" );
+ }
+
+ /*
+ * (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 );
+ final boolean result = false;
+
+ if ( matcher.matches() )
+ {
+ return true;
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/InsecureExactSettingsRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/InsecureExactSettingsRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/InsecureExactSettingsRule.java
new file mode 100644
index 0000000..ce40dfc
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/InsecureExactSettingsRule.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.security;
+
+import java.util.regex.Matcher;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class InsecureExactSettingsRule 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.HIGH;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+ */
+ @Override
+ protected final String getRegexp()
+ {
+ return ".*\\.exactSettings[ \\t=]+([a-zA-Z]+).*";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#isCurrentLineConcerned
+ * (java.lang.String)
+ */
+ @Override
+ protected boolean isCurrentLineConcerned( final String line )
+ {
+ return line.contains( "exactSettings" );
+ }
+
+ /*
+ * (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 );
+ boolean result = false;
+
+ if ( matcher.matches() )
+ {
+ result = matcher.group( 1 ).trim().equalsIgnoreCase( "false" );
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LSOSecureFalseRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LSOSecureFalseRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LSOSecureFalseRule.java
new file mode 100644
index 0000000..54f3219
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LSOSecureFalseRule.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.security;
+
+import java.util.regex.Matcher;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class LSOSecureFalseRule 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.LOW;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+ */
+ @Override
+ protected final String getRegexp()
+ {
+ return ".*\\.getLocal\\s*\\([^,]+\\,[^,]+\\,([A-Za-z ]+)\\).*";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#isCurrentLineConcerned
+ * (java.lang.String)
+ */
+ @Override
+ protected boolean isCurrentLineConcerned( final String line )
+ {
+ return line.contains( "getLocal" );
+ }
+
+ /*
+ * (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 );
+
+ if ( matcher.matches() )
+ {
+ final String secureFlag = matcher.group( 1 ).trim();
+
+ if ( secureFlag.equalsIgnoreCase( "false" ) )
+ {
+ return true;
+ }
+
+ }
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LocalConnectionStarRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LocalConnectionStarRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LocalConnectionStarRule.java
new file mode 100644
index 0000000..2bf7ae0
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LocalConnectionStarRule.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.security;
+
+import java.util.regex.Matcher;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class LocalConnectionStarRule 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.HIGH;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+ */
+ @Override
+ protected final String getRegexp()
+ {
+ return ".*\\s([a-zA-Z0-9\\.\\-_]+)\\.allowDomain\\s*\\(\\s*['\"]\\*['\"]\\s*\\).*";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#isCurrentLineConcerned
+ * (java.lang.String)
+ */
+ @Override
+ protected boolean isCurrentLineConcerned( final String line )
+ {
+ return line.contains( "allowDomain" );
+ }
+
+ /*
+ * (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 );
+ boolean result = false;
+
+ if ( matcher.matches() )
+ {
+ final String objectName = matcher.group( 1 ).trim();
+
+ if ( objectName.equalsIgnoreCase( "Security" ) )
+ {
+ return false;
+ }
+
+ result = true;
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooLongFunctionRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooLongFunctionRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooLongFunctionRule.java
new file mode 100644
index 0000000..be51e7e
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooLongFunctionRule.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.sizing;
+
+import com.adobe.ac.pmd.nodes.utils.FunctionUtils;
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.AbstractMaximizedAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public class TooLongFunctionRule extends AbstractMaximizedAstFlexRule
+{
+ public static final int DEFAULT_THRESHOLD = 20;
+ private int functionLength;
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+ * getActualValueForTheCurrentViolation()
+ */
+ public final int getActualValueForTheCurrentViolation()
+ {
+ return functionLength;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getDefaultThreshold
+ * ()
+ */
+ public final int getDefaultThreshold()
+ {
+ return DEFAULT_THRESHOLD;
+ }
+
+ /*
+ * (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#visitFunction(com.adobe
+ * .ac.pmd.parser.IParserNode,
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule.FunctionType)
+ */
+ @Override
+ protected final void visitFunction( final IParserNode functionNode,
+ final FunctionType type )
+ {
+ super.visitFunction( functionNode,
+ type );
+
+ final IParserNode block = functionNode.getChild( functionNode.numChildren() - 1 );
+
+ if ( block != null
+ && block.numChildren() != 0 )
+ {
+ functionLength = FunctionUtils.computeFunctionLength( getCurrentFile(),
+ block );
+ if ( functionLength > getThreshold() )
+ {
+ addViolation( getNameFromFunctionDeclaration( functionNode ) );
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooLongSwitchCaseRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooLongSwitchCaseRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooLongSwitchCaseRule.java
new file mode 100644
index 0000000..c383a2d
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooLongSwitchCaseRule.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.sizing;
+
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.AbstractMaximizedAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public class TooLongSwitchCaseRule extends AbstractMaximizedAstFlexRule
+{
+ private int length;
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+ * getActualValueForTheCurrentViolation()
+ */
+ public final int getActualValueForTheCurrentViolation()
+ {
+ return length;
+ }
+
+ /*
+ * (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.AbstractAstFlexRule#visitSwitchCase(com.adobe
+ * .ac.pmd.parser.IParserNode)
+ */
+ @Override
+ protected final void visitSwitchCase( final IParserNode caseBlock )
+ {
+ if ( caseBlock.getLastChild() != null )
+ {
+ length = caseBlock.getLastChild().getLine()
+ - caseBlock.getLine();
+ if ( length > getThreshold() )
+ {
+ addViolation( caseBlock );
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFieldInVORule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFieldInVORule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFieldInVORule.java
new file mode 100644
index 0000000..44d8b22
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFieldInVORule.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.sizing;
+
+/**
+ * @author xagnetti
+ */
+public class TooManyFieldInVORule extends TooManyFieldsRule
+{
+ public static final int DEFAULT_THRESHOLD_FOR_VO = 15;
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.sizing.TooManyFieldsRule#getDefaultThreshold()
+ */
+ @Override
+ public final int getDefaultThreshold()
+ {
+ return DEFAULT_THRESHOLD_FOR_VO;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.sizing.TooManyFieldsRule#isConcernedByTheCurrentFile
+ * ()
+ */
+ @Override
+ public final boolean isConcernedByTheCurrentFile()
+ {
+ return !super.isConcernedByTheCurrentFile();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFieldsRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFieldsRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFieldsRule.java
new file mode 100644
index 0000000..5dba6cb
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFieldsRule.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.sizing;
+
+import java.util.List;
+
+import com.adobe.ac.pmd.nodes.IAttribute;
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.AbstractMaximizedAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public class TooManyFieldsRule extends AbstractMaximizedAstFlexRule
+{
+ public static final int DEFAULT_THRESHOLD = 5;
+ private int attributesNb = 0;
+ private IClass classNode = null;
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+ * getActualValueForTheCurrentViolation()
+ */
+ public final int getActualValueForTheCurrentViolation()
+ {
+ return attributesNb;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getDefaultThreshold
+ * ()
+ */
+ public int getDefaultThreshold()
+ {
+ return DEFAULT_THRESHOLD;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+ * ()
+ */
+ @Override
+ public boolean isConcernedByTheCurrentFile()
+ {
+ return !getCurrentFile().getClassName().endsWith( "VO.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 classNodeToBeSet )
+ {
+ classNode = classNodeToBeSet;
+ super.findViolations( classNodeToBeSet );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromAttributes
+ * (java.util.List)
+ */
+ @Override
+ protected final void findViolationsFromAttributes( final List< IAttribute > attributes )
+ {
+ attributesNb = attributes.size();
+
+ if ( attributesNb > getThreshold() )
+ {
+ addViolation( classNode );
+ }
+ }
+
+ /*
+ * (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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFunctionRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFunctionRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFunctionRule.java
new file mode 100644
index 0000000..e3ced20
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFunctionRule.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.sizing;
+
+import java.util.List;
+
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.AbstractMaximizedAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public class TooManyFunctionRule extends AbstractMaximizedAstFlexRule
+{
+ public static final int DEFAULT_THRESHOLD = 10;
+ private IClass classNode = null;
+ private int functionNb;
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+ * getActualValueForTheCurrentViolation()
+ */
+ public final int getActualValueForTheCurrentViolation()
+ {
+ return functionNb;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getDefaultThreshold
+ * ()
+ */
+ public final int getDefaultThreshold()
+ {
+ return DEFAULT_THRESHOLD;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+ * .ac.pmd.nodes.IClass)
+ */
+ @Override
+ protected final void findViolations( final IClass classNodeToSet )
+ {
+ functionNb = 0;
+ classNode = classNodeToSet;
+
+ super.findViolations( classNodeToSet );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(java.util
+ * .List)
+ */
+ @Override
+ protected final void findViolations( final List< IFunction > functions )
+ {
+ for ( final IFunction functionNode : functions )
+ {
+ if ( !functionNode.isGetter()
+ && !functionNode.isSetter() && functionNode != classNode.getConstructor() )
+ {
+ functionNb++;
+ }
+ }
+ if ( functionNb > getThreshold() )
+ {
+ 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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyParametersRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyParametersRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyParametersRule.java
new file mode 100644
index 0000000..109a50b
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyParametersRule.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 com.adobe.ac.pmd.rules.sizing;
+
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.AbstractMaximizedAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public class TooManyParametersRule extends AbstractMaximizedAstFlexRule
+{
+ public static final int DEFAULT_THRESHOLD = 4;
+ private int paramsNb;
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+ * getActualValueForTheCurrentViolation()
+ */
+ public final int getActualValueForTheCurrentViolation()
+ {
+ return paramsNb;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getDefaultThreshold
+ * ()
+ */
+ public final int getDefaultThreshold()
+ {
+ return DEFAULT_THRESHOLD;
+ }
+
+ /*
+ * (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.AbstractAstFlexRule#visitFunction(com.adobe
+ * .ac.pmd.parser.IParserNode,
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule.FunctionType)
+ */
+ @Override
+ protected final void visitFunction( final IParserNode ast,
+ final FunctionType type )
+ {
+ super.visitFunction( ast,
+ type );
+
+ final IParserNode paramList = ast.getChild( 2 );
+
+ paramsNb = paramList.numChildren();
+
+ if ( paramsNb > getThreshold() )
+ {
+ addViolation( paramList );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyPublicRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyPublicRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyPublicRule.java
new file mode 100644
index 0000000..e4c7fda
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyPublicRule.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.sizing;
+
+import java.util.List;
+
+import com.adobe.ac.pmd.nodes.IAttribute;
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.AbstractMaximizedAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public class TooManyPublicRule extends AbstractMaximizedAstFlexRule
+{
+ public static final int DEFAULT_THRESHOLD = 10;
+ private IFunction constructor;
+ private int publicCount;
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+ * getActualValueForTheCurrentViolation()
+ */
+ public final int getActualValueForTheCurrentViolation()
+ {
+ return publicCount;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getDefaultThreshold
+ * ()
+ */
+ public final int getDefaultThreshold()
+ {
+ return DEFAULT_THRESHOLD;
+ }
+
+ /*
+ * (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 )
+ {
+ publicCount = 0;
+ constructor = classNode.getConstructor();
+
+ super.findViolations( classNode );
+
+ if ( publicCount > getThreshold() )
+ {
+ addViolation( classNode );
+ }
+ }
+
+ /*
+ * (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.isPublic()
+ && !function.equals( constructor ) && !function.isGetter() && !function.isSetter() )
+ {
+ publicCount++;
+ }
+ }
+
+ /*
+ * (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 variable : variables )
+ {
+ if ( variable.isPublic() )
+ {
+ publicCount++;
+ }
+ }
+ }
+
+ /*
+ * (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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/BadFormatLoggerRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/BadFormatLoggerRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/BadFormatLoggerRule.java
new file mode 100644
index 0000000..9774747
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/BadFormatLoggerRule.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 com.adobe.ac.pmd.rules.style;
+
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.IField;
+import com.adobe.ac.pmd.nodes.IVariable;
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class BadFormatLoggerRule extends AbstractAstFlexRule
+{
+ private static final String CORRECT_LOGGER_NAME = "LOG";
+ private static final String LOGGER_INTERFACE = "ILogger";
+ private static final String MESSAGE_LOGGER_NAME_IS_NOT_LOG = "The logger name is not LOG";
+ private static final String MESSAGE_NOT_INITIALIZED = "The logger is not initialized";
+ private static final String MESSAGE_SHOULD_BE_CONSTANT = "A logger should be constant";
+
+ /*
+ * (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 )
+ {
+ for ( final IVariable field : classNode.getAttributes() )
+ {
+ if ( field.getType().toString().equals( LOGGER_INTERFACE ) )
+ {
+ addViolation( field.getInternalNode(),
+ field.getInternalNode(),
+ MESSAGE_SHOULD_BE_CONSTANT );
+ }
+ }
+ for ( final IField field : classNode.getConstants() )
+ {
+ if ( field.getType().toString().equals( LOGGER_INTERFACE ) )
+ {
+ if ( !field.getName().equals( CORRECT_LOGGER_NAME ) )
+ {
+ addViolation( field.getInternalNode(),
+ field.getInternalNode(),
+ MESSAGE_LOGGER_NAME_IS_NOT_LOG );
+ }
+ if ( field.getInitializationExpression() == null )
+ {
+ addViolation( field.getInternalNode(),
+ field.getInternalNode(),
+ MESSAGE_NOT_INITIALIZED );
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.LOW;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/ConstructorNonEmptyReturnTypeRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/ConstructorNonEmptyReturnTypeRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/ConstructorNonEmptyReturnTypeRule.java
new file mode 100644
index 0000000..bbb743f
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/ConstructorNonEmptyReturnTypeRule.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 com.adobe.ac.pmd.rules.style;
+
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class ConstructorNonEmptyReturnTypeRule extends AbstractAstFlexRule
+{
+ /*
+ * (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.getReturnType() != null
+ && !"".equals( constructor.getReturnType().toString() ) )
+ {
+ addViolation( constructor );
+ }
+ }
+
+ /*
+ * (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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/CopyrightMissingRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/CopyrightMissingRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/CopyrightMissingRule.java
new file mode 100644
index 0000000..f0e641b
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/CopyrightMissingRule.java
@@ -0,0 +1,95 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package com.adobe.ac.pmd.rules.style;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.adobe.ac.pmd.IFlexViolation;
+import com.adobe.ac.pmd.files.IAs3File;
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.pmd.files.IMxmlFile;
+import com.adobe.ac.pmd.rules.core.AbstractFlexRule;
+import com.adobe.ac.pmd.rules.core.ViolationPosition;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class CopyrightMissingRule extends AbstractFlexRule
+{
+ /*
+ * (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#findViolationsInCurrentFile()
+ */
+ @Override
+ protected final List< IFlexViolation > findViolationsInCurrentFile()
+ {
+ final List< IFlexViolation > violations = new ArrayList< IFlexViolation >();
+ final IFlexFile currentFile = getCurrentFile();
+
+ if ( currentFile.getLinesNb() == 1 )
+ {
+ addViolation( violations );
+ }
+ else if ( currentFile.getLinesNb() > 1 )
+ {
+ final String commentOpeningTag = currentFile.getCommentOpeningTag();
+ final String firstLine = currentFile.getLineAt( 1 );
+ final String secondLine = currentFile.getLineAt( 2 );
+
+ if ( !firstLine.startsWith( commentOpeningTag )
+ && !( currentFile instanceof IMxmlFile && secondLine.contains( commentOpeningTag ) )
+ && !( currentFile instanceof IAs3File && firstLine.contains( currentFile.getSingleLineComment() ) ) )
+ {
+ addViolation( violations );
+ }
+ }
+
+ return violations;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+
+ private void addViolation( final List< IFlexViolation > violations )
+ {
+ addViolation( violations,
+ new ViolationPosition( -1 ) );
+ }
+}