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:44:12 UTC
[41/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-core/src/test/resources/pmd.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/test/resources/pmd.xml b/FlexPMD/flex-pmd-core/src/test/resources/pmd.xml
deleted file mode 100644
index 6b9ac1d..0000000
--- a/FlexPMD/flex-pmd-core/src/test/resources/pmd.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<pmd version="4.2.1" timestamp="Fri Aug 08 08:31:02 PDT 2008">
- <file name="C:/Documents and Settings/Administrator/.hudson/jobs/FlexPmd/workspace/flex-pmd-core/target/test-classes/test/AbstractRowData.as">
- <violation beginline="41" endline="121" begincolumn="7" endcolumn="7" rule="TooManyFunction" ruleset="Basic As3 Rules" package="" class="AbstractRowData.as" externalInfoUrl="" priority="1">A constructor should not have a return type</violation>
- <violation beginline="41" endline="118" begincolumn="7" endcolumn="7" rule="TooManyFunction" ruleset="Basic As3 Rules" package="" class="AbstractRowData.as" externalInfoUrl="" priority="1">A constructor should not have a return type</violation>
- <violation beginline="29" endline="29" begincolumn="9" endcolumn="29" rule="PackageCase" ruleset="Basic Common Flex Rules" package="" class="AbstractRowData.as" externalInfoUrl="" priority="3">A package name should be lower case</violation>
- <violation beginline="44" endline="44" begincolumn="0" endcolumn="44" rule="DeadCode" ruleset="Basic Common Flex Rules" package="" class="AbstractRowData.as" externalInfoUrl="" priority="3">There are some dead code here.</violation>
- <violation beginline="49" endline="62" begincolumn="0" endcolumn="9" rule="DeadCode" ruleset="Basic Common Flex Rules" package="" class="AbstractRowData.as" externalInfoUrl="" priority="3">There are some dead code here.</violation>
- <violation beginline="98" endline="100" begincolumn="12" endcolumn="10" rule="EmptyIfStmt" ruleset="Basic Common Flex Rules" package="" class="AbstractRowData.as" externalInfoUrl="" priority="3">No statements in this if statement</violation>
- <violation beginline="101" endline="101" begincolumn="0" endcolumn="36" rule="DispatchHardCodedEventName" ruleset="Basic Common Flex Rules" package="" class="AbstractRowData.as" externalInfoUrl="" priority="3">DispatchEvent function must dispatch constant strings</violation>
- <violation beginline="102" endline="102" begincolumn="0" endcolumn="38" rule="DispatchHardCodedEventName" ruleset="Basic Common Flex Rules" package="" class="AbstractRowData.as" externalInfoUrl="" priority="3">DispatchEvent function must dispatch constant strings</violation>
- <violation beginline="97" endline="97" begincolumn="0" endcolumn="57" rule="TooShortVariable" ruleset="Basic Common Flex Rules" package="" class="AbstractRowData.as" externalInfoUrl="" priority="5">This variable name is too short</violation>
- </file>
- <file name="C:/Documents and Settings/Administrator/.hudson/jobs/FlexPmd/workspace/flex-pmd-core/target/test-classes/test/com/adobe/ac/ncss/BigModel.as">
- <violation beginline="5" endline="28" begincolumn="7" endcolumn="7" rule="TooManyFunction" ruleset="Basic As3 Rules" package="com.adobe.ac.ncss" class="BigModel.as" externalInfoUrl="" priority="1">A constructor should not have a return type</violation>
- <violation beginline="8" endline="8" begincolumn="0" endcolumn="22" rule="TooShortVariable" ruleset="Basic Common Flex Rules" package="com.adobe.ac.ncss" class="BigModel.as" externalInfoUrl="" priority="5">This variable name is too short</violation>
- </file>
- <file name="C:/Documents and Settings/Administrator/.hudson/jobs/FlexPmd/workspace/flex-pmd-core/target/test-classes/test/com/adobe/ac/ncss/event/DynamicCustomEvent.as">
- <violation beginline="3" endline="3" begincolumn="0" endcolumn="43" rule="DynamicClass" ruleset="Basic As3 Rules" package="com.adobe.ac.ncss.event" class="DynamicCustomEvent.as" externalInfoUrl="" priority="1">A class must not be dynamic</violation>
- <violation beginline="5" endline="5" begincolumn="0" endcolumn="31" rule="PublicVariableInCustomEvent" ruleset="Basic As3 Rules" package="com.adobe.ac.ncss.event" class="DynamicCustomEvent.as" externalInfoUrl="" priority="3">No public variables should be inside a custom event</violation>
- </file>
- <file name="C:/Documents and Settings/Administrator/.hudson/jobs/FlexPmd/workspace/flex-pmd-core/target/test-classes/test/com/adobe/ac/ncss/event/FirstCustomEvent.as">
- <violation beginline="0" endline="0" begincolumn="0" endcolumn="0" rule="EventMissingCloneFunction" ruleset="Basic As3 Rules" package="com.adobe.ac.ncss.event" class="FirstCustomEvent.as" externalInfoUrl="" priority="1">The clone event must be overiden in a custom event</violation>
- <violation beginline="5" endline="5" begincolumn="0" endcolumn="31" rule="PublicVariableInCustomEvent" ruleset="Basic As3 Rules" package="com.adobe.ac.ncss.event" class="FirstCustomEvent.as" externalInfoUrl="" priority="3">No public variables should be inside a custom event</violation>
- </file>
- <file name="C:/Documents and Settings/Administrator/.hudson/jobs/FlexPmd/workspace/flex-pmd-core/target/test-classes/test/com/adobe/ac/ncss/mxml/IterationsList.mxml">
- <violation beginline="18" endline="18" begincolumn="0" endcolumn="72" rule="MoreThanTwoEntryPointsInMxml" ruleset="Basic MXML Rules" package="com.adobe.ac.ncss.mxml" class="IterationsList.mxml" externalInfoUrl="" priority="3">There are more than 2 public variables in this MXML component</violation>
- <violation beginline="18" endline="18" begincolumn="0" endcolumn="72" rule="MoreThanOneEntryPointInMxml" ruleset="Basic MXML Rules" package="com.adobe.ac.ncss.mxml" class="IterationsList.mxml" externalInfoUrl="" priority="5">There are more than 1 public variable in this MXML component</violation>
- <violation beginline="20" endline="20" begincolumn="0" endcolumn="86" rule="TooShortVariable" ruleset="Basic Common Flex Rules" package="com.adobe.ac.ncss.mxml" class="IterationsList.mxml" externalInfoUrl="" priority="5">This variable name is too short</violation>
- <violation beginline="31" endline="31" begincolumn="0" endcolumn="51" rule="TooShortVariable" ruleset="Basic Common Flex Rules" package="com.adobe.ac.ncss.mxml" class="IterationsList.mxml" externalInfoUrl="" priority="5">This variable name is too short</violation>
- </file>
- <file name="C:/Documents and Settings/Administrator/.hudson/jobs/FlexPmd/workspace/flex-pmd-core/target/test-classes/test/com/adobe/ac/ncss/SearchBarEvent.as">
- <violation beginline="0" endline="0" begincolumn="0" endcolumn="0" rule="EventMissingCloneFunction" ruleset="Basic As3 Rules" package="com.adobe.ac.ncss" class="SearchBarEvent.as" externalInfoUrl="" priority="1">The clone event must be overiden in a custom event</violation>
- </file>
- <file name="C:/Documents and Settings/Administrator/.hudson/jobs/FlexPmd/workspace/flex-pmd-core/target/test-classes/test/com/adobe/ac/ncss/event/SecondCustomEvent.as">
- <violation beginline="0" endline="0" begincolumn="0" endcolumn="0" rule="EventMissingCloneFunction" ruleset="Basic As3 Rules" package="com.adobe.ac.ncss.event" class="SecondCustomEvent.as" externalInfoUrl="" priority="1">The clone event must be overiden in a custom event</violation>
- </file>
- <file name="C:/Documents and Settings/Administrator/.hudson/jobs/FlexPmd/workspace/flex-pmd-core/target/test-classes/test/com/adobe/ac/ncss/TestResult.as">
- <violation beginline="61" endline="64" begincolumn="0" endcolumn="11" rule="DeadCode" ruleset="Basic Common Flex Rules" package="com.adobe.ac.ncss" class="TestResult.as" externalInfoUrl="" priority="3">There are some dead code here.</violation>
- </file>
- <file name="C:/Documents and Settings/Administrator/.hudson/jobs/FlexPmd/workspace/flex-pmd-core/target/test-classes/test/com/adobe/ac/ncss/VoidConstructor.as">
- <violation beginline="6" endline="7" begincolumn="7" endcolumn="10" rule="ConstructorNonEmptyReturnType" ruleset="Basic As3 Rules" package="com.adobe.ac.ncss" class="VoidConstructor.as" externalInfoUrl="" priority="3">A constructor should not have a return type</violation>
- <violation beginline="8" endline="8" begincolumn="0" endcolumn="22" rule="TooShortVariable" ruleset="Basic Common Flex Rules" package="com.adobe.ac.ncss" class="VoidConstructor.as" externalInfoUrl="" priority="5">This variable name is too short</violation>
- </file>
-</pmd>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/test/resources/pmd.xsd
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/test/resources/pmd.xsd b/FlexPMD/flex-pmd-core/src/test/resources/pmd.xsd
deleted file mode 100644
index 92c59a3..0000000
--- a/FlexPMD/flex-pmd-core/src/test/resources/pmd.xsd
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<!--W3C Schema generated by XMLSpy v2007 rel. 3 sp1 (http://www.altova.com)-->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:element name="violation">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="ruleset" use="required" type="xs:string"/>
- <xs:attribute name="rule" use="required" type="xs:string"/>
- <xs:attribute name="priority" use="required" type="xs:int"/>
- <xs:attribute name="package" use="required" type="xs:string"/>
- <xs:attribute name="externalInfoUrl" use="required" type="xs:string"/>
- <xs:attribute name="endline" use="required" type="xs:int"/>
- <xs:attribute name="endcolumn" use="required" type="xs:int"/>
- <xs:attribute name="class" use="required" type="xs:string"/>
- <xs:attribute name="beginline" use="required" type="xs:int"/>
- <xs:attribute name="begincolumn" use="required" type="xs:int"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="pmd">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="file" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="version" use="required" type="xs:string"/>
- <xs:attribute name="timestamp" use="required" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- <xs:element name="file">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="violation" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="name" use="required" type="xs:string"/>
- </xs:complexType>
- </xs:element>
-</xs:schema>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd-ant-task/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-ant-task/pom.xml b/FlexPMD/flex-pmd-cpd-ant-task/pom.xml
deleted file mode 100644
index 987d68e..0000000
--- a/FlexPMD/flex-pmd-cpd-ant-task/pom.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<!--
-
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.adobe.ac</groupId>
- <artifactId>flex-pmd-cpd-ant-task</artifactId>
- <name>Adobe Flex CPD Ant task</name>
- <packaging>jar</packaging>
-
- <parent>
- <groupId>com.adobe.ac</groupId>
- <artifactId>flex-pmd-java-parent</artifactId>
- <version>1.3-SNAPSHOT</version>
- <relativePath>../flex-pmd-java-parent/pom.xml</relativePath>
- </parent>
-
-
- <dependencies>
-
- <dependency>
- <groupId>pmd</groupId>
- <artifactId>pmd</artifactId>
- <version>${pmd.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <version>${project.parent.version}</version>
- <artifactId>flex-pmd-cpd</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant</artifactId>
- <version>${ant.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <version>${project.version}</version>
- <artifactId>flex-pmd-files</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>as3-plugin-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>as3-parser</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>as3-parser-api</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>flex-pmd-test-resources</artifactId>
- <version>${project.parent.version}</version>
- <classifier>resources</classifier>
- <type>zip</type>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <testResources>
- <testResource>
- <directory>${project.build.directory}/test/generated-resources</directory>
- </testResource>
- </testResources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>unpack-test-resources</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>unpack-dependencies</goal>
- </goals>
- <configuration>
- <includeGroupIds>${project.groupId}</includeGroupIds>
- <includes>**/*.as,**/*.mxml</includes>
- <outputDirectory>${project.build.directory}/test/generated-resources</outputDirectory>
- <excludeTransitive>true</excludeTransitive>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>${maven-antrun-plugin.version}</version>
- <executions>
- <execution>
- <id>package-ant-task</id>
- <phase>install</phase>
- <configuration>
- <tasks>
- <echo message="Building ant-task" />
- <mkdir dir="${project.build.directory}/release" />
- <echo message="" />
- <echo message="Copying Flex PMD dependencies..." />
- <copy file="${project.build.directory}/${project.build.finalName}.jar" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.adobe.ac.flex-pmd-cpd.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.pmd.pmd.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <echo message="Copying Ant dependencies..." />
- <copy file="${maven.dependency.com.adobe.ac.flex-pmd-files.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.adobe.ac.as3-parser.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.adobe.ac.as3-parser-api.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.org.apache.ant.ant.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.adobe.ac.as3-plugin-utils.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <echo message="Extracting license..." />
- <copy file="../flex-pmd-parent/src/etc/header.txt" tofile="${project.build.directory}/release/LICENSE.txt" overwrite="true" />
- <echo message="Compressing zip..." />
- <zip destfile="${project.build.directory}/${project.build.finalName}.zip" basedir="${project.build.directory}/release" excludes="*.zip" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd-ant-task/src/main/java/com/adobe/ac/cpd/ant/FlexCpdAntTask.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-ant-task/src/main/java/com/adobe/ac/cpd/ant/FlexCpdAntTask.java b/FlexPMD/flex-pmd-cpd-ant-task/src/main/java/com/adobe/ac/cpd/ant/FlexCpdAntTask.java
deleted file mode 100644
index 1f1a438..0000000
--- a/FlexPMD/flex-pmd-cpd-ant-task/src/main/java/com/adobe/ac/cpd/ant/FlexCpdAntTask.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * 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.cpd.ant;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sourceforge.pmd.cpd.CPD;
-import net.sourceforge.pmd.cpd.FileReporter;
-import net.sourceforge.pmd.cpd.Renderer;
-import net.sourceforge.pmd.cpd.ReportException;
-import net.sourceforge.pmd.cpd.XMLRenderer;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.FileSet;
-
-import com.adobe.ac.cpd.FlexLanguage;
-import com.adobe.ac.cpd.FlexTokenizer;
-import com.adobe.ac.pmd.LoggerUtils;
-
-public class FlexCpdAntTask extends Task
-{
- private String encoding = System.getProperty( "file.encoding" );
- private final List< FileSet > filesets = new ArrayList< FileSet >();
- private int minimumTokenCount = FlexTokenizer.DEFAULT_MINIMUM_TOKENS;
- private File outputFile;
-
- public void addFileset( final FileSet set )
- {
- filesets.add( set );
- }
-
- @Override
- public void execute()
- {
- try
- {
- validateFields();
- new LoggerUtils().loadConfiguration();
-
- log( "Starting run, minimumTokenCount is "
- + minimumTokenCount,
- Project.MSG_INFO );
-
- log( "Tokenizing files",
- Project.MSG_INFO );
- final CPD cpd = new CPD( minimumTokenCount, new FlexLanguage() );
- cpd.setEncoding( encoding );
- tokenizeFiles( cpd );
-
- log( "Starting to analyze code",
- Project.MSG_INFO );
- final long timeTaken = analyzeCode( cpd );
- log( "Done analyzing code; that took "
- + timeTaken + " milliseconds" );
-
- log( "Generating report",
- Project.MSG_INFO );
- report( cpd );
- }
- catch ( final IOException ioe )
- {
- log( ioe.toString(),
- Project.MSG_ERR );
- throw new BuildException( "IOException during task execution", ioe );
- }
- catch ( final ReportException re )
- {
- log( re.toString(),
- Project.MSG_ERR );
- throw new BuildException( "ReportException during task execution", re );
- }
- }
-
- public void setEncoding( final String encodingValue )
- {
- encoding = encodingValue;
- }
-
- public void setMinimumTokenCount( final int minimumTokenCountToBeSet )
- {
- minimumTokenCount = minimumTokenCountToBeSet;
- }
-
- public void setOutputFile( final File outputFileToBeSet )
- {
- outputFile = outputFileToBeSet;
- }
-
- private long analyzeCode( final CPD cpd )
- {
- final long start = System.currentTimeMillis();
- cpd.go();
- final long stop = System.currentTimeMillis();
- return stop
- - start;
- }
-
- private File getFile( final DirectoryScanner directoryScanner,
- final String includedFile )
- {
- final File file = new File( directoryScanner.getBasedir()
- + System.getProperty( "file.separator" ) + includedFile );
- log( "Tokenizing "
- + file.getAbsolutePath(),
- Project.MSG_VERBOSE );
- return file;
- }
-
- private void report( final CPD cpd ) throws ReportException
- {
- final Renderer renderer = new XMLRenderer( encoding );
- FileReporter reporter;
- if ( outputFile == null )
- {
- reporter = new FileReporter( encoding );
- }
- else if ( outputFile.isAbsolute() )
- {
- reporter = new FileReporter( outputFile, encoding );
- }
- else
- {
- reporter = new FileReporter( new File( getProject().getBaseDir(), outputFile.toString() ), encoding );
- }
- reporter.report( renderer.render( cpd.getMatches() ) );
- }
-
- private void tokenizeFiles( final CPD cpd ) throws IOException
- {
- for ( final FileSet fileSet : filesets )
- {
- final DirectoryScanner directoryScanner = fileSet.getDirectoryScanner( getProject() );
- final String[] includedFiles = directoryScanner.getIncludedFiles();
- for ( final String includedFile : includedFiles )
- {
- cpd.add( getFile( directoryScanner,
- includedFile ) );
- }
- }
- }
-
- private void validateFields()
- {
- if ( minimumTokenCount == 0 )
- {
- throw new BuildException( "minimumTokenCount is required and must be greater than zero" );
- }
- else if ( filesets.isEmpty() )
- {
- throw new BuildException( "Must include at least one FileSet" );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd-ant-task/src/test/java/com/adobe/ac/cpd/ant/FlexCpdAntTaskTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-ant-task/src/test/java/com/adobe/ac/cpd/ant/FlexCpdAntTaskTest.java b/FlexPMD/flex-pmd-cpd-ant-task/src/test/java/com/adobe/ac/cpd/ant/FlexCpdAntTaskTest.java
deleted file mode 100644
index c4aaf38..0000000
--- a/FlexPMD/flex-pmd-cpd-ant-task/src/test/java/com/adobe/ac/cpd/ant/FlexCpdAntTaskTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.cpd.ant;
-
-import java.io.File;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.FileSet;
-import org.junit.Test;
-
-import com.adobe.ac.pmd.FlexPmdTestBase;
-
-public class FlexCpdAntTaskTest extends FlexPmdTestBase
-{
- @Test
- public void testExecute()
- {
- final FlexCpdAntTask task = new FlexCpdAntTask();
- final FileSet set = new FileSet();
- final Project project = new Project();
-
- set.setDir( getTestDirectory() );
- task.setProject( project );
- task.addFileset( set );
- task.execute();
- }
-
- @Test
- public void testParameter()
- {
- final FlexCpdAntTask task = new FlexCpdAntTask();
- final String encodingValue = "encoding";
- final String desc = "desc";
- final int minimumTokenCountToBeSet = 10;
- final File outputFile = null;
-
- task.setDescription( desc );
- task.setEncoding( encodingValue );
- task.setOutputFile( outputFile );
- task.setMinimumTokenCount( minimumTokenCountToBeSet );
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd-command-line/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-command-line/pom.xml b/FlexPMD/flex-pmd-cpd-command-line/pom.xml
deleted file mode 100644
index c7d4729..0000000
--- a/FlexPMD/flex-pmd-cpd-command-line/pom.xml
+++ /dev/null
@@ -1,187 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.adobe.ac</groupId>
- <artifactId>flex-pmd-cpd-command-line</artifactId>
- <name>Adobe Flex CPD Command line</name>
- <description />
- <packaging>jar</packaging>
-
- <parent>
- <groupId>com.adobe.ac</groupId>
- <artifactId>flex-pmd-java-parent</artifactId>
- <version>1.3-SNAPSHOT</version>
- <relativePath>../flex-pmd-java-parent/pom.xml</relativePath>
- </parent>
-
-
- <properties>
- <maven.jar.plugin.version>2.2</maven.jar.plugin.version>
- </properties>
-
- <dependencies>
-
-
- <dependency>
- <groupId>com.martiansoftware</groupId>
- <artifactId>jsap</artifactId>
- <version>${jsap.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <version>${project.version}</version>
- <artifactId>flex-pmd-command-line-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>pmd</groupId>
- <artifactId>pmd</artifactId>
- <version>${pmd.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <version>${project.parent.version}</version>
- <artifactId>flex-pmd-cpd</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <version>${project.version}</version>
- <artifactId>flex-pmd-files</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>as3-plugin-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>as3-parser</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>as3-parser-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>${commons-lang.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>flex-pmd-test-resources</artifactId>
- <version>${project.parent.version}</version>
- <classifier>resources</classifier>
- <type>zip</type>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-
- <build>
-
- <testResources>
- <testResource>
- <directory>${project.build.directory}/test/generated-resources</directory>
- </testResource>
- </testResources>
-
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>unpack-test-resources</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>unpack-dependencies</goal>
- </goals>
- <configuration>
- <includeGroupIds>${project.groupId}</includeGroupIds>
- <includes>**/*.as,**/*.mxml</includes>
- <outputDirectory>${project.build.directory}/test/generated-resources</outputDirectory>
- <excludeTransitive>true</excludeTransitive>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>${maven.jar.plugin.version}</version>
- <configuration>
- <archive>
- <manifest>
- <mainClass>com.adobe.ac.cpd.commandline.FlexCPD</mainClass>
- <packageName>com.adobe.ac.cpd.commandline</packageName>
- <addClasspath>true</addClasspath>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>${maven-antrun-plugin.version}</version>
- <executions>
- <execution>
- <id>package-ant-task</id>
- <phase>install</phase>
- <configuration>
- <tasks>
- <echo message="Building ant-task" />
- <mkdir dir="${project.build.directory}/release" />
- <echo message="" />
- <echo message="Copying Flex CPD dependencies..." />
- <copy file="${project.build.directory}/${project.build.finalName}.jar" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.adobe.ac.flex-pmd-command-line-api.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.adobe.ac.as3-parser-api.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.adobe.ac.as3-parser.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.adobe.ac.flex-pmd-cpd.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.adobe.ac.flex-pmd-files.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.adobe.ac.as3-plugin-utils.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <echo message="Copying Command line dependencies..." />
- <copy file="${maven.dependency.pmd.pmd.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.commons-lang.commons-lang.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.martiansoftware.jsap.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <echo message="Extracting license..." />
- <copy file="../flex-pmd-parent/src/etc/header.txt" tofile="${project.build.directory}/release/LICENSE.txt" overwrite="true" />
- <echo message="Compressing zip..." />
- <zip destfile="${project.build.directory}/${project.build.finalName}.zip" basedir="${project.build.directory}/release" excludes="*.zip" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/CpdCommandLineOptions.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/CpdCommandLineOptions.java b/FlexPMD/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/CpdCommandLineOptions.java
deleted file mode 100644
index a359eb4..0000000
--- a/FlexPMD/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/CpdCommandLineOptions.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.cpd.commandline;
-
-import com.adobe.ac.pmd.ICommandLineOptions;
-
-public enum CpdCommandLineOptions implements ICommandLineOptions
-{
- MINIMUM_TOKENS("minimumTokens"), OUTPUT_FILE("outputFile");
-
- private String name;
-
- private CpdCommandLineOptions( final String nameToBeSet )
- {
- name = nameToBeSet;
- }
-
- @Override
- public String toString()
- {
- return name;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCPD.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCPD.java b/FlexPMD/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCPD.java
deleted file mode 100644
index c43042f..0000000
--- a/FlexPMD/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCPD.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * 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.cpd.commandline;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import net.sourceforge.pmd.PMDException;
-import net.sourceforge.pmd.cpd.CPD;
-import net.sourceforge.pmd.cpd.FileReporter;
-import net.sourceforge.pmd.cpd.Renderer;
-import net.sourceforge.pmd.cpd.ReportException;
-import net.sourceforge.pmd.cpd.XMLRenderer;
-
-import com.adobe.ac.cpd.FlexLanguage;
-import com.adobe.ac.cpd.FlexTokenizer;
-import com.adobe.ac.pmd.CommandLineOptions;
-import com.adobe.ac.pmd.CommandLineUtils;
-import com.adobe.ac.pmd.ICommandLineOptions;
-import com.adobe.ac.pmd.LoggerUtils;
-import com.adobe.ac.pmd.files.IFlexFile;
-import com.adobe.ac.pmd.files.impl.FileUtils;
-import com.martiansoftware.jsap.JSAP;
-import com.martiansoftware.jsap.JSAPException;
-import com.martiansoftware.jsap.JSAPResult;
-
-public final class FlexCPD
-{
- private static JSAPResult config;
- private static final String ENCODING = System.getProperty( "file.encoding" );
- private static final Logger LOGGER = Logger.getLogger( FlexCPD.class.getName() );
- private static FlexCpdParameters parameters;
-
- public static void main( final String[] args ) throws JSAPException,
- URISyntaxException,
- IOException,
- ReportException,
- PMDException
- {
- new LoggerUtils().loadConfiguration();
- startFlexCPD( args );
- LOGGER.info( "FlexCPD terminated" );
- System.exit( 0 ); // NOPMD
- }
-
- static boolean areCommandLineOptionsCorrect( final String[] args ) throws JSAPException
- {
- final JSAP jsap = new JSAP();
- config = parseCommandLineArguments( args,
- jsap );
-
- if ( !config.success() )
- {
- LOGGER.log( Level.SEVERE,
- "Usage: java "
- + FlexCPD.class.getName() + " " + jsap.getUsage() );
- }
-
- return config.success();
- }
-
- static String getParameterValue( final ICommandLineOptions option )
- {
- return config.getString( option.toString() );
- }
-
- static boolean startFlexCPD( final String[] args ) throws JSAPException,
- URISyntaxException,
- IOException,
- ReportException,
- PMDException
- {
- if ( areCommandLineOptionsCorrect( args ) )
- {
- final String minimumTokens = getParameterValue( CpdCommandLineOptions.MINIMUM_TOKENS );
- final String source = getParameterValue( CommandLineOptions.SOURCE_DIRECTORY );
- final File sourceDirectory = source.contains( "," ) ? null
- : new File( source );
- final List< File > sourceList = CommandLineUtils.computeSourceList( source );
- final File outputDirectory = new File( getParameterValue( CpdCommandLineOptions.OUTPUT_FILE ) );
-
- parameters = new FlexCpdParameters( outputDirectory,
- minimumTokens == null ? FlexTokenizer.DEFAULT_MINIMUM_TOKENS
- : Integer.valueOf( minimumTokens ),
- sourceDirectory,
- sourceList );
- LOGGER.info( "Starting run, minimumTokenCount is "
- + parameters.getMinimumTokenCount() );
-
- LOGGER.info( "Tokenizing files" );
- final CPD cpd = new CPD( parameters.getMinimumTokenCount(), new FlexLanguage() );
-
- cpd.setEncoding( ENCODING );
- tokenizeFiles( cpd );
-
- LOGGER.info( "Starting to analyze code" );
- final long timeTaken = analyzeCode( cpd );
- LOGGER.info( "Done analyzing code; that took "
- + timeTaken + " milliseconds" );
-
- LOGGER.info( "Generating report" );
- report( cpd );
- }
-
- return config.success();
- }
-
- private static long analyzeCode( final CPD cpd )
- {
- final long start = System.currentTimeMillis();
- cpd.go();
- final long stop = System.currentTimeMillis();
- return stop
- - start;
- }
-
- private static JSAPResult parseCommandLineArguments( final String[] args,
- final JSAP jsap ) throws JSAPException
- {
- CommandLineUtils.registerParameter( jsap,
- CommandLineOptions.SOURCE_DIRECTORY,
- true );
- CommandLineUtils.registerParameter( jsap,
- CpdCommandLineOptions.OUTPUT_FILE,
- true );
- CommandLineUtils.registerParameter( jsap,
- CpdCommandLineOptions.MINIMUM_TOKENS,
- false );
- CommandLineUtils.registerParameter( jsap,
- CommandLineOptions.EXLUDE_PACKAGE,
- false );
-
- return jsap.parse( args );
- }
-
- private static void report( final CPD cpd ) throws ReportException,
- IOException
- {
- if ( !cpd.getMatches().hasNext() )
- {
- LOGGER.info( "No duplicates over "
- + parameters.getMinimumTokenCount() + " tokens found" );
- }
- final Renderer renderer = new XMLRenderer( ENCODING );
-
- if ( !parameters.getOutputFile().exists() )
- {
- if ( parameters.getOutputFile().createNewFile() == false )
- {
- LOGGER.warning( "Could not create a new output file" );
- }
- }
-
- final FileReporter reporter = new FileReporter( parameters.getOutputFile(), ENCODING );
- reporter.report( renderer.render( cpd.getMatches() ) );
- }
-
- private static void tokenizeFiles( final CPD cpd ) throws IOException,
- PMDException
- {
- final Map< String, IFlexFile > files = FileUtils.computeFilesList( parameters.getSourceDirectory(),
- parameters.getSourceList(),
- "",
- null );
-
- for ( final Entry< String, IFlexFile > fileEntry : files.entrySet() )
- {
- cpd.add( new File( fileEntry.getValue().getFilePath() ) ); // NOPMD
- }
- }
-
- private FlexCPD()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCpdParameters.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCpdParameters.java b/FlexPMD/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCpdParameters.java
deleted file mode 100644
index dfdd0b3..0000000
--- a/FlexPMD/flex-pmd-cpd-command-line/src/main/java/com/adobe/ac/cpd/commandline/FlexCpdParameters.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.cpd.commandline;
-
-import java.io.File;
-import java.util.List;
-
-public class FlexCpdParameters
-{
- private final Integer minimumTokenCount;
- private final File outputFile;
- private final File sourceDirectory;
- private final List< File > sourceList;
-
- public FlexCpdParameters( final File outputFileToBeSet,
- final Integer minimumTokenCountToBeSet,
- final File sourceDirectoryToBeSet,
- final List< File > sourceListToBeSet )
- {
- super();
- minimumTokenCount = minimumTokenCountToBeSet;
- outputFile = outputFileToBeSet;
- sourceDirectory = sourceDirectoryToBeSet;
- sourceList = sourceListToBeSet;
- }
-
- public final Integer getMinimumTokenCount()
- {
- return minimumTokenCount;
- }
-
- public final File getOutputFile()
- {
- return outputFile;
- }
-
- public final File getSourceDirectory()
- {
- return sourceDirectory;
- }
-
- public List< File > getSourceList()
- {
- return sourceList;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd-command-line/src/test/java/com/adobe/ac/cpd/commandline/FlexCPDTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-command-line/src/test/java/com/adobe/ac/cpd/commandline/FlexCPDTest.java b/FlexPMD/flex-pmd-cpd-command-line/src/test/java/com/adobe/ac/cpd/commandline/FlexCPDTest.java
deleted file mode 100644
index 9526b0a..0000000
--- a/FlexPMD/flex-pmd-cpd-command-line/src/test/java/com/adobe/ac/cpd/commandline/FlexCPDTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.cpd.commandline;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import net.sourceforge.pmd.PMDException;
-import net.sourceforge.pmd.cpd.ReportException;
-
-import org.junit.Test;
-
-import com.adobe.ac.pmd.CommandLineOptions;
-import com.adobe.ac.pmd.FlexPmdTestBase;
-import com.martiansoftware.jsap.JSAPException;
-
-public class FlexCPDTest extends FlexPmdTestBase
-{
- @Test
- public void testAreCommandLineOptionsCorrect() throws FileNotFoundException,
- JSAPException,
- PMDException,
- URISyntaxException
- {
- assertFalse( FlexCPD.areCommandLineOptionsCorrect( new String[]
- {} ) );
-
- assertFalse( FlexCPD.areCommandLineOptionsCorrect( new String[]
- { "-y",
- "sourceDirectory",
- "-p",
- "outPutDirectory" } ) );
-
- assertTrue( FlexCPD.areCommandLineOptionsCorrect( new String[]
- { "-s",
- "sourceDirectory",
- "-o",
- "target",
- "-m",
- "50" } ) );
-
- assertTrue( FlexCPD.areCommandLineOptionsCorrect( new String[]
- { "-s",
- "sourceDirectory",
- "-o",
- "target" } ) );
- }
-
- @Test
- public void testGetCommandLineValue() throws JSAPException
- {
- FlexCPD.areCommandLineOptionsCorrect( new String[]
- { "-s",
- "sourceDirectory",
- "-o",
- "target",
- "-m",
- "25" } );
-
- assertEquals( "sourceDirectory",
- FlexCPD.getParameterValue( CommandLineOptions.SOURCE_DIRECTORY ) );
- assertEquals( "target",
- FlexCPD.getParameterValue( CpdCommandLineOptions.OUTPUT_FILE ) );
- assertEquals( "25",
- FlexCPD.getParameterValue( CpdCommandLineOptions.MINIMUM_TOKENS ) );
- }
-
- @Test
- public void testStartFlexCPD() throws JSAPException,
- PMDException,
- URISyntaxException,
- IOException,
- ReportException
- {
- final String[] args = new String[]
- { "-s",
- getTestDirectory().getAbsolutePath(),
- "-o",
- new File( "target/cpd.xml" ).getAbsolutePath(),
- "--excludePackage",
- "cairngorm." };
-
- FlexCPD.startFlexCPD( args );
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-maven-plugin/pom.xml b/FlexPMD/flex-pmd-cpd-maven-plugin/pom.xml
deleted file mode 100644
index 7249bb3..0000000
--- a/FlexPMD/flex-pmd-cpd-maven-plugin/pom.xml
+++ /dev/null
@@ -1,116 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.adobe.ac</groupId>
- <artifactId>flex-pmd-cpd-maven-plugin</artifactId>
- <name>Adobe Flex CPD Maven plugin</name>
- <packaging>maven-plugin</packaging>
-
- <parent>
- <groupId>com.adobe.ac</groupId>
- <artifactId>flex-pmd-java-parent</artifactId>
- <version>1.3-SNAPSHOT</version>
- <relativePath>../flex-pmd-java-parent/pom.xml</relativePath>
- </parent>
-
- <dependencies>
- <dependency>
- <groupId>pmd</groupId>
- <artifactId>pmd</artifactId>
- <version>${pmd.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>${maven-plugin-api.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.reporting</groupId>
- <artifactId>maven-reporting-impl</artifactId>
- <version>${maven-reporting-impl.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <version>${maven-pmd-plugin.version}</version>
- <type>maven-plugin</type>
- </dependency>
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>flex-pmd-core</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>flex-pmd-cpd</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>flex-pmd-files</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>flex-pmd-test-resources</artifactId>
- <version>${project.parent.version}</version>
- <classifier>resources</classifier>
- <type>zip</type>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-
- <build>
-
- <testResources>
- <testResource>
- <directory>${project.build.directory}/test/generated-resources</directory>
- </testResource>
- </testResources>
-
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>unpack-test-resources</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>unpack-dependencies</goal>
- </goals>
- <configuration>
- <includeGroupIds>${project.groupId}</includeGroupIds>
- <includes>**/*.as,**/*.mxml</includes>
- <outputDirectory>${project.build.directory}/test/generated-resources</outputDirectory>
- <excludeTransitive>true</excludeTransitive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/java/com/adobe/ac/cpd/maven/FlexCpdMojo.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/java/com/adobe/ac/cpd/maven/FlexCpdMojo.java b/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/java/com/adobe/ac/cpd/maven/FlexCpdMojo.java
deleted file mode 100644
index e7481e5..0000000
--- a/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/java/com/adobe/ac/cpd/maven/FlexCpdMojo.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * 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.cpd.maven;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.Map.Entry;
-
-import net.sourceforge.pmd.PMDException;
-import net.sourceforge.pmd.cpd.CPD;
-import net.sourceforge.pmd.cpd.FileReporter;
-import net.sourceforge.pmd.cpd.Renderer;
-import net.sourceforge.pmd.cpd.ReportException;
-import net.sourceforge.pmd.cpd.XMLRenderer;
-
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.reporting.AbstractMavenReport;
-import org.apache.maven.reporting.MavenReportException;
-import org.codehaus.doxia.site.renderer.SiteRenderer;
-
-import com.adobe.ac.cpd.FlexLanguage;
-import com.adobe.ac.pmd.LoggerUtils;
-import com.adobe.ac.pmd.files.IFlexFile;
-import com.adobe.ac.pmd.files.impl.FileUtils;
-
-/**
- * @author xagnetti
- * @goal check
- * @phase verify
- */
-public class FlexCpdMojo extends AbstractMavenReport
-{
- private static final String OUTPUT_NAME = "cpd";
-
- protected static ResourceBundle getBundle( final Locale locale )
- {
- return ResourceBundle.getBundle( "flexPmd",
- locale,
- FlexCpdMojo.class.getClassLoader() ); // NOPMD
- }
-
- private final String encoding = System.getProperty( "file.encoding" );
-
- /**
- * Location of the file.
- *
- * @parameter expression="25"
- * @required
- */
- private int minimumTokenCount;
-
- /**
- * Location of the file.
- *
- * @parameter expression="${project.build.directory}"
- * @required
- */
- private File outputDirectory;
-
- /**
- * @parameter expression="${project}"
- * @required
- * @readonly
- */
- private MavenProject project;
-
- /**
- * @parameter
- * expression="${component.org.codehaus.doxia.site.renderer.SiteRenderer}"
- * @required
- * @readonly
- */
- private SiteRenderer siteRenderer;
-
- /**
- * Specifies the location of the source files to be used.
- *
- * @parameter expression="${project.build.sourceDirectory}"
- * @required
- * @readonly
- */
- private File sourceDirectory;
-
- public FlexCpdMojo()
- {
- super();
- }
-
- public FlexCpdMojo( final File outputDirectoryToBeSet,
- final File sourceDirectoryToBeSet,
- final MavenProject projectToBeSet )
- {
- super();
- outputDirectory = outputDirectoryToBeSet;
- sourceDirectory = sourceDirectoryToBeSet;
- project = projectToBeSet;
- minimumTokenCount = 25;
- }
-
- public String getDescription( final Locale locale )
- {
- return getBundle( locale ).getString( "report.flexCpd.description" );
- }
-
- public final String getName( final Locale locale )
- {
- return getBundle( locale ).getString( "report.flexCpd.name" );
- }
-
- public final String getOutputName()
- {
- return OUTPUT_NAME;
- }
-
- void setSiteRenderer( final SiteRenderer site )
- {
- siteRenderer = site;
- }
-
- @Override
- protected void executeReport( final Locale locale ) throws MavenReportException
- {
- new LoggerUtils().loadConfiguration();
-
- final CPD cpd = new CPD( minimumTokenCount, new FlexLanguage() );
-
- try
- {
- final Map< String, IFlexFile > files = FileUtils.computeFilesList( sourceDirectory,
- null,
- "",
- null );
-
- for ( final Entry< String, IFlexFile > fileEntry : files.entrySet() )
- {
- cpd.add( new File( fileEntry.getValue().getFilePath() ) ); // NOPMD
- }
-
- cpd.go();
-
- report( cpd );
- }
- catch ( final PMDException e )
- {
- throw new MavenReportException( "", e );
- }
- catch ( final IOException e )
- {
- throw new MavenReportException( "", e );
- }
- catch ( final ReportException e )
- {
- throw new MavenReportException( "", e );
- }
- }
-
- @Override
- protected String getOutputDirectory()
- {
- return outputDirectory.getAbsolutePath();
- }
-
- @Override
- protected MavenProject getProject()
- {
- return project;
- }
-
- @Override
- protected SiteRenderer getSiteRenderer()
- {
- return siteRenderer;
- }
-
- private void report( final CPD cpd ) throws ReportException
- {
- final Renderer renderer = new XMLRenderer( encoding );
- final FileReporter reporter = new FileReporter( new File( outputDirectory.getAbsolutePath(),
- OUTPUT_NAME
- + ".xml" ), encoding );
- reporter.report( renderer.render( cpd.getMatches() ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/resources/flexPmd.properties
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/resources/flexPmd.properties b/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/resources/flexPmd.properties
deleted file mode 100644
index 238be18..0000000
--- a/FlexPMD/flex-pmd-cpd-maven-plugin/src/main/resources/flexPmd.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-# 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.
-
-report.flexCpd.name=
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd-maven-plugin/src/test/java/com/adobe/ac/cpd/maven/FlexCpdMojoTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd-maven-plugin/src/test/java/com/adobe/ac/cpd/maven/FlexCpdMojoTest.java b/FlexPMD/flex-pmd-cpd-maven-plugin/src/test/java/com/adobe/ac/cpd/maven/FlexCpdMojoTest.java
deleted file mode 100644
index 93d09cb..0000000
--- a/FlexPMD/flex-pmd-cpd-maven-plugin/src/test/java/com/adobe/ac/cpd/maven/FlexCpdMojoTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.cpd.maven;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
-import org.codehaus.doxia.site.renderer.DefaultSiteRenderer;
-import org.junit.Test;
-
-import com.adobe.ac.pmd.FlexPmdTestBase;
-
-public class FlexCpdMojoTest extends FlexPmdTestBase
-{
- @Test
- public void testExecute() throws MojoExecutionException,
- IOException
- {
- final FlexCpdMojo mojo = new FlexCpdMojo( new File( "target" ),
- getTestDirectory(),
- new MavenProjectStub() );
-
- mojo.setSiteRenderer( new DefaultSiteRenderer() );
- mojo.execute();
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd/pom.xml b/FlexPMD/flex-pmd-cpd/pom.xml
deleted file mode 100644
index c0ac9ec..0000000
--- a/FlexPMD/flex-pmd-cpd/pom.xml
+++ /dev/null
@@ -1,93 +0,0 @@
-<!--
-
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.adobe.ac</groupId>
- <artifactId>flex-pmd-cpd</artifactId>
- <name>Adobe Flex CPD (Copy and Past Detector)</name>
-
- <parent>
- <groupId>com.adobe.ac</groupId>
- <artifactId>flex-pmd-java-parent</artifactId>
- <version>1.3-SNAPSHOT</version>
- <relativePath>../flex-pmd-java-parent/pom.xml</relativePath>
- </parent>
-
- <dependencies>
-
- <dependency>
- <groupId>pmd</groupId>
- <artifactId>pmd</artifactId>
- <version>${pmd.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <version>${project.parent.version}</version>
- <artifactId>as3-parser</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>flex-pmd-test-resources</artifactId>
- <version>${project.parent.version}</version>
- <classifier>resources</classifier>
- <type>zip</type>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <version>${project.version}</version>
- <artifactId>flex-pmd-files</artifactId>
- </dependency>
-
- </dependencies>
-
- <build>
- <testResources>
- <testResource>
- <directory>${project.build.directory}/test/generated-resources</directory>
- </testResource>
- </testResources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>unpack-test-resources</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>unpack-dependencies</goal>
- </goals>
- <configuration>
- <includeGroupIds>${project.groupId}</includeGroupIds>
- <includes>**/*.as,**/*.mxml</includes>
- <outputDirectory>${project.build.directory}/test/generated-resources</outputDirectory>
- <excludeTransitive>true</excludeTransitive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexLanguage.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexLanguage.java b/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexLanguage.java
deleted file mode 100644
index b71ce3f..0000000
--- a/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexLanguage.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.cpd;
-
-import net.sourceforge.pmd.cpd.AbstractLanguage;
-
-public class FlexLanguage extends AbstractLanguage
-{
- public FlexLanguage()
- {
- super( new FlexTokenizer(), "as", "mxml" );
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexTokenizer.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexTokenizer.java b/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexTokenizer.java
deleted file mode 100644
index 252009d..0000000
--- a/FlexPMD/flex-pmd-cpd/src/main/java/com/adobe/ac/cpd/FlexTokenizer.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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.cpd;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Set;
-
-import net.sourceforge.pmd.cpd.SourceCode;
-import net.sourceforge.pmd.cpd.TokenEntry;
-import net.sourceforge.pmd.cpd.Tokenizer;
-import net.sourceforge.pmd.cpd.Tokens;
-
-import com.adobe.ac.pmd.files.IFlexFile;
-import com.adobe.ac.pmd.files.IMxmlFile;
-import com.adobe.ac.pmd.files.impl.FileUtils;
-import com.adobe.ac.pmd.parser.KeyWords;
-import com.adobe.ac.pmd.parser.Operators;
-
-import de.bokelberg.flex.parser.AS3Parser;
-import de.bokelberg.flex.parser.AS3Scanner;
-import de.bokelberg.flex.parser.AS3Scanner.Token;
-
-public class FlexTokenizer implements Tokenizer
-{
- public static final int DEFAULT_MINIMUM_TOKENS = 25;
- private static final Set< String > IGNORED_TOKENS;
- private static final Set< String > IGNORING_LINE_TOKENS;
-
- static
- {
- IGNORED_TOKENS = new HashSet< String >();
- IGNORED_TOKENS.add( Operators.SEMI_COLUMN.toString() );
- IGNORED_TOKENS.add( Operators.LEFT_CURLY_BRACKET.toString() );
- IGNORED_TOKENS.add( Operators.RIGHT_CURLY_BRACKET.toString() );
- IGNORED_TOKENS.add( AS3Parser.NEW_LINE );
- IGNORING_LINE_TOKENS = new HashSet< String >();
- IGNORING_LINE_TOKENS.add( KeyWords.IMPORT.toString() );
- IGNORING_LINE_TOKENS.add( KeyWords.PACKAGE.toString() );
- }
-
- private static boolean isTokenIgnored( final String tokenText )
- {
- return IGNORED_TOKENS.contains( tokenText )
- || tokenText.startsWith( AS3Parser.MULTIPLE_LINES_COMMENT )
- || tokenText.startsWith( AS3Parser.SINGLE_LINE_COMMENT );
- }
-
- private static boolean isTokenIgnoringLine( final String tokenText )
- {
- return IGNORING_LINE_TOKENS.contains( tokenText );
- }
-
- public void tokenize( final SourceCode tokens,
- final Tokens tokenEntries )
- {
- try
- {
- final AS3Scanner scanner = initializeScanner( tokens );
- Token currentToken = scanner.moveToNextToken();
- int inImportLine = 0;
-
- while ( currentToken != null
- && currentToken.getText().compareTo( KeyWords.EOF.toString() ) != 0 )
- {
- final String currentTokenText = currentToken.getText();
- final int currentTokenLine = currentToken.getLine();
-
- if ( !isTokenIgnored( currentTokenText ) )
- {
- if ( isTokenIgnoringLine( currentTokenText ) )
- {
- inImportLine = currentTokenLine;
- }
- else
- {
- if ( inImportLine == 0
- || inImportLine != currentTokenLine )
- {
- inImportLine = 0;
- tokenEntries.add( new TokenEntry( currentTokenText, // NOPMD
- tokens.getFileName(),
- currentTokenLine ) );
- }
- }
- }
- currentToken = scanner.moveToNextToken();
- }
- }
- catch ( final Exception e )
- {
- }
- finally
- {
- tokenEntries.add( TokenEntry.getEOF() );
- }
- }
-
- private AS3Scanner initializeScanner( final SourceCode tokens )
- {
- final AS3Scanner scanner = new AS3Scanner();
-
- final IFlexFile flexFile = FileUtils.create( new File( tokens.getFileName() ),
- new File( "" ) );
-
- if ( flexFile instanceof IMxmlFile )
- {
- final IMxmlFile mxml = ( IMxmlFile ) flexFile;
-
- scanner.setLines( mxml.getScriptBlock() );
- }
- else
- {
- scanner.setLines( tokens.getCode().toArray( new String[ tokens.getCode().size() ] ) );
- }
- return scanner;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd/src/test/java/com/adobe/ac/cpd/FlexCpdTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd/src/test/java/com/adobe/ac/cpd/FlexCpdTest.java b/FlexPMD/flex-pmd-cpd/src/test/java/com/adobe/ac/cpd/FlexCpdTest.java
deleted file mode 100644
index 09b7a75..0000000
--- a/FlexPMD/flex-pmd-cpd/src/test/java/com/adobe/ac/cpd/FlexCpdTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.cpd;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-import net.sourceforge.pmd.cpd.CPD;
-import net.sourceforge.pmd.cpd.Match;
-
-import org.junit.Test;
-
-import com.adobe.ac.pmd.FlexPmdTestBase;
-import com.adobe.ac.pmd.files.IFlexFile;
-
-public class FlexCpdTest extends FlexPmdTestBase
-{
- private class ExpectedMatchInformation
- {
- private final int lineCount;
- private final int markCount;
- private final int tokenCount;
-
- public ExpectedMatchInformation( final int tokenCountToBeSet,
- final int markCountToBeSet,
- final int lineCountToBeSet )
- {
- lineCount = lineCountToBeSet;
- tokenCount = tokenCountToBeSet;
- markCount = markCountToBeSet;
- }
- }
- final ExpectedMatchInformation[] EXPECTED = new ExpectedMatchInformation[]
- { new ExpectedMatchInformation( 107, 2, 7 ),
- new ExpectedMatchInformation( 79, 2, 17 ),
- new ExpectedMatchInformation( 77, 2, 6 ),
- new ExpectedMatchInformation( 76, 2, 18 ),
- new ExpectedMatchInformation( 64, 2, 7 ),
- new ExpectedMatchInformation( 60, 3, 14 ),
- new ExpectedMatchInformation( 57, 2, 7 ),
- new ExpectedMatchInformation( 54, 2, 9 ),
- new ExpectedMatchInformation( 53, 2, 8 ),
- new ExpectedMatchInformation( 48, 2, 18 ) };
-
- @Test
- public void test119() throws IOException
- {
- final CPD cpd = new CPD( 25, new FlexLanguage() );
-
- cpd.add( new File( "src/test/resources/test/FlexPMD119.mxml" ) );
- cpd.go();
-
- final Iterator< Match > matchIterator = cpd.getMatches();
- final Match match = matchIterator.next();
-
- assertEquals( "The first mark is not correct",
- 41,
- match.getFirstMark().getBeginLine() );
- assertEquals( "The second mark is not correct",
- 81,
- match.getSecondMark().getBeginLine() );
- }
-
- @Test
- public void tokenize() throws IOException
- {
- final Iterator< Match > matchIterator = getMatchIterator();
-
- for ( int currentIndex = 0; matchIterator.hasNext()
- && currentIndex < EXPECTED.length; currentIndex++ )
- {
- final Match currentMatch = matchIterator.next();
-
- assertEquals( "The token count is not correct on the "
- + currentIndex + "th index",
- EXPECTED[ currentIndex ].tokenCount,
- currentMatch.getTokenCount() );
-
- assertEquals( "The mark count is not correct on the "
- + currentIndex + "th index",
- EXPECTED[ currentIndex ].markCount,
- currentMatch.getMarkCount() );
-
- assertEquals( "The line count is not correct on the "
- + currentIndex + "th index",
- EXPECTED[ currentIndex ].lineCount,
- currentMatch.getLineCount() );
- }
- }
-
- private Iterator< Match > getMatchIterator() throws IOException
- {
- final CPD cpd = new CPD( 25, new FlexLanguage() );
-
- for ( final Entry< String, IFlexFile > includedFile : getTestFiles().entrySet() )
- {
- cpd.add( new File( includedFile.getValue().getFilePath() ) );
- }
- cpd.go();
-
- return cpd.getMatches();
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-cpd/src/test/resources/test/FlexPMD119.mxml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-cpd/src/test/resources/test/FlexPMD119.mxml b/FlexPMD/flex-pmd-cpd/src/test/resources/test/FlexPMD119.mxml
deleted file mode 100644
index 1519ac1..0000000
--- a/FlexPMD/flex-pmd-cpd/src/test/resources/test/FlexPMD119.mxml
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-
- 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.
-
--->
-<mx:Canvas>
-
- <mx:Script>
- <![CDATA[
-
- // Handle the mouseDown event generated
- // by clicking in the application.
- private function handleMouseDown(event:MouseEvent):void {
-
- // Convert the mouse position to global coordinates.
- // The localX and localY properties of the mouse event contain
- // the coordinates at which the event occurred relative to the
- // event target, typically one of the
- // colored internal Canvas controls.
- // A production version of this example could use the stageX
- // and stageY properties, which use the global coordinates,
- // and avoid this step.
- // This example uses the localX and localY properties only to
- // illustrate conversion between different frames of reference.
- var pt:Point = new Point(event.localX, event.localY);
- pt = event.target.localToGlobal(pt);
-
- // Convert the global coordinates to the content coordinates
- // inside the outer c1 Canvas control.
- pt = c1.globalToContent(pt);
-
- // Figure out which quadrant was clicked.
- var whichColor:String = "border area";
-
- if (pt.x < 150) {
- if (pt.y < 150)
- whichColor = "red";
- else
- whichColor = "blue";
- }
- else {
- if (pt.y < 150)
- whichColor = "green";
- else
- whichColor = "magenta";
- }
-
- Alert.show("You clicked on the " + whichColor);
- }
-
- // Handle the mouseDown event generated
- // by clicking in the application.
- private function handleMouseDown(event:MouseEvent):void {
-
- // Convert the mouse position to global coordinates.
- // The localX and localY properties of the mouse event contain
- // the coordinates at which the event occurred relative to the
- // event target, typically one of the
- // colored internal Canvas controls.
- // A production version of this example could use the stageX
- // and stageY properties, which use the global coordinates,
- // and avoid this step.
- // This example uses the localX and localY properties only to
- // illustrate conversion between different frames of reference.
- var pt:Point = new Point(event.localX, event.localY);
- pt = event.target.localToGlobal(pt);
-
- // Convert the global coordinates to the content coordinates
- // inside the outer c1 Canvas control.
- pt = c1.globalToContent(pt);
-
- // Figure out which quadrant was clicked.
- var whichColor:String = "border area";
-
- if (pt.x < 150) {
- if (pt.y < 150)
- whichColor = "red";
- else
- whichColor = "blue";
- }
- else {
- if (pt.y < 150)
- whichColor = "green";
- else
- whichColor = "magenta";
- }
-
- Alert.show("You clicked on the " + whichColor);
- }
- ]]>
- </mx:Script>
-
-</mx:Canvas>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-files/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-files/pom.xml b/FlexPMD/flex-pmd-files/pom.xml
deleted file mode 100644
index 0ae0148..0000000
--- a/FlexPMD/flex-pmd-files/pom.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-<!--
-
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License. You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.adobe.ac</groupId>
- <artifactId>flex-pmd-files</artifactId>
- <name>Adobe Flex PMD Files</name>
-
- <parent>
- <groupId>com.adobe.ac</groupId>
- <artifactId>flex-pmd-java-parent</artifactId>
- <version>1.3-SNAPSHOT</version>
- <relativePath>../flex-pmd-java-parent/pom.xml</relativePath>
- </parent>
-
- <dependencies>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>${commons-lang.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>as3-plugin-utils</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>flex-pmd-test-resources</artifactId>
- <version>${project.version}</version>
- <classifier>resources</classifier>
- <type>zip</type>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <testResources>
- <testResource>
- <directory>${project.build.directory}/test/generated-resources</directory>
- </testResource>
- </testResources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>unpack-test-resources</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>unpack-dependencies</goal>
- </goals>
- <configuration>
- <includeGroupIds>${project.groupId}</includeGroupIds>
- <includes>**/*.as,**/*.mxml</includes>
- <outputDirectory>${project.build.directory}/test/generated-resources</outputDirectory>
- <excludeTransitive>true</excludeTransitive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file