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:44 UTC
[13/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/binding/BindingUtilsRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/binding/BindingUtilsRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/binding/BindingUtilsRule.java
new file mode 100644
index 0000000..5b86b95
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/binding/BindingUtilsRule.java
@@ -0,0 +1,48 @@
+/*
+ * 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.binding;
+
+import com.adobe.ac.pmd.rules.core.AbstractForbiddenImportRule;
+import com.adobe.ac.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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/binding/ChangeWatcherRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/binding/ChangeWatcherRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/binding/ChangeWatcherRule.java
new file mode 100644
index 0000000..05e3f42
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/binding/ChangeWatcherRule.java
@@ -0,0 +1,48 @@
+/*
+ * 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.binding;
+
+import com.adobe.ac.pmd.rules.core.AbstractForbiddenImportRule;
+import com.adobe.ac.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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/binding/TooLongBindingExpressionRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/binding/TooLongBindingExpressionRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/binding/TooLongBindingExpressionRule.java
new file mode 100644
index 0000000..4241f8f
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/binding/TooLongBindingExpressionRule.java
@@ -0,0 +1,115 @@
+/*
+ * 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.binding;
+
+import java.util.regex.Matcher;
+
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.AbstractMaximizedRegexpBasedRule;
+
+/**
+ * @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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/BadCairngormEventNameFormatRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/BadCairngormEventNameFormatRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/BadCairngormEventNameFormatRule.java
new file mode 100644
index 0000000..119b01e
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/BadCairngormEventNameFormatRule.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.cairngorm;
+
+import org.apache.commons.lang.StringUtils;
+
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.IField;
+import com.adobe.ac.pmd.nodes.IFunction;
+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 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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/BindableModelLocatorRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/BindableModelLocatorRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/BindableModelLocatorRule.java
new file mode 100644
index 0000000..eb3dca0
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/BindableModelLocatorRule.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.cairngorm;
+
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+import com.adobe.ac.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/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/CairngormEventDispatcherCallExplicitlyRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/CairngormEventDispatcherCallExplicitlyRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/CairngormEventDispatcherCallExplicitlyRule.java
new file mode 100644
index 0000000..22c44ef
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/CairngormEventDispatcherCallExplicitlyRule.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.cairngorm;
+
+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 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;
+ }
+}
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/cairngorm/FatControllerRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/FatControllerRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/FatControllerRule.java
new file mode 100644
index 0000000..7c23727
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/FatControllerRule.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 com.adobe.ac.pmd.rules.cairngorm;
+
+import java.util.List;
+
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.IPackage;
+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 class FatControllerRule extends AbstractAstFlexRule // NO_UCD
+{
+ private static final int DEFAULT_THRESHOLD = 5;
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+ * ()
+ */
+ @Override
+ public final boolean isConcernedByTheCurrentFile()
+ {
+ return getCurrentFile().getClassName().endsWith( "Controller.as" );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+ * .ac.pmd.nodes.IPackage)
+ */
+ @Override
+ protected final void findViolations( final IPackage packageNode )
+ {
+ final IClass classNode = packageNode.getClassNode();
+
+ if ( classNode != null )
+ {
+ final int commandsCount = computeCommandsCountInImport( packageNode.getImports() );
+ final int methodsCount = classNode.getFunctions().size();
+
+ if ( methodsCount > 0
+ && commandsCount
+ / methodsCount > DEFAULT_THRESHOLD )
+ {
+ addViolation( classNode );
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+
+ private int computeCommandsCountInImport( final List< IParserNode > imports )
+ {
+ int commandImport = 0;
+
+ if ( imports != null )
+ {
+ for ( final IParserNode importNode : imports )
+ {
+ if ( importNode.getStringValue().endsWith( "Command" ) )
+ {
+ commandImport++;
+ }
+ }
+ }
+ return commandImport;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/ModelLocatorReferencedMoreThanOncePerClassRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/ModelLocatorReferencedMoreThanOncePerClassRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/ModelLocatorReferencedMoreThanOncePerClassRule.java
new file mode 100644
index 0000000..68bfb27
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/ModelLocatorReferencedMoreThanOncePerClassRule.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.cairngorm;
+
+/**
+ * @author xagnetti
+ */
+public class ModelLocatorReferencedMoreThanOncePerClassRule extends
+ ReferenceModelLocatorOutsideTheMainApplicationRule
+{
+ private int referencesPerFile;
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.cairngorm.
+ * ReferenceModelLocatorOutsideTheMainApplicationRule
+ * #isViolationDetectedOnThisMatchingLine(java.lang.String)
+ */
+ @Override
+ protected final boolean isViolationDetectedOnThisMatchingLine( final String line )
+ {
+ if ( !line.contains( "import" )
+ && !line.contains( "return" ) )
+ {
+ referencesPerFile++;
+ }
+ return referencesPerFile > 1;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#onRuleStart()
+ */
+ @Override
+ protected final void onRuleStart()
+ {
+ referencesPerFile = 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/ReferenceModelLocatorOutsideTheMainApplicationRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/ReferenceModelLocatorOutsideTheMainApplicationRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/ReferenceModelLocatorOutsideTheMainApplicationRule.java
new file mode 100644
index 0000000..5df0b7e
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/cairngorm/ReferenceModelLocatorOutsideTheMainApplicationRule.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.cairngorm;
+
+import com.adobe.ac.pmd.parser.KeyWords;
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+import de.bokelberg.flex.parser.AS3Parser;
+
+/**
+ * @author xagnetti
+ */
+public class ReferenceModelLocatorOutsideTheMainApplicationRule extends AbstractRegexpBasedRule // NO_UCD
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+ */
+ @Override
+ public final boolean isConcernedByTheCurrentFile()
+ {
+ return !getCurrentFile().getClassName().endsWith( "ModelLocator.as" )
+ && ( !getCurrentFile().isMxml() || !getCurrentFile().isMainApplication() );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+ */
+ @Override
+ protected final String getRegexp()
+ {
+ return ".*ModelLocator.*";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#
+ * isViolationDetectedOnThisMatchingLine(java.lang.String)
+ */
+ @Override
+ protected boolean isViolationDetectedOnThisMatchingLine( final String line )
+ {
+ return !line.contains( KeyWords.IMPORT.toString() )
+ && !line.contains( AS3Parser.SINGLE_LINE_COMMENT );
+ }
+}
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/component/CallLaterDirectlyRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/component/CallLaterDirectlyRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/component/CallLaterDirectlyRule.java
new file mode 100644
index 0000000..5eaae55
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/component/CallLaterDirectlyRule.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.component;
+
+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 CallLaterDirectlyRule extends AbstractPrimaryAstRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#addViolation(com.adobe
+ * .ac.pmd.parser.IParserNode, com.adobe.ac.pmd.nodes.IFunction)
+ */
+ @Override
+ protected void addViolation( final IParserNode statement,
+ final IFunction function )
+ {
+ addViolation( statement );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.HIGH;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#getFirstPrimaryToFind()
+ */
+ @Override
+ protected String getFirstPrimaryToFind()
+ {
+ return "callLater";
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/component/UpdateChildrenNumberInUpdateDisplayListRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/component/UpdateChildrenNumberInUpdateDisplayListRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/component/UpdateChildrenNumberInUpdateDisplayListRule.java
new file mode 100644
index 0000000..642d3cc
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/component/UpdateChildrenNumberInUpdateDisplayListRule.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.component;
+
+import com.adobe.ac.pmd.nodes.IFunction;
+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 class UpdateChildrenNumberInUpdateDisplayListRule extends AbstractAstFlexRule // NO_UCD
+{
+ private static final String[] METHOD_NAMES =
+ { "addChild",
+ "addChildAt",
+ "removeChild",
+ "removeChildAt" };
+ private static final String UPDATE_DISPLAY_LIST = "updateDisplayList";
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+ * .ac.pmd.nodes.IFunction)
+ */
+ @Override
+ protected final void findViolations( final IFunction function )
+ {
+ if ( function.getName().equals( UPDATE_DISPLAY_LIST ) )
+ {
+ for ( final String methodName : METHOD_NAMES )
+ {
+ for ( final IParserNode statement : function.findPrimaryStatementsInBody( methodName ) )
+ {
+ addViolation( statement );
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.HIGH;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/css/StyleBlockInMxmlRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/css/StyleBlockInMxmlRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/css/StyleBlockInMxmlRule.java
new file mode 100644
index 0000000..15fa24a
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/css/StyleBlockInMxmlRule.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.css;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class StyleBlockInMxmlRule extends AbstractRegexpBasedRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+ */
+ @Override
+ public final boolean isConcernedByTheCurrentFile()
+ {
+ return getCurrentFile().isMxml();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+ */
+ @Override
+ protected final String getRegexp()
+ {
+ return ".*<mx:Style>.*";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#
+ * isViolationDetectedOnThisMatchingLine(java.lang.String)
+ */
+ @Override
+ protected final boolean isViolationDetectedOnThisMatchingLine( final String line )
+ {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/css/UseCssInsteadOfEmbedMetaDataRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/css/UseCssInsteadOfEmbedMetaDataRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/css/UseCssInsteadOfEmbedMetaDataRule.java
new file mode 100644
index 0000000..cc9c5b3
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/css/UseCssInsteadOfEmbedMetaDataRule.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.css;
+
+import java.util.List;
+
+import com.adobe.ac.pmd.nodes.IAttribute;
+import com.adobe.ac.pmd.nodes.IConstant;
+import com.adobe.ac.pmd.nodes.IMetaData;
+import com.adobe.ac.pmd.nodes.IMetaDataListHolder;
+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 UseCssInsteadOfEmbedMetaDataRule extends AbstractAstFlexRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromAttributes
+ * (java.util.List)
+ */
+ @Override
+ protected final void findViolationsFromAttributes( final List< IAttribute > variables )
+ {
+ super.findViolationsFromAttributes( variables );
+
+ findViolationsInMetaDataList( variables );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromConstants
+ * (java.util.List)
+ */
+ @Override
+ protected final void findViolationsFromConstants( final List< IConstant > constants )
+ {
+ super.findViolationsFromConstants( constants );
+
+ findViolationsInMetaDataList( constants );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.LOW;
+ }
+
+ private void findViolationsInMetaDataList( final List< ? extends IMetaDataListHolder > metaDataList )
+ {
+ for ( final IMetaDataListHolder metaData : metaDataList )
+ {
+ final List< IMetaData > embedList = metaData.getMetaData( MetaData.EMBED );
+
+ if ( embedList != null )
+ {
+ addViolation( embedList.get( 0 ) );
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/empty/AbstractEmptyBlockRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/empty/AbstractEmptyBlockRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/empty/AbstractEmptyBlockRule.java
new file mode 100644
index 0000000..9f92476
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/empty/AbstractEmptyBlockRule.java
@@ -0,0 +1,37 @@
+/*
+ * 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.empty;
+
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.parser.NodeKind;
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public abstract class AbstractEmptyBlockRule extends AbstractAstFlexRule
+{
+ /**
+ * @param block
+ * @return
+ */
+ protected static boolean isBlockEmpty( final IParserNode block )
+ {
+ return block.is( NodeKind.BLOCK )
+ && block.numChildren() == 0 || block.is( NodeKind.STMT_EMPTY );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/empty/EmptyCatchStatementRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/empty/EmptyCatchStatementRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/empty/EmptyCatchStatementRule.java
new file mode 100644
index 0000000..b73a29e
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/empty/EmptyCatchStatementRule.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.empty;
+
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class EmptyCatchStatementRule extends AbstractEmptyBlockRule
+{
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitCatch(com.adobe.ac
+ * .pmd.parser.IParserNode)
+ */
+ @Override
+ protected final void visitCatch( final IParserNode ast )
+ {
+ super.visitCatch( ast );
+
+ if ( isBlockEmpty( ast.getChild( 2 ) ) )
+ {
+ addViolation( ast );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/empty/EmptyIfStmtRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/empty/EmptyIfStmtRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/empty/EmptyIfStmtRule.java
new file mode 100644
index 0000000..2774d93
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/empty/EmptyIfStmtRule.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.empty;
+
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class EmptyIfStmtRule extends AbstractEmptyBlockRule
+{
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitIf(com.adobe.ac.pmd
+ * .parser.IParserNode)
+ */
+ @Override
+ protected final void visitIf( final IParserNode ast )
+ {
+ super.visitIf( ast );
+
+ if ( isBlockEmpty( ast.getChild( 1 ) ) )
+ {
+ addViolation( ast );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/AbstractEventRelatedRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/AbstractEventRelatedRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/AbstractEventRelatedRule.java
new file mode 100644
index 0000000..b6d4514
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/AbstractEventRelatedRule.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.event;
+
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public abstract class AbstractEventRelatedRule extends AbstractAstFlexRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+ * ()
+ */
+ @Override
+ public final boolean isConcernedByTheCurrentFile()
+ {
+ return !getCurrentFile().isMxml();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+ * .ac.pmd.nodes.IClass)
+ */
+ @Override
+ protected void findViolations( final IClass classNode )
+ {
+ if ( classNode.getExtensionName() != null
+ && classNode.getExtensionName().endsWith( "Event" ) )
+ {
+ super.findViolations( classNode );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/ConstructorDispatchingEventRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/ConstructorDispatchingEventRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/ConstructorDispatchingEventRule.java
new file mode 100644
index 0000000..1d9945e
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/ConstructorDispatchingEventRule.java
@@ -0,0 +1,65 @@
+/*
+ * 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.event;
+
+import com.adobe.ac.pmd.nodes.IFunction;
+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 class ConstructorDispatchingEventRule extends AbstractAstFlexRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+ * ()
+ */
+ @Override
+ public final boolean isConcernedByTheCurrentFile()
+ {
+ return !getCurrentFile().isMxml();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromConstructor
+ * (com.adobe.ac.pmd.nodes.IFunction)
+ */
+ @Override
+ protected final void findViolationsFromConstructor( final IFunction constructor )
+ {
+ for ( final IParserNode statement : constructor.findPrimaryStatementsInBody( "dispatchEvent" ) )
+ {
+ addViolation( statement );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.HIGH;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/DefaultEventNameRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/DefaultEventNameRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/DefaultEventNameRule.java
new file mode 100644
index 0000000..523490a
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/DefaultEventNameRule.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.event;
+
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class DefaultEventNameRule extends AbstractEventRelatedRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromConstructor
+ * (com.adobe.ac.pmd.nodes.IFunction)
+ */
+ @Override
+ protected final void findViolationsFromConstructor( final IFunction constructor )
+ {
+ if ( constructor.getParameters().size() > 0
+ && constructor.getParameters().get( 0 ).getType().toString().equals( "String" )
+ && constructor.getParameters().get( 0 ).getInitializationExpression() != null )
+ {
+ addViolation( constructor.getParameters().get( 0 ) );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.HIGH;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/DispatchHardCodedEventNameRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/DispatchHardCodedEventNameRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/DispatchHardCodedEventNameRule.java
new file mode 100644
index 0000000..2770a12
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/DispatchHardCodedEventNameRule.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.event;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class DispatchHardCodedEventNameRule extends AbstractRegexpBasedRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+ */
+ @Override
+ public final boolean isConcernedByTheCurrentFile()
+ {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+ */
+ @Override
+ protected final String getRegexp()
+ {
+ return ".*dispatchEvent *\\( *new Event\\( *(\"|\').*(\"|\') *\\) *\\).*";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#isCurrentLineConcerned
+ * (java.lang.String)
+ */
+ @Override
+ protected boolean isCurrentLineConcerned( final String line )
+ {
+ return line.contains( "dispatchEvent" );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#
+ * isViolationDetectedOnThisMatchingLine(java.lang.String)
+ */
+ @Override
+ protected final boolean isViolationDetectedOnThisMatchingLine( final String line )
+ {
+ return getMatcher( line ).matches();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/EventMissingCloneFunctionRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/EventMissingCloneFunctionRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/EventMissingCloneFunctionRule.java
new file mode 100644
index 0000000..69eca21
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/EventMissingCloneFunctionRule.java
@@ -0,0 +1,82 @@
+/*
+ * 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.event;
+
+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;
+
+/**
+ * @author xagnetti
+ */
+public class EventMissingCloneFunctionRule extends AbstractEventRelatedRule
+{
+ private IClass classNode = null;
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.event.AbstractEventRelatedRule#findViolations(com
+ * .adobe.ac.pmd.nodes.IClass)
+ */
+ @Override
+ protected final void findViolations( final IClass classNodeToBeSet )
+ {
+ classNode = classNodeToBeSet;
+ if ( "Event".equals( classNode.getExtensionName() ) )
+ {
+ super.findViolations( classNode );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(java.util
+ * .List)
+ */
+ @Override
+ protected final void findViolations( final List< IFunction > functions )
+ {
+ boolean cloneFound = false;
+
+ for ( final IFunction functionNode : functions )
+ {
+ if ( "clone".equals( functionNode.getName() ) )
+ {
+ cloneFound = true;
+ break;
+ }
+ }
+ if ( !cloneFound )
+ {
+ addViolation( classNode );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.HIGH;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/ListenForHardCodedEventNameRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/ListenForHardCodedEventNameRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/ListenForHardCodedEventNameRule.java
new file mode 100644
index 0000000..99d0a24
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/ListenForHardCodedEventNameRule.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.event;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class ListenForHardCodedEventNameRule extends AbstractRegexpBasedRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+ */
+ @Override
+ public final boolean isConcernedByTheCurrentFile()
+ {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#getRegexp()
+ */
+ @Override
+ protected final String getRegexp()
+ {
+ return ".*addEventListener *\\( *(\"|\').*(\"|\').*";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#isCurrentLineConcerned
+ * (java.lang.String)
+ */
+ @Override
+ protected boolean isCurrentLineConcerned( final String line )
+ {
+ return line.contains( "addEventListener" );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule#
+ * isViolationDetectedOnThisMatchingLine(java.lang.String)
+ */
+ @Override
+ protected final boolean isViolationDetectedOnThisMatchingLine( final String line )
+ {
+ return getMatcher( line ).matches();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/PublicVariableInCustomEventRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/PublicVariableInCustomEventRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/PublicVariableInCustomEventRule.java
new file mode 100644
index 0000000..caaf913
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/PublicVariableInCustomEventRule.java
@@ -0,0 +1,57 @@
+/*
+ * 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.event;
+
+import java.util.List;
+
+import com.adobe.ac.pmd.nodes.IAttribute;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class PublicVariableInCustomEventRule extends AbstractEventRelatedRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromAttributes
+ * (java.util.List)
+ */
+ @Override
+ protected final void findViolationsFromAttributes( final List< IAttribute > variables )
+ {
+ for ( final IAttribute attribute : variables )
+ {
+ if ( attribute.isPublic() )
+ {
+ addViolation( attribute,
+ attribute.getName() );
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/UnboundTypeInMetadataRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/UnboundTypeInMetadataRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/UnboundTypeInMetadataRule.java
new file mode 100644
index 0000000..0dc7d2a
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/UnboundTypeInMetadataRule.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.event;
+
+import java.util.List;
+import java.util.Map;
+
+import com.adobe.ac.pmd.files.IFlexFile;
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.IMetaData;
+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 UnboundTypeInMetadataRule extends AbstractAstFlexRule
+{
+ private static final String TYPE = "type";
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+ * .ac.pmd.nodes.IClass)
+ */
+ @Override
+ protected final void findViolations( final IClass classNode )
+ {
+ final List< IMetaData > eventMetaDatas = classNode.getMetaData( MetaData.EVENT );
+
+ if ( eventMetaDatas != null )
+ {
+ findViolationsInMetaDataNode( eventMetaDatas,
+ getFilesInSourcePath() );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+
+ private void findViolationsInMetaDataNode( final List< IMetaData > eventMetaDatas,
+ final Map< String, IFlexFile > files )
+ {
+ for ( final IMetaData metaData : eventMetaDatas )
+ {
+ if ( metaData.getProperty( TYPE ).length > 0 )
+ {
+ final String type = metaData.getProperty( TYPE )[ 0 ];
+
+ if ( !files.containsKey( type
+ + ".as" )
+ && !type.startsWith( "mx." ) && !type.startsWith( "flash." ) )
+ {
+ addViolation( metaData,
+ type );
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/UntypedEventMetadataRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/UntypedEventMetadataRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/UntypedEventMetadataRule.java
new file mode 100644
index 0000000..8851615
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/event/UntypedEventMetadataRule.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 com.adobe.ac.pmd.rules.event;
+
+import java.util.List;
+
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.IMetaData;
+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 UntypedEventMetadataRule extends AbstractAstFlexRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+ * .ac.pmd.nodes.IClass)
+ */
+ @Override
+ protected final void findViolations( final IClass classNode )
+ {
+ final List< IMetaData > eventMetaData = classNode.getMetaData( MetaData.EVENT );
+
+ if ( eventMetaData != null )
+ {
+ findViolationsInMetaDataNode( eventMetaData );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.LOW;
+ }
+
+ private void findViolationsInMetaDataNode( final List< IMetaData > eventMetaDatas )
+ {
+ for ( final IMetaData metaData : eventMetaDatas )
+ {
+ final String metaDataValue = metaData.getInternalNode().getStringValue();
+
+ if ( !metaDataValue.contains( "type = " ) )
+ {
+ addViolation( metaData );
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/flexunit/EmptyUnitTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/flexunit/EmptyUnitTest.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/flexunit/EmptyUnitTest.java
new file mode 100644
index 0000000..3980293
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/flexunit/EmptyUnitTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.flexunit;
+
+import com.adobe.ac.pmd.nodes.IClass;
+import com.adobe.ac.pmd.nodes.IFunction;
+import com.adobe.ac.pmd.nodes.MetaData;
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public final class EmptyUnitTest extends AbstractAstFlexRule
+{
+ private static final String[] ASSERTIONS = new String[]
+ { "assertEquals",
+ "assertObjectEquals",
+ "assertMatch",
+ "assertNoMatch",
+ "assertContained",
+ "assertNotContained",
+ "assertStrictlyEquals",
+ "assertTrue",
+ "assertFalse",
+ "assertNull",
+ "assertNotNull",
+ "assertUndefined",
+ "assertNotUndefined",
+ "assertThat",
+ "handleEvent",
+ "assertEvents",
+ "fail" };
+
+ private boolean isExtendingTestCase;
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+ * .ac.pmd.nodes.IClass)
+ */
+ @Override
+ protected void findViolations( final IClass classNode )
+ {
+ isExtendingTestCase = classNode.getExtensionName() != null
+ && classNode.getExtensionName().endsWith( "TestCase" );
+
+ super.findViolations( classNode );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+ * .ac.pmd.nodes.IFunction)
+ */
+ @Override
+ protected void findViolations( final IFunction function )
+ {
+ super.findViolations( function );
+
+ if ( isExtendingTestCase
+ && function.getName().startsWith( "test" )
+ && function.findPrimaryStatementInBody( ASSERTIONS ).isEmpty() )
+ {
+ addViolation( function );
+ }
+ if ( !function.getMetaData( MetaData.TEST ).isEmpty()
+ && function.findPrimaryStatementInBody( ASSERTIONS ).isEmpty() )
+ {
+ addViolation( function );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/maintanability/AlertShowRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/maintanability/AlertShowRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/maintanability/AlertShowRule.java
new file mode 100644
index 0000000..8b8ac35
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/maintanability/AlertShowRule.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.maintanability;
+
+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 AlertShowRule extends AbstractPrimaryAstRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#addViolation(com.adobe
+ * .ac.pmd.parser.IParserNode, com.adobe.ac.pmd.nodes.IFunction)
+ */
+ @Override
+ protected void addViolation( final IParserNode statement,
+ final IFunction function )
+ {
+ addViolation( statement );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.LOW;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#getFirstPrimaryToFind()
+ */
+ @Override
+ protected String getFirstPrimaryToFind()
+ {
+ return "Alert";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractPrimaryAstRule#getSecondPrimaryToFind
+ * ()
+ */
+ @Override
+ protected String getSecondPrimaryToFind()
+ {
+ return "show";
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/maintanability/ArrayFieldWithNoArrayElementTypeRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/maintanability/ArrayFieldWithNoArrayElementTypeRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/maintanability/ArrayFieldWithNoArrayElementTypeRule.java
new file mode 100644
index 0000000..f1d8f90
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/maintanability/ArrayFieldWithNoArrayElementTypeRule.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.maintanability;
+
+import java.util.List;
+
+import com.adobe.ac.pmd.nodes.IAttribute;
+import com.adobe.ac.pmd.nodes.IConstant;
+import com.adobe.ac.pmd.nodes.IField;
+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 ArrayFieldWithNoArrayElementTypeRule extends AbstractAstFlexRule
+{
+ private static final String ARRAY_TYPE = "Array";
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#isConcernedByTheCurrentFile
+ * ()
+ */
+ @Override
+ public boolean isConcernedByTheCurrentFile()
+ {
+ return getCurrentFile().isMxml();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromAttributes
+ * (java.util.List)
+ */
+ @Override
+ protected final void findViolationsFromAttributes( final List< IAttribute > variables )
+ {
+ findViolationFromFieds( variables );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolationsFromConstants
+ * (java.util.List)
+ */
+ @Override
+ protected void findViolationsFromConstants( final List< IConstant > constants )
+ {
+ findViolationFromFieds( constants );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+
+ private void findViolationFromFieds( final List< ? extends IField > fields )
+ {
+ for ( final IField variable : fields )
+ {
+ if ( ARRAY_TYPE.equals( variable.getType().toString() )
+ && variable.getMetaData( MetaData.ARRAY_ELEMENT_TYPE ) == null )
+ {
+ addViolation( variable,
+ variable.getName() );
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/maintanability/AvoidProtectedFieldInFinalClassRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/maintanability/AvoidProtectedFieldInFinalClassRule.java b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/maintanability/AvoidProtectedFieldInFinalClassRule.java
new file mode 100644
index 0000000..940ed49
--- /dev/null
+++ b/FlexPMD/flex-pmd-java/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/maintanability/AvoidProtectedFieldInFinalClassRule.java
@@ -0,0 +1,92 @@
+/*
+ * 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.maintanability;
+
+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.nodes.Modifier;
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class AvoidProtectedFieldInFinalClassRule extends AbstractAstFlexRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+ * .ac.pmd.nodes.IClass)
+ */
+ @Override
+ protected final void findViolations( final IClass classNode )
+ {
+ final boolean isClassFinal = classNode.isFinal();
+
+ findProtectedAttributes( classNode.getAttributes(),
+ isClassFinal );
+ findProtectedMethods( classNode.getFunctions(),
+ isClassFinal );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.LOW;
+ }
+
+ private void findProtectedAttributes( final List< IAttribute > atributes,
+ final boolean isClassFinal )
+ {
+ if ( atributes != null )
+ {
+ for ( final IAttribute field : atributes )
+ {
+ if ( field.is( Modifier.PROTECTED )
+ && isClassFinal )
+ {
+ addViolation( field,
+ field.getName() );
+ }
+ }
+ }
+ }
+
+ private void findProtectedMethods( final List< IFunction > functions,
+ final boolean isClassFinal )
+ {
+ if ( functions != null )
+ {
+ for ( final IFunction function : functions )
+ {
+ if ( function.is( Modifier.PROTECTED )
+ && !function.isOverriden() && isClassFinal )
+ {
+ addViolation( function );
+ }
+ }
+ }
+ }
+}