You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2014/04/25 08:18:12 UTC
[13/46] FlexPMD Donation from Adobe Systems Inc
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/AllowAllSecureDomainRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/AllowAllSecureDomainRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/AllowInsecureDomainRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/AllowInsecureDomainRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/ImportLoadBestPracticeRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/ImportLoadBestPracticeRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/InsecureExactSettingsRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/InsecureExactSettingsRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LSOSecureFalseRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LSOSecureFalseRule.java b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LSOSecureFalseRule.java
new file mode 100644
index 0000000..755a33e
--- /dev/null
+++ b/FlexPMD/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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LocalConnectionStarRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/security/LocalConnectionStarRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooLongFunctionRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooLongFunctionRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooLongSwitchCaseRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooLongSwitchCaseRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFieldInVORule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFieldInVORule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFieldsRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFieldsRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFunctionRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyFunctionRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyParametersRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyParametersRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyPublicRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/sizing/TooManyPublicRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/BadFormatLoggerRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/BadFormatLoggerRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/ConstructorNonEmptyReturnTypeRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/ConstructorNonEmptyReturnTypeRule.java b/FlexPMD/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-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/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/CopyrightMissingRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/CopyrightMissingRule.java b/FlexPMD/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-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 ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/ImportFromSamePackageRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/ImportFromSamePackageRule.java b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/ImportFromSamePackageRule.java
new file mode 100644
index 0000000..ef71b6d
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/ImportFromSamePackageRule.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.style;
+
+import org.apache.commons.lang.StringUtils;
+
+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 ImportFromSamePackageRule extends AbstractAstFlexRule
+{
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#findViolations(com.adobe
+ * .ac.pmd.nodes.IPackage)
+ */
+ @Override
+ protected final void findViolations( final IPackage packageNode )
+ {
+ final String packageName = packageNode.getName();
+
+ for ( final IParserNode importNode : packageNode.getImports() )
+ {
+ if ( StringUtils.substringBeforeLast( importNode.toString(),
+ "." ).equals( packageName ) )
+ {
+ addViolation( importNode );
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.LOW;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/OverLongLineRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/OverLongLineRule.java b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/OverLongLineRule.java
new file mode 100644
index 0000000..1e80663
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/OverLongLineRule.java
@@ -0,0 +1,114 @@
+/*
+ * 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.IFlexFile;
+import com.adobe.ac.pmd.rules.core.ViolationPosition;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.AbstractMaximizedFlexRule;
+
+/**
+ * @author xagnetti
+ */
+public class OverLongLineRule extends AbstractMaximizedFlexRule
+{
+ private static final int DEFAULT_THRESHOLD = 120;
+ private int currentLineLength;
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractFlexRule#findViolationsInCurrentFile()
+ */
+ @Override
+ public final List< IFlexViolation > findViolationsInCurrentFile()
+ {
+ final List< IFlexViolation > violations = new ArrayList< IFlexViolation >();
+
+ if ( isConcernedByTheCurrentFile() )
+ {
+ final IFlexFile currentFile = getCurrentFile();
+
+ for ( int i = 1; i <= currentFile.getLinesNb(); i++ )
+ {
+ final String line = currentFile.getLineAt( i );
+
+ if ( !line.trim().startsWith( "import" )
+ && line.length() > getThreshold() )
+ {
+ currentLineLength = line.length();
+ final ViolationPosition position = ViolationPosition.create( i,
+ i,
+ 0,
+ currentLineLength );
+
+ addViolation( violations,
+ position );
+ }
+ }
+ }
+ return violations;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+ * getActualValueForTheCurrentViolation()
+ */
+ @Override
+ public final int getActualValueForTheCurrentViolation()
+ {
+ return currentLineLength;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getDefaultThreshold
+ * ()
+ */
+ @Override
+ public final int getDefaultThreshold()
+ {
+ return DEFAULT_THRESHOLD;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.LOW;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractFlexRule#isConcernedByTheCurrentFile()
+ */
+ @Override
+ protected boolean isConcernedByTheCurrentFile()
+ {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/TabUsedAsIndentorRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/TabUsedAsIndentorRule.java b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/TabUsedAsIndentorRule.java
new file mode 100644
index 0000000..37f44a3
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/style/TabUsedAsIndentorRule.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.style;
+
+import com.adobe.ac.pmd.rules.core.AbstractRegexpBasedRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+public class TabUsedAsIndentorRule extends AbstractRegexpBasedRule
+{
+
+ @Override
+ protected ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+
+ @Override
+ protected String getRegexp()
+ {
+ return "^ *\t.*";
+ }
+
+ @Override
+ protected boolean isConcernedByTheCurrentFile()
+ {
+ return !getCurrentFile().isMxml();
+ }
+
+ @Override
+ protected boolean isViolationDetectedOnThisMatchingLine( final String line )
+ {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/IdenticalSwitchCasesRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/IdenticalSwitchCasesRule.java b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/IdenticalSwitchCasesRule.java
new file mode 100644
index 0000000..fad7a45
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/IdenticalSwitchCasesRule.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.switchrules;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+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 IdenticalSwitchCasesRule extends AbstractAstFlexRule
+{
+ /*
+ * (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#visitSwitch(com.adobe.
+ * ac.pmd.parser.IParserNode)
+ */
+ @Override
+ protected final void visitSwitch( final IParserNode ast )
+ {
+ super.visitSwitch( ast );
+
+ if ( ast.numChildren() > 0 )
+ {
+ final Map< String, IParserNode > cases = new LinkedHashMap< String, IParserNode >();
+
+ for ( final IParserNode caseStatement : ast.getChild( 1 ).getChildren() )
+ {
+ final String label = caseStatement.getChild( 0 ).toString();
+
+ if ( cases.containsKey( label ) )
+ {
+ addViolation( caseStatement );
+ break;
+ }
+ else
+ {
+ cases.put( label,
+ caseStatement );
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/NestedSwitchRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/NestedSwitchRule.java b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/NestedSwitchRule.java
new file mode 100644
index 0000000..38dd7e5
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/NestedSwitchRule.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.switchrules;
+
+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 NestedSwitchRule extends AbstractAstFlexRule
+{
+ private int switchLevel = 0;
+
+ /*
+ * (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#visitSwitch(com.adobe.
+ * ac.pmd.parser.IParserNode)
+ */
+ @Override
+ protected final void visitSwitch( final IParserNode ast )
+ {
+ switchLevel++;
+ if ( switchLevel > 1 )
+ {
+ addViolation( ast );
+ }
+ super.visitSwitch( ast );
+
+ switchLevel--;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/NonBreakableSwitchCaseRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/NonBreakableSwitchCaseRule.java b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/NonBreakableSwitchCaseRule.java
new file mode 100644
index 0000000..3697903
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/NonBreakableSwitchCaseRule.java
@@ -0,0 +1,41 @@
+/*
+ * 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.switchrules;
+
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+public class NonBreakableSwitchCaseRule extends AbstractAstFlexRule
+{
+ @Override
+ protected ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.HIGH;
+ }
+
+ @Override
+ protected void visitSwitchCase( final IParserNode switchCaseNode )
+ {
+ if ( switchCaseNode.getChildren() != null
+ && switchCaseNode.getChildren().size() > 0
+ && switchCaseNode.getLastChild().getStringValue().compareTo( "break" ) != 0 )
+ {
+ addViolation( switchCaseNode );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/SwitchStatementsShouldHaveDefaultRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/SwitchStatementsShouldHaveDefaultRule.java b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/SwitchStatementsShouldHaveDefaultRule.java
new file mode 100644
index 0000000..163333e
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/SwitchStatementsShouldHaveDefaultRule.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.adobe.ac.pmd.rules.switchrules;
+
+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 SwitchStatementsShouldHaveDefaultRule extends AbstractAstFlexRule
+{
+ private boolean defaultStatementFound = false;
+
+ /*
+ * (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.AbstractAstFlexRule#visitSwitch(com.adobe.
+ * ac.pmd.parser.IParserNode)
+ */
+ @Override
+ protected final void visitSwitch( final IParserNode ast )
+ {
+ super.visitSwitch( ast );
+
+ if ( !defaultStatementFound )
+ {
+ ast.getChild( 1 );
+
+ addViolation( ast );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitSwitchDefaultCase
+ * (com.adobe.ac.pmd.parser.IParserNode)
+ */
+ @Override
+ protected final void visitSwitchDefaultCase( final IParserNode child )
+ {
+ super.visitSwitchDefaultCase( child );
+
+ if ( child.numChildren() != 0 )
+ {
+ defaultStatementFound = true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/TooFewBrancheInSwitchStatementRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/TooFewBrancheInSwitchStatementRule.java b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/TooFewBrancheInSwitchStatementRule.java
new file mode 100644
index 0000000..2f4aae9
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/switchrules/TooFewBrancheInSwitchStatementRule.java
@@ -0,0 +1,144 @@
+/*
+ * 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.switchrules;
+
+import java.util.Map;
+
+import net.sourceforge.pmd.PropertyDescriptor;
+
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+import com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule;
+
+/**
+ * @author xagnetti
+ */
+public class TooFewBrancheInSwitchStatementRule extends AbstractAstFlexRule implements IThresholdedRule
+{
+ public static final int DEFAULT_THRESHOLD = 3;
+ private int switchCases;
+
+ /*
+ * (non-Javadoc)
+ * @seecom.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#
+ * getActualValueForTheCurrentViolation()
+ */
+ public final int getActualValueForTheCurrentViolation()
+ {
+ return switchCases;
+ }
+
+ /*
+ * (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.thresholded.IThresholdedRule#getThreshold()
+ */
+ public final int getThreshold()
+ {
+ return getIntProperty( propertyDescriptorFor( getThresholdName() ) );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.thresholded.IThresholdedRule#getThresholdName
+ * ()
+ */
+ public final String getThresholdName()
+ {
+ return MINIMUM;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.adobe.ac.pmd.rules.core.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.LOW;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see net.sourceforge.pmd.CommonAbstractRule#propertiesByName()
+ */
+ @Override
+ protected final Map< String, PropertyDescriptor > propertiesByName()
+ {
+ return getThresholdedRuleProperties( this );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitSwitch(com.adobe.
+ * ac.pmd.parser.IParserNode)
+ */
+ @Override
+ protected final void visitSwitch( final IParserNode ast )
+ {
+ switchCases = 0;
+
+ super.visitSwitch( ast );
+
+ if ( switchCases < getThreshold() )
+ {
+ addViolation( ast );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitSwitchCase(com.adobe
+ * .ac.pmd.parser.IParserNode)
+ */
+ @Override
+ protected final void visitSwitchCase( final IParserNode child )
+ {
+ super.visitSwitchCase( child );
+
+ switchCases++;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitSwitchDefaultCase
+ * (com.adobe.ac.pmd.parser.IParserNode)
+ */
+ @Override
+ protected void visitSwitchDefaultCase( final IParserNode defaultCaseNode )
+ {
+ super.visitSwitchDefaultCase( defaultCaseNode );
+
+ switchCases++;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/unused/AbstractUnusedVariableRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/unused/AbstractUnusedVariableRule.java b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/unused/AbstractUnusedVariableRule.java
new file mode 100644
index 0000000..63640b2
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/unused/AbstractUnusedVariableRule.java
@@ -0,0 +1,130 @@
+/*
+ * 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.unused;
+
+import java.util.Map;
+
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.parser.NodeKind;
+import com.adobe.ac.pmd.rules.core.AbstractAstFlexRule;
+
+/**
+ * @author xagnetti
+ */
+abstract class AbstractUnusedVariableRule extends AbstractAstFlexRule
+{
+ private Map< String, IParserNode > variablesUnused;
+
+ /**
+ * @param variableName
+ * @param ast
+ */
+ protected final void addVariable( final String variableName,
+ final IParserNode ast )
+ {
+ variablesUnused.put( variableName,
+ ast );
+ }
+
+ /**
+ * @return
+ */
+ protected Map< String, IParserNode > getVariablesUnused()
+ {
+ return variablesUnused;
+ }
+
+ /**
+ * @param variablesUnusedToBeSet
+ */
+ protected void setVariablesUnused( final Map< String, IParserNode > variablesUnusedToBeSet )
+ {
+ variablesUnused = variablesUnusedToBeSet;
+ }
+
+ /**
+ * @param ast
+ */
+ protected final void tryToAddVariableNodeInChildren( final IParserNode ast )
+ {
+ if ( ast != null
+ && !tryToAddVariableNode( ast ) && ast.is( NodeKind.VAR_LIST ) )
+ {
+ for ( final IParserNode child : ast.getChildren() )
+ {
+ tryToAddVariableNode( child );
+ }
+ }
+ }
+
+ /**
+ * @param ast
+ */
+ protected final void tryToMarkVariableAsUsed( final IParserNode ast )
+ {
+ if ( variablesUnused != null
+ && ast != null )
+ {
+ markVariableAsUsed( ast );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitStatement(com.adobe
+ * .ac.pmd.parser.IParserNode)
+ */
+ @Override
+ protected void visitStatement( final IParserNode ast )
+ {
+ super.visitStatement( ast );
+
+ tryToMarkVariableAsUsed( ast );
+ }
+
+ private void markVariableAsUsed( final IParserNode ast )
+ {
+ if ( ast.numChildren() == 0 )
+ {
+ if ( variablesUnused.containsKey( ast.getStringValue() ) )
+ {
+ variablesUnused.remove( ast.getStringValue() );
+ }
+ }
+ else
+ {
+ for ( final IParserNode child : ast.getChildren() )
+ {
+ markVariableAsUsed( child );
+ }
+ }
+ }
+
+ private boolean tryToAddVariableNode( final IParserNode ast )
+ {
+ boolean result = false;
+
+ if ( ast.is( NodeKind.NAME_TYPE_INIT ) )
+ {
+ addVariable( ast.getChild( 0 ).getStringValue(),
+ ast );
+ result = true;
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/unused/EmptyPrivateMethodRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/unused/EmptyPrivateMethodRule.java b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/unused/EmptyPrivateMethodRule.java
new file mode 100644
index 0000000..f9805c1
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/unused/EmptyPrivateMethodRule.java
@@ -0,0 +1,41 @@
+/*
+ * 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.unused;
+
+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;
+
+public class EmptyPrivateMethodRule extends AbstractAstFlexRule
+{
+ @Override
+ protected final void findViolations( final IFunction function )
+ {
+ if ( function.is( Modifier.PRIVATE )
+ && function.getBody().numChildren() == 0 )
+ {
+ addViolation( function );
+ }
+ }
+
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.NORMAL;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b0fc5f17/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/unused/UnusedFieldRule.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/unused/UnusedFieldRule.java b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/unused/UnusedFieldRule.java
new file mode 100644
index 0000000..c6bc6fd
--- /dev/null
+++ b/FlexPMD/flex-pmd-ruleset/src/main/java/com/adobe/ac/pmd/rules/unused/UnusedFieldRule.java
@@ -0,0 +1,128 @@
+/*
+ * 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.unused;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import com.adobe.ac.pmd.parser.IParserNode;
+import com.adobe.ac.pmd.parser.KeyWords;
+import com.adobe.ac.pmd.rules.core.ViolationPriority;
+
+/**
+ * @author xagnetti
+ */
+public class UnusedFieldRule extends AbstractUnusedVariableRule
+{
+ /*
+ * (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.AbstractFlexRule#getDefaultPriority()
+ */
+ @Override
+ protected final ViolationPriority getDefaultPriority()
+ {
+ return ViolationPriority.HIGH;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitClass(com.adobe.ac
+ * .pmd.parser.IParserNode)
+ */
+ @Override
+ protected final void visitClass( final IParserNode classNode )
+ {
+ setVariablesUnused( new LinkedHashMap< String, IParserNode >() );
+
+ super.visitClass( classNode );
+
+ for ( final String variableName : getVariablesUnused().keySet() )
+ {
+ final IParserNode variable = getVariablesUnused().get( variableName );
+
+ addViolation( variable,
+ variable,
+ variableName );
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitVariableInitialization
+ * (com.adobe.ac.pmd.parser.IParserNode)
+ */
+ @Override
+ protected final void visitVariableInitialization( final IParserNode node )
+ {
+ super.visitVariableInitialization( node );
+
+ tryToMarkVariableAsUsed( node );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule#visitVarOrConstList(com
+ * .adobe.ac.pmd.parser.IParserNode,
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule.VariableOrConstant,
+ * com.adobe.ac.pmd.rules.core.AbstractAstFlexRule.VariableScope)
+ */
+ @Override
+ protected final void visitVarOrConstList( final IParserNode ast,
+ final VariableOrConstant varOrConst,
+ final VariableScope scope )
+ {
+ if ( scope.equals( VariableScope.IN_CLASS ) )
+ {
+ final List< IParserNode > modifiers = ast.getChild( 0 ).getChildren();
+ boolean isPrivate = false;
+
+ if ( !modifiers.isEmpty() )
+ {
+ for ( final IParserNode modifierNode : modifiers )
+ {
+ if ( modifierNode.getStringValue().equals( KeyWords.PRIVATE.toString() ) )
+ {
+ isPrivate = true;
+ break;
+ }
+ }
+ }
+ if ( isPrivate )
+ {
+ tryToAddVariableNodeInChildren( ast );
+ }
+ }
+ super.visitVarOrConstList( ast,
+ varOrConst,
+ scope );
+ }
+}