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:14 UTC
[43/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-command-line-api/src/test/java/com/adobe/ac/pmd/CommandLineUtilsTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-command-line-api/src/test/java/com/adobe/ac/pmd/CommandLineUtilsTest.java b/FlexPMD/flex-pmd-command-line-api/src/test/java/com/adobe/ac/pmd/CommandLineUtilsTest.java
deleted file mode 100644
index 305315c..0000000
--- a/FlexPMD/flex-pmd-command-line-api/src/test/java/com/adobe/ac/pmd/CommandLineUtilsTest.java
+++ /dev/null
@@ -1,58 +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.pmd;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-import com.martiansoftware.jsap.JSAP;
-import com.martiansoftware.jsap.JSAPException;
-
-public class CommandLineUtilsTest
-{
- @Test
- public void testComputeSourceList()
- {
- assertEquals( 3,
- CommandLineUtils.computeSourceList( "lala,toto,tyty" ).size() );
- assertNull( CommandLineUtils.computeSourceList( "lala" ) );
- }
-
- @Test
- public void testRegisterParameter() throws JSAPException
- {
- final JSAP jsap = new JSAP();
-
- CommandLineUtils.registerParameter( jsap,
- new ICommandLineOptions()
- {
- @Override
- public String toString()
- {
- return "name";
- }
- },
- true );
-
- assertTrue( jsap.getByShortFlag( 'n' ) != null );
- assertNull( jsap.getByShortFlag( 'm' ) );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-command-line/.pmd
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-command-line/.pmd b/FlexPMD/flex-pmd-command-line/.pmd
deleted file mode 100644
index b5c19d9..0000000
--- a/FlexPMD/flex-pmd-command-line/.pmd
+++ /dev/null
@@ -1,25 +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>
- <useProjectRuleSet>false</useProjectRuleSet>
- <ruleSetFile>../flex-pmd-parent/pmd.xml</ruleSetFile>
- <includeDerivedFiles>false</includeDerivedFiles>
- <violationsAsErrors>true</violationsAsErrors>
-</pmd>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-command-line/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-command-line/pom.xml b/FlexPMD/flex-pmd-command-line/pom.xml
deleted file mode 100644
index f930a8a..0000000
--- a/FlexPMD/flex-pmd-command-line/pom.xml
+++ /dev/null
@@ -1,198 +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-command-line</artifactId>
- <name>Adobe Flex PMD Command line</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>
-
- <description />
- <packaging>jar</packaging>
-
- <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-core</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <version>${project.version}</version>
- <artifactId>${project.artifactId}-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <version>${project.version}</version>
- <artifactId>flex-pmd-ruleset</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>
-
- <!-- Dependencies for packaging from ANT -->
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <version>${project.version}</version>
- <artifactId>flex-pmd-files</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <version>${project.version}</version>
- <artifactId>flex-pmd-ruleset-api</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>pmd</groupId>
- <artifactId>pmd</artifactId>
- <version>${pmd.version}</version>
- </dependency>
- <dependency>
- <groupId>plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>${plexus-utils.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>${commons-lang.version}</version>
- </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.pmd.commandline.FlexPMD</mainClass>
- <packageName>com.adobe.ac.pmd.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 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-command-line-api.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.adobe.ac.flex-pmd-core.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.com.adobe.ac.flex-pmd-ruleset.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.flex-pmd-ruleset-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" />
- <echo message="Copying Command line dependencies..." />
- <copy file="${maven.dependency.com.adobe.ac.as3-plugin-utils.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.pmd.pmd.jar.path}" todir="${project.build.directory}/release" overwrite="true" />
- <copy file="${maven.dependency.plexus.plexus-utils.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-command-line/src/main/assemble/bin.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-command-line/src/main/assemble/bin.xml b/FlexPMD/flex-pmd-command-line/src/main/assemble/bin.xml
deleted file mode 100644
index 3f5dd15..0000000
--- a/FlexPMD/flex-pmd-command-line/src/main/assemble/bin.xml
+++ /dev/null
@@ -1,41 +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.
-
--->
-<assembly>
- <id>command-line</id>
- <formats>
- <format>jar</format>
- </formats>
- <fileSets>
- <fileSet>
-
- </fileSet>
- </fileSets>
- <dependencySets>
- <dependencySet>
- <includes>
- <include>com.adobe.ac:flex-pmd-core</include>
- <include>com.adobe.ac:as3-parser</include>
- <include>com.adobe.ac:as3-plugin-utils</include>
- <include>com.adobe.ac:flex-pmd-ruleset</include>
- <include>com.adobe.ac:flex-pmd-ruleset-api</include>
- <include>com.martiansoftware:jsap</include>
- </includes>
- </dependencySet>
- </dependencySets>
-</assembly>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-command-line/src/main/java/com/adobe/ac/pmd/commandline/FlexPMD.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-command-line/src/main/java/com/adobe/ac/pmd/commandline/FlexPMD.java b/FlexPMD/flex-pmd-command-line/src/main/java/com/adobe/ac/pmd/commandline/FlexPMD.java
deleted file mode 100644
index 4b293fa..0000000
--- a/FlexPMD/flex-pmd-command-line/src/main/java/com/adobe/ac/pmd/commandline/FlexPMD.java
+++ /dev/null
@@ -1,134 +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.pmd.commandline;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import net.sourceforge.pmd.PMDException;
-
-import com.adobe.ac.pmd.CommandLineOptions;
-import com.adobe.ac.pmd.CommandLineUtils;
-import com.adobe.ac.pmd.FlexPmdParameters;
-import com.adobe.ac.pmd.FlexPmdViolations;
-import com.adobe.ac.pmd.LoggerUtils;
-import com.adobe.ac.pmd.engines.FlexPmdXmlEngine;
-import com.martiansoftware.jsap.JSAP;
-import com.martiansoftware.jsap.JSAPException;
-import com.martiansoftware.jsap.JSAPResult;
-
-public final class FlexPMD // NO_UCD
-{
- private static JSAPResult config;
- private static final Logger LOGGER = Logger.getLogger( FlexPMD.class.getName() );
-
- /**
- * @param args
- * @throws JSAPException
- * @throws PMDException
- * @throws URISyntaxException
- * @throws IOException
- * @throws Exception
- */
- public static void main( final String[] args ) throws JSAPException,
- PMDException,
- URISyntaxException,
- IOException
- {
- new LoggerUtils().loadConfiguration();
- startFlexPMD( args );
- LOGGER.info( "FlexPMD 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 "
- + FlexPMD.class.getName() + " " + jsap.getUsage() );
- }
-
- return config.success();
- }
-
- static String getParameterValue( final CommandLineOptions option )
- {
- return config.getString( option.toString() );
- }
-
- static boolean startFlexPMD( final String[] args ) throws JSAPException,
- PMDException,
- URISyntaxException,
- IOException
- {
- if ( areCommandLineOptionsCorrect( args ) )
- {
- final String rulesetRef = getParameterValue( CommandLineOptions.RULE_SET );
- final String excludePackage = getParameterValue( CommandLineOptions.EXLUDE_PACKAGE );
- 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( CommandLineOptions.OUTPUT ) );
- final FlexPmdParameters parameters = new FlexPmdParameters( excludePackage == null ? ""
- : excludePackage,
- outputDirectory,
- rulesetRef == null ? null
- : new File( rulesetRef ),
- sourceDirectory,
- sourceList );
- final FlexPmdXmlEngine engine = new FlexPmdXmlEngine( parameters );
-
- engine.executeReport( new FlexPmdViolations() );
- }
-
- return config.success();
- }
-
- private static JSAPResult parseCommandLineArguments( final String[] args,
- final JSAP jsap ) throws JSAPException
- {
- CommandLineUtils.registerParameter( jsap,
- CommandLineOptions.SOURCE_DIRECTORY,
- true );
- CommandLineUtils.registerParameter( jsap,
- CommandLineOptions.OUTPUT,
- true );
- CommandLineUtils.registerParameter( jsap,
- CommandLineOptions.RULE_SET,
- false );
- CommandLineUtils.registerParameter( jsap,
- CommandLineOptions.EXLUDE_PACKAGE,
- false );
-
- return jsap.parse( args );
- }
-
- private FlexPMD()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-command-line/src/test/java/com/adobe/ac/pmd/commandline/FlexPMDTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-command-line/src/test/java/com/adobe/ac/pmd/commandline/FlexPMDTest.java b/FlexPMD/flex-pmd-command-line/src/test/java/com/adobe/ac/pmd/commandline/FlexPMDTest.java
deleted file mode 100644
index 764b118..0000000
--- a/FlexPMD/flex-pmd-command-line/src/test/java/com/adobe/ac/pmd/commandline/FlexPMDTest.java
+++ /dev/null
@@ -1,187 +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.pmd.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 junit.framework.Assert;
-import net.sourceforge.pmd.PMDException;
-
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.io.SAXReader;
-import org.junit.Test;
-
-import com.adobe.ac.pmd.CommandLineOptions;
-import com.adobe.ac.pmd.FlexPmdTestBase;
-import com.martiansoftware.jsap.JSAPException;
-
-public class FlexPMDTest extends FlexPmdTestBase
-{
- @Test
- public void testAreCommandLineOptionsCorrect() throws FileNotFoundException,
- JSAPException,
- PMDException,
- URISyntaxException
- {
- assertFalse( FlexPMD.areCommandLineOptionsCorrect( new String[]
- {} ) );
-
- assertFalse( FlexPMD.areCommandLineOptionsCorrect( new String[]
- { "-y",
- "sourceDirectory",
- "-p",
- "outPutDirectory" } ) );
-
- assertTrue( FlexPMD.areCommandLineOptionsCorrect( new String[]
- { "-s",
- "sourceDirectory",
- "-o",
- "target",
- "-r",
- "valid.xml" } ) );
-
- assertTrue( FlexPMD.areCommandLineOptionsCorrect( new String[]
- { "-s",
- "sourceDirectory",
- "-o",
- "target" } ) );
- }
-
- @Test
- public void testFlexPMD114() throws JSAPException,
- PMDException,
- URISyntaxException,
- IOException,
- DocumentException
- {
- final String[] args = new String[]
- { "-s",
- getTestDirectory().getAbsolutePath()
- + File.separatorChar + "flexpmd114",
- "-o",
- new File( "target/test2" ).getAbsolutePath() };
-
- FlexPMD.startFlexPMD( args );
-
- assertEquals( 3,
- loadDocument( new File( "target/test2/pmd.xml" ) ).selectNodes( "//pmd/file" ).size() );
- }
-
- @Test
- public void testFlexPMD88() throws JSAPException,
- PMDException,
- URISyntaxException,
- IOException,
- DocumentException
- {
- final String[] args = new String[]
- { "-s",
- getTestDirectory().getAbsolutePath()
- + File.separatorChar + "bug" + File.separatorChar + "FlexPMD88.as",
- "-o",
- new File( "target/test3" ).getAbsolutePath() };
-
- FlexPMD.startFlexPMD( args );
-
- Assert.assertTrue( loadDocument( new File( "target/test3/pmd.xml" ) ).selectNodes( "//pmd/file[1]/violation" )
- .size() > 0 );
- }
-
- @Test
- public void testGetCommandLineValue() throws JSAPException
- {
- FlexPMD.areCommandLineOptionsCorrect( new String[]
- { "-s",
- "sourceDirectory",
- "-o",
- "target",
- "-r",
- "valid.xml" } );
-
- assertEquals( "sourceDirectory",
- FlexPMD.getParameterValue( CommandLineOptions.SOURCE_DIRECTORY ) );
- assertEquals( "target",
- FlexPMD.getParameterValue( CommandLineOptions.OUTPUT ) );
- assertEquals( "valid.xml",
- FlexPMD.getParameterValue( CommandLineOptions.RULE_SET ) );
- }
-
- @Test
- public void testStartFlexPMD() throws JSAPException,
- PMDException,
- URISyntaxException,
- IOException
- {
- final String[] args = new String[]
- { "-s",
- getTestDirectory().getAbsolutePath(),
- "-o",
- new File( "target/test" ).getAbsolutePath(),
- "--excludePackage",
- "cairngorm." };
-
- FlexPMD.startFlexPMD( args );
- }
-
- @Test
- public void testStartFlexPMDOnAFile() throws JSAPException,
- PMDException,
- URISyntaxException,
- IOException
- {
- final String filePath = getTestFiles().get( "AbstractRowData.as" ).getFilePath();
-
- final String[] args = new String[]
- { "-s",
- filePath,
- "-o",
- new File( "target/test" ).getAbsolutePath(),
- "--excludePackage",
- "cairngorm." };
-
- FlexPMD.startFlexPMD( args );
- }
-
- @Test
- public void testStartFlexPMDOnSeveralFolders() throws JSAPException,
- PMDException,
- URISyntaxException,
- IOException
- {
- final String[] args = new String[]
- { "-s",
- new File( "target/test/bug" ).getAbsolutePath()
- + "," + new File( "target/test/cairngorm" ).getAbsolutePath(),
- "-o",
- new File( "target/test" ).getAbsolutePath(), };
-
- FlexPMD.startFlexPMD( args );
- }
-
- private Document loadDocument( final File outputFile ) throws DocumentException
- {
- return new SAXReader().read( outputFile );
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/.p4ignore
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/.p4ignore b/FlexPMD/flex-pmd-core/.p4ignore
deleted file mode 100644
index eb5a316..0000000
--- a/FlexPMD/flex-pmd-core/.p4ignore
+++ /dev/null
@@ -1 +0,0 @@
-target
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/.pmd
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/.pmd b/FlexPMD/flex-pmd-core/.pmd
deleted file mode 100644
index b5c19d9..0000000
--- a/FlexPMD/flex-pmd-core/.pmd
+++ /dev/null
@@ -1,25 +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>
- <useProjectRuleSet>false</useProjectRuleSet>
- <ruleSetFile>../flex-pmd-parent/pmd.xml</ruleSetFile>
- <includeDerivedFiles>false</includeDerivedFiles>
- <violationsAsErrors>true</violationsAsErrors>
-</pmd>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/pom.xml
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/pom.xml b/FlexPMD/flex-pmd-core/pom.xml
deleted file mode 100644
index 1c9b175..0000000
--- a/FlexPMD/flex-pmd-core/pom.xml
+++ /dev/null
@@ -1,105 +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-core</artifactId>
- <name>Adobe Flex PMD Core</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>
- <doxia-core.version>1.0-alpha-4</doxia-core.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>doxia</groupId>
- <artifactId>doxia-core</artifactId>
- <version>${doxia-core.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>flex-pmd-ruleset-api</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <!-- Test dependencies -->
- <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>
- <dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>flex-pmd-ruleset</artifactId>
- <version>${project.parent.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <testResources>
- <testResource>
- <directory>${project.build.directory}/test/generated-resources</directory>
- </testResource>
- <testResource>
- <directory>${basedir}/src/test/resources</directory>
- </testResource>
- </testResources>
- <resources>
- <resource>
- <directory>${project.build.directory}/test/generated-resources</directory>
- </resource>
- </resources>
-
- <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,**/*.xml</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-core/src/main/java/com/adobe/ac/pmd/FlexPmdParameters.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/FlexPmdParameters.java b/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/FlexPmdParameters.java
deleted file mode 100644
index 5bab526..0000000
--- a/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/FlexPmdParameters.java
+++ /dev/null
@@ -1,123 +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.pmd;
-
-import java.io.File;
-import java.util.List;
-
-public class FlexPmdParameters
-{
- private final String excludePackage;
- private final boolean failOnError;
- private final boolean failOnRuleViolation;
- private final File outputDirectory;
- private final File ruleSet;
- private final File source;
- private final List< File > sourceList;
-
- public FlexPmdParameters( final String excludePackageToBeSet,
- final boolean failOnErrorToBeSet,
- final boolean failOnRuleViolationToBeSet,
- final File outputDirectoryToBeSet,
- final File ruleSetToBeSet,
- final File sourceToBeSet )
- {
- this( excludePackageToBeSet,
- failOnErrorToBeSet,
- failOnRuleViolationToBeSet,
- outputDirectoryToBeSet,
- ruleSetToBeSet,
- sourceToBeSet,
- null );
- }
-
- public FlexPmdParameters( final String excludePackageToBeSet,
- final boolean failOnErrorToBeSet,
- final boolean failOnRuleViolationToBeSet,
- final File outputDirectoryToBeSet,
- final File ruleSetToBeSet,
- final File sourceToBeSet,
- final List< File > sourceListToBeSet )
- {
- super();
- excludePackage = excludePackageToBeSet;
- failOnError = failOnErrorToBeSet;
- failOnRuleViolation = failOnRuleViolationToBeSet;
- outputDirectory = outputDirectoryToBeSet;
- ruleSet = ruleSetToBeSet;
- source = sourceToBeSet;
- sourceList = sourceListToBeSet;
- }
-
- public FlexPmdParameters( final String excludePackageToBeSet,
- final File outputDirectoryToBeSet,
- final File ruleSetToBeSet,
- final File sourceToBeSet )
- {
- this( excludePackageToBeSet, false, false, outputDirectoryToBeSet, ruleSetToBeSet, sourceToBeSet, null );
- }
-
- public FlexPmdParameters( final String excludePackageToBeSet,
- final File outputDirectoryToBeSet,
- final File ruleSetToBeSet,
- final File sourceToBeSet,
- final List< File > sourceListToBeSet )
- {
- this( excludePackageToBeSet,
- false,
- false,
- outputDirectoryToBeSet,
- ruleSetToBeSet,
- sourceToBeSet,
- sourceListToBeSet );
- }
-
- public final String getExcludePackage()
- {
- return excludePackage;
- }
-
- public final File getOutputDirectory()
- {
- return outputDirectory;
- }
-
- public final File getRuleSet()
- {
- return ruleSet;
- }
-
- public final File getSource()
- {
- return source;
- }
-
- public List< File > getSourceList()
- {
- return sourceList;
- }
-
- public final boolean isFailOnError()
- {
- return failOnError;
- }
-
- public boolean isFailOnRuleViolation()
- {
- return failOnRuleViolation;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/FlexPmdViolations.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/FlexPmdViolations.java b/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/FlexPmdViolations.java
deleted file mode 100644
index 607610d..0000000
--- a/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/FlexPmdViolations.java
+++ /dev/null
@@ -1,244 +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.pmd;
-
-import java.io.File;
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import net.sourceforge.pmd.PMDException;
-import net.sourceforge.pmd.Rule;
-import net.sourceforge.pmd.RuleReference;
-import net.sourceforge.pmd.RuleSet;
-
-import com.adobe.ac.pmd.files.FileSetUtils;
-import com.adobe.ac.pmd.files.IFlexFile;
-import com.adobe.ac.pmd.files.impl.FileUtils;
-import com.adobe.ac.pmd.nodes.IPackage;
-import com.adobe.ac.pmd.rules.core.IFlexAstRule;
-import com.adobe.ac.pmd.rules.core.IFlexRule;
-import com.adobe.ac.utils.StackTraceUtils;
-
-public class FlexPmdViolations implements Serializable
-{
- private static final Logger LOGGER;
-
- /**
- *
- */
- private static final long serialVersionUID = -3683680443330143504L;
-
- static
- {
- LOGGER = Logger.getLogger( FlexPmdViolations.class.getName() );
- }
-
- private Map< String, IPackage > asts;
- private Map< String, IFlexFile > files;
- private boolean hasBeenComputed;
- private final Map< String, IFlexRule > rules;
- private final Map< IFlexRule, Long > ruleSpeeds;
- private final Map< IFlexFile, List< IFlexViolation > > violations;
-
- public FlexPmdViolations()
- {
- violations = new LinkedHashMap< IFlexFile, List< IFlexViolation > >();
- rules = new LinkedHashMap< String, IFlexRule >();
- ruleSpeeds = new LinkedHashMap< IFlexRule, Long >();
- hasBeenComputed = false;
- }
-
- public final void computeViolations( final File source,
- final List< File > sourceList,
- final RuleSet ruleSet,
- final String packageToExclude ) throws PMDException
- {
- hasBeenComputed = true;
-
- if ( ruleSet != null )
- {
- computeRules( ruleSet );
- computeFiles( source,
- sourceList,
- packageToExclude,
- ruleSet.getExcludePatterns() );
- computeAsts();
- processRules();
- sortViolations();
- }
- }
-
- public final Map< IFlexFile, List< IFlexViolation >> getViolations()
- {
- return violations;
- }
-
- public final boolean hasViolationsBeenComputed()
- {
- return hasBeenComputed;
- }
-
- private void computeAsts() throws PMDException
- {
- LOGGER.info( "computing Asts" );
-
- final long startTime = System.currentTimeMillis();
- asts = FileSetUtils.computeAsts( files );
-
- LOGGER.info( "computed Asts in "
- + ( System.currentTimeMillis() - startTime ) + " ms" );
- }
-
- private void computeFiles( final File source,
- final List< File > sourceList,
- final String packageToExclude,
- final List< String > excludePatterns ) throws PMDException
- {
- LOGGER.info( "computing FilesList" );
-
- final long startTime = System.currentTimeMillis();
-
- files = FileUtils.computeFilesList( source,
- sourceList,
- packageToExclude,
- excludePatterns );
- LOGGER.info( "computed FilesList in "
- + ( System.currentTimeMillis() - startTime ) + " ms" );
- }
-
- private void computeRules( final RuleSet ruleSet )
- {
- LOGGER.info( "computing RulesList" );
-
- final long startTime = System.currentTimeMillis();
- Set< String > excludes = new HashSet< String >( ruleSet.getExcludePatterns() );
-
- for ( Rule rule : ruleSet.getRules() )
- {
- while ( rule instanceof RuleReference )
- {
- excludes = ( ( RuleReference ) rule ).getRuleSetReference().getExcludes();
- rule = ( ( RuleReference ) rule ).getRule();
- }
- final IFlexRule flexRule = ( IFlexRule ) rule;
-
- if ( excludes != null
- && !excludes.isEmpty() )
- {
- flexRule.setExcludes( excludes );
- }
- rules.put( flexRule.getRuleName(),
- flexRule );
- }
-
- LOGGER.info( "computed RulesList in "
- + ( System.currentTimeMillis() - startTime ) + " ms" );
- }
-
- private void processFile( final IFlexRule currentRule,
- final IFlexFile currentFile )
- {
- try
- {
- final String fullyQualifiedName = currentFile.getFullyQualifiedName();
- final IPackage ast = currentRule instanceof IFlexAstRule ? asts.get( fullyQualifiedName )
- : null;
- final List< IFlexViolation > foundViolations = currentRule.processFile( currentFile,
- ast,
- files );
-
- if ( !foundViolations.isEmpty() )
- {
- if ( violations.containsKey( currentFile ) )
- {
- violations.get( currentFile ).addAll( foundViolations );
- }
- else
- {
- violations.put( currentFile,
- foundViolations );
- }
- }
- }
- catch ( final Exception e )
- {
- LOGGER.warning( StackTraceUtils.print( currentFile.getFullyQualifiedName(),
- e ) );
- }
- }
-
- private void processRule( final IFlexRule currentRule )
- {
- LOGGER.fine( "Processing "
- + currentRule.getRuleName() + "..." );
-
- for ( final Entry< String, IFlexFile > currentFileEntry : files.entrySet() )
- {
- processFile( currentRule,
- currentFileEntry.getValue() );
- }
- }
-
- private void processRule( final String currentRuleName,
- final IFlexRule currentRule )
- {
- final long startTime = System.currentTimeMillis();
-
- processRule( currentRule );
- final long ellapsedTime = System.currentTimeMillis()
- - startTime;
-
- if ( LOGGER.isLoggable( Level.FINE ) )
- {
- LOGGER.fine( "rule "
- + currentRuleName + " computed in " + ellapsedTime + "ms" );
- }
- if ( LOGGER.isLoggable( Level.FINER ) )
- {
- ruleSpeeds.put( currentRule,
- ellapsedTime );
- }
- }
-
- private void processRules()
- {
- for ( final Entry< String, IFlexRule > currentRuleEntry : rules.entrySet() )
- {
- processRule( currentRuleEntry.getKey(),
- currentRuleEntry.getValue() );
- }
- }
-
- private void sortViolations()
- {
- for ( final Entry< String, IFlexFile > entry : files.entrySet() )
- {
- if ( violations.containsKey( entry.getValue() ) )
- {
- Collections.sort( violations.get( entry.getValue() ) );
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/AbstractFlexPmdEngine.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/AbstractFlexPmdEngine.java b/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/AbstractFlexPmdEngine.java
deleted file mode 100644
index be8f747..0000000
--- a/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/AbstractFlexPmdEngine.java
+++ /dev/null
@@ -1,199 +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.pmd.engines;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URISyntaxException;
-import java.util.List;
-import java.util.logging.Logger;
-
-import net.sourceforge.pmd.PMDException;
-import net.sourceforge.pmd.RuleSet;
-import net.sourceforge.pmd.RuleSetFactory;
-
-import org.apache.commons.lang.StringUtils;
-import org.codehaus.plexus.util.IOUtil;
-
-import com.adobe.ac.pmd.FlexPmdParameters;
-import com.adobe.ac.pmd.FlexPmdViolations;
-import com.adobe.ac.pmd.IFlexViolation;
-import com.adobe.ac.utils.StackTraceUtils;
-
-public abstract class AbstractFlexPmdEngine
-{
- private static final Logger LOGGER = Logger.getLogger( AbstractFlexPmdEngine.class.getName() );
-
- private static int computeViolationNumber( final FlexPmdViolations flexPmdViolations )
- {
- int foundViolations = 0;
- for ( final List< IFlexViolation > violations : flexPmdViolations.getViolations().values() )
- {
- foundViolations += violations.size();
- }
- LOGGER.info( "Violations number found: "
- + foundViolations );
- return foundViolations;
- }
-
- private static File extractDefaultRuleSet() throws URISyntaxException,
- IOException
- {
- final String rulesetURI = "/com/adobe/ac/pmd/default_flex.xml";
- final InputStream resourceAsStream = AbstractFlexPmdEngine.class.getResourceAsStream( rulesetURI );
- final File temporaryRuleset = File.createTempFile( "default_flex",
- ".xml" );
- temporaryRuleset.deleteOnExit();
- final FileOutputStream writter = new FileOutputStream( temporaryRuleset );
- IOUtil.copy( resourceAsStream,
- writter );
-
- resourceAsStream.close();
- return temporaryRuleset;
- }
-
- private final File outputDirectory;
- private final String packageToExclude;
- private RuleSet ruleSet;
- private final File source;
- private final List< File > sourceList;
-
- public AbstractFlexPmdEngine( final FlexPmdParameters parameters )
- {
- super();
-
- source = parameters.getSource();
- sourceList = parameters.getSourceList();
- outputDirectory = parameters.getOutputDirectory();
- packageToExclude = parameters.getExcludePackage();
- try
- {
- ruleSet = loadRuleset( parameters.getRuleSet() );
- }
- catch ( final URISyntaxException e )
- {
- LOGGER.warning( StackTraceUtils.print( e ) );
- }
- catch ( final IOException e )
- {
- LOGGER.warning( StackTraceUtils.print( e ) );
- }
- }
-
- /**
- * @param flexPmdViolations
- * @return The number of violations with the given ruleset and the result
- * wrapper in case of reuse
- * @throws PMDException
- * @throws URISyntaxException
- * @throws IOException
- */
- public final void executeReport( final FlexPmdViolations flexPmdViolations ) throws PMDException
- {
- if ( source == null
- && sourceList == null )
- {
- throw new PMDException( "unspecified sourceDirectory" );
- }
- if ( outputDirectory == null )
- {
- throw new PMDException( "unspecified outputDirectory" );
- }
-
- if ( ruleSet != null )
- {
- if ( !flexPmdViolations.hasViolationsBeenComputed() )
- {
- computeViolations( flexPmdViolations );
- }
- computeViolationNumber( flexPmdViolations );
- writeAnyReport( flexPmdViolations );
- }
- }
-
- public final RuleSet getRuleSet()
- {
- return ruleSet;
- }
-
- protected File getOutputDirectory()
- {
- return outputDirectory;
- }
-
- protected abstract void writeReport( final FlexPmdViolations pmd ) throws PMDException;
-
- private void computeViolations( final FlexPmdViolations flexPmdViolations ) throws PMDException
- {
- final long startTime = System.currentTimeMillis();
-
- flexPmdViolations.computeViolations( source,
- sourceList,
- ruleSet,
- packageToExclude );
- final long ellapsedTime = System.currentTimeMillis()
- - startTime;
- LOGGER.info( "It took "
- + ellapsedTime + "ms to compute violations" );
- }
-
- private File extractRuleset( final File ruleSetFile ) throws URISyntaxException,
- IOException
- {
- return ruleSetFile == null ? extractDefaultRuleSet()
- : ruleSetFile;
- }
-
- private String getReportType()
- {
- return StringUtils.substringBefore( StringUtils.substringAfter( getClass().getName(),
- "FlexPmd" ),
- "Engine" );
- }
-
- private RuleSet loadRuleset( final File ruleSetFile ) throws URISyntaxException,
- IOException
- {
- final File realRuleSet = extractRuleset( ruleSetFile );
- final FileInputStream inputStream = new FileInputStream( realRuleSet );
- final RuleSet loadedRuleSet = new RuleSetFactory().createRuleSet( inputStream );
-
- LOGGER.info( "Ruleset: "
- + realRuleSet.getAbsolutePath() );
- LOGGER.info( "Rules number in the ruleSet: "
- + loadedRuleSet.getRules().size() );
- inputStream.close();
-
- return loadedRuleSet;
- }
-
- private void writeAnyReport( final FlexPmdViolations flexPmdViolations ) throws PMDException
- {
- long startTime;
- long ellapsedTime;
- startTime = System.currentTimeMillis();
- writeReport( flexPmdViolations );
- ellapsedTime = System.currentTimeMillis()
- - startTime;
-
- LOGGER.info( "It took "
- + ellapsedTime + "ms to write the " + getReportType() + " report" );
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/FlexPMDFormat.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/FlexPMDFormat.java b/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/FlexPMDFormat.java
deleted file mode 100644
index f3f11d4..0000000
--- a/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/FlexPMDFormat.java
+++ /dev/null
@@ -1,35 +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.pmd.engines;
-
-public enum FlexPMDFormat
-{
- HTML("flexPmd.html"), XML("pmd.xml");
-
- private final String name;
-
- private FlexPMDFormat( final String formatName )
- {
- name = formatName;
- }
-
- @Override
- public String toString()
- {
- return name;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/FlexPmdXmlEngine.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/FlexPmdXmlEngine.java b/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/FlexPmdXmlEngine.java
deleted file mode 100644
index 4835993..0000000
--- a/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/FlexPmdXmlEngine.java
+++ /dev/null
@@ -1,171 +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.pmd.engines;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.logging.Logger;
-
-import net.sourceforge.pmd.PMDException;
-
-import com.adobe.ac.pmd.FlexPmdParameters;
-import com.adobe.ac.pmd.FlexPmdViolations;
-import com.adobe.ac.pmd.IFlexViolation;
-import com.adobe.ac.pmd.files.IFlexFile;
-
-public class FlexPmdXmlEngine extends AbstractFlexPmdEngine
-{
- private static final Logger LOGGER = Logger.getLogger( FlexPmdXmlEngine.class.getName() );
-
- public FlexPmdXmlEngine( final FlexPmdParameters parameters ) throws URISyntaxException,
- IOException
- {
- super( parameters );
- }
-
- @Override
- protected final void writeReport( final FlexPmdViolations pmd ) throws PMDException
- {
- final File realOutputDirectory = getOutputDirectory();
- final String filePath = realOutputDirectory.getAbsoluteFile()
- + File.separator + FlexPMDFormat.XML.toString();
-
- makeSureOutputDirectoryExists( realOutputDirectory );
-
- Writer writter = null;
- try
- {
- LOGGER.finest( "Start writting XML report" );
- LOGGER.info( "Creating report in <"
- + filePath + ">" );
-
- writter = new OutputStreamWriter( new FileOutputStream( filePath ), "UTF-8" );
- writeReportHeader( writter );
- writeFileViolations( pmd,
- writter );
- writeReportFooter( writter );
- writter.close();
- }
- catch ( final IOException e )
- {
- throw new PMDException( "Error creating file "
- + filePath, e );
- }
- finally
- {
- finalizeReport( writter );
- }
- }
-
- private void finalizeReport( final Writer writter )
- {
- LOGGER.finest( "End writting XML report" );
-
- if ( writter != null )
- {
- try
- {
- LOGGER.finest( "Closing the XML writter" );
- writter.close();
- }
- catch ( final IOException e )
- {
- LOGGER.warning( Arrays.toString( e.getStackTrace() ) );
- }
- LOGGER.finest( "Closed the XML writter" );
- }
- }
-
- private void formatFileFiolation( final Writer writter,
- final IFlexFile sourceFile,
- final Collection< IFlexViolation > violations,
- final String sourceFilePath ) throws IOException
- {
- if ( !violations.isEmpty() )
- {
- if ( sourceFilePath.charAt( 2 ) == ':' )
- {
- writter.write( " <file name=\""
- + sourceFilePath.substring( 1,
- sourceFilePath.length() ) + "\">" + getNewLine() );
- }
- else
- {
- writter.write( " <file name=\""
- + sourceFilePath + "\">" + getNewLine() );
-
- }
- for ( final IFlexViolation violation : violations )
- {
- writter.write( violation.toXmlString( sourceFile,
- violation.getRule().getRuleSetName() ) );
- }
- writter.write( " </file>"
- + getNewLine() );
- }
- }
-
- private String getNewLine()
- {
- return System.getProperty( "line.separator" );
- }
-
- private void makeSureOutputDirectoryExists( final File realOutputDirectory )
- {
- if ( !realOutputDirectory.exists()
- && !realOutputDirectory.mkdirs() )
- {
- LOGGER.severe( "Unable to create an output folder" );
- }
- }
-
- private void writeFileViolations( final FlexPmdViolations pmd,
- final Writer writter ) throws IOException
- {
- for ( final IFlexFile sourceFile : pmd.getViolations().keySet() )
- {
- final Collection< IFlexViolation > violations = pmd.getViolations().get( sourceFile );
- final String sourceFilePath = sourceFile.getFilePath();
-
- formatFileFiolation( writter,
- sourceFile,
- violations,
- sourceFilePath );
- }
- }
-
- private void writeReportFooter( final Writer writter ) throws IOException
- {
- writter.write( "</pmd>"
- + getNewLine() );
- }
-
- private void writeReportHeader( final Writer writter ) throws IOException
- {
- writter.write( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- + getNewLine() );
- writter.write( "<pmd version=\"4.2.1\" timestamp=\""
- + new Date().toString() + "\">" + getNewLine() );
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/PmdEngineUtils.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/PmdEngineUtils.java b/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/PmdEngineUtils.java
deleted file mode 100644
index 7c48a9e..0000000
--- a/FlexPMD/flex-pmd-core/src/main/java/com/adobe/ac/pmd/engines/PmdEngineUtils.java
+++ /dev/null
@@ -1,66 +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.pmd.engines;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Map.Entry;
-
-import com.adobe.ac.pmd.FlexPmdViolations;
-import com.adobe.ac.pmd.IFlexViolation;
-import com.adobe.ac.pmd.files.IFlexFile;
-import com.adobe.ac.pmd.rules.core.ViolationPriority;
-
-public final class PmdEngineUtils
-{
- public static String findFirstViolationError( final FlexPmdViolations violations )
- {
- final StringBuffer buffer = new StringBuffer();
- final String message = "An error violation has been found on the file {0} at "
- + "line {1}, with the rule \"{2}\": {3}";
- final MessageFormat form = new MessageFormat( message );
-
- for ( final Entry< IFlexFile, List< IFlexViolation >> violatedFile : violations.getViolations()
- .entrySet() )
- {
- for ( final IFlexViolation violation : violatedFile.getValue() )
- {
- if ( violation.getRule().getPriority() == Integer.parseInt( ViolationPriority.HIGH.toString() ) )
- {
- final String[] formatArgument = computeArgumentFormat( violation );
- buffer.append( form.format( formatArgument ) );
- buffer.append( '\n' );
- }
- }
- }
- return buffer.toString();
- }
-
- private static String[] computeArgumentFormat( final IFlexViolation violation )
- {
- final String[] formatArgument = new String[]
- { violation.getFilename(),
- String.valueOf( violation.getBeginLine() ),
- violation.getRule().getRuleClass(),
- violation.getRuleMessage() };
- return formatArgument;
- }
-
- private PmdEngineUtils()
- {
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/AbstractEntireRulesetTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/AbstractEntireRulesetTest.java b/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/AbstractEntireRulesetTest.java
deleted file mode 100644
index 9c5102f..0000000
--- a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/AbstractEntireRulesetTest.java
+++ /dev/null
@@ -1,87 +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.pmd;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import net.sourceforge.pmd.PMDException;
-
-import org.junit.Test;
-
-import com.adobe.ac.pmd.engines.FlexPmdXmlEngine;
-
-import junit.framework.TestCase;
-
-public abstract class AbstractEntireRulesetTest extends TestCase
-{
-
- protected static final String OUTPUT_DIRECTORY_URL = "target/report/";
-
- public AbstractEntireRulesetTest()
- {
- super();
- }
-
- protected abstract int getRulesNb();
-
- protected abstract int getViolatedFilesNb();
-
- protected abstract String getRuleSetPath();
-
- public AbstractEntireRulesetTest( String name )
- {
- super( name );
- }
-
- @Test
- public void testLoadRuleSet() throws URISyntaxException,
- PMDException,
- IOException
- {
- final File sourceDirectory = new File( getClass().getResource( "/test" ).toURI().getPath() );
- final URL ruleSetUrl = getClass().getResource( getRuleSetPath() );
-
- assertNotNull( "RuleSet has not been found",
- ruleSetUrl );
-
- assertNotNull( "RuleSet has not been found",
- ruleSetUrl.toURI() );
-
- assertNotNull( "RuleSet has not been found",
- ruleSetUrl.toURI().getPath() );
-
- final File outputDirectory = new File( OUTPUT_DIRECTORY_URL );
- final File ruleSetFile = new File( ruleSetUrl.toURI().getPath() );
- final FlexPmdXmlEngine engine = new FlexPmdXmlEngine( new FlexPmdParameters( "",
- outputDirectory,
- ruleSetFile,
- sourceDirectory ) );
- final FlexPmdViolations flexPmdViolations = new FlexPmdViolations();
-
- engine.executeReport( flexPmdViolations );
-
- assertEquals( "Number of rules found is not correct",
- getRulesNb(),
- engine.getRuleSet().size() );
- assertEquals( getViolatedFilesNb(),
- flexPmdViolations.getViolations().size() );
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/AllInOneRulesetTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/AllInOneRulesetTest.java b/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/AllInOneRulesetTest.java
deleted file mode 100644
index 62f1484..0000000
--- a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/AllInOneRulesetTest.java
+++ /dev/null
@@ -1,64 +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.pmd;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import net.sourceforge.pmd.PMDException;
-
-import org.junit.Test;
-
-import com.adobe.ac.pmd.engines.FlexPmdXmlEngine;
-
-public class AllInOneRulesetTest extends AbstractEntireRulesetTest
-{
- @Test
- public void testLoadUncorrectRuleSet() throws URISyntaxException,
- PMDException,
- IOException
- {
- final File sourceDirectory = new File( getClass().getResource( "/test" ).toURI().getPath() );
- final File outputDirectory = new File( OUTPUT_DIRECTORY_URL );
-
- final FlexPmdXmlEngine engine = new FlexPmdXmlEngine( new FlexPmdParameters( "",
- outputDirectory,
- new File( "nonExist" ),
- sourceDirectory ) );
-
- engine.executeReport( new FlexPmdViolations() );
- }
-
- @Override
- protected String getRuleSetPath()
- {
- return "/allInOneRuleset.xml";
- }
-
- @Override
- protected int getRulesNb()
- {
- return 43;
- }
-
- @Override
- protected int getViolatedFilesNb()
- {
- return 50;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/AllInOneWithExclusionRulesetTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/AllInOneWithExclusionRulesetTest.java b/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/AllInOneWithExclusionRulesetTest.java
deleted file mode 100644
index 10322f1..0000000
--- a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/AllInOneWithExclusionRulesetTest.java
+++ /dev/null
@@ -1,38 +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.pmd;
-
-public class AllInOneWithExclusionRulesetTest extends AbstractEntireRulesetTest
-{
- @Override
- protected String getRuleSetPath()
- {
- return "/allInOneWithExclusionRuleset.xml";
- }
-
- @Override
- protected int getRulesNb()
- {
- return 43;
- }
-
- @Override
- protected int getViolatedFilesNb()
- {
- return 36;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/FlexPmdParametersTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/FlexPmdParametersTest.java b/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/FlexPmdParametersTest.java
deleted file mode 100644
index 94b1ff9..0000000
--- a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/FlexPmdParametersTest.java
+++ /dev/null
@@ -1,47 +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.pmd;
-
-import java.io.File;
-import java.util.ArrayList;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-
-public class FlexPmdParametersTest
-{
- @Test
- public void testFlexPmdParametersStringBooleanBooleanFileFileFile()
- {
- final FlexPmdParameters parameters = new FlexPmdParameters( "", true, true, null, null, null );
-
- Assert.assertTrue( parameters.isFailOnError() );
- Assert.assertTrue( parameters.isFailOnRuleViolation() );
- }
-
- @Test
- public void testFlexPmdParametersStringFileFileFileListOfFile()
- {
- final File file = new File( "" );
- final ArrayList< File > sourceList = new ArrayList< File >();
- final FlexPmdParameters parameters = new FlexPmdParameters( "", file, file, file, sourceList );
-
- Assert.assertEquals( sourceList,
- parameters.getSourceList() );
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/FlexPmdXmlEngineTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/FlexPmdXmlEngineTest.java b/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/FlexPmdXmlEngineTest.java
deleted file mode 100644
index d84641c..0000000
--- a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/FlexPmdXmlEngineTest.java
+++ /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.
- */
-package com.adobe.ac.pmd;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.SchemaFactory;
-
-import org.xml.sax.SAXException;
-
-import com.adobe.ac.pmd.engines.AbstractFlexPmdEngine;
-import com.adobe.ac.pmd.engines.AbstractTestFlexPmdEngineTest;
-import com.adobe.ac.pmd.engines.FlexPMDFormat;
-import com.adobe.ac.pmd.engines.FlexPmdXmlEngine;
-
-public class FlexPmdXmlEngineTest extends AbstractTestFlexPmdEngineTest
-{
- private static final String OUTPUT_DIRECTORY_URL = "target/report/";
-
- public FlexPmdXmlEngineTest( final String name )
- {
- super( name );
- }
-
- @Override
- protected AbstractFlexPmdEngine getFlexPmdEngine( final File sourceDirectory,
- final File outputDirectory,
- final String packageToExclude,
- final File ruleSet ) throws URISyntaxException,
- IOException
- {
- return new FlexPmdXmlEngine( new FlexPmdParameters( packageToExclude,
- outputDirectory,
- ruleSet,
- sourceDirectory ) );
- }
-
- @Override
- protected void onTestExecuteReportDone()
- {
- final File outXmlReport = new File( OUTPUT_DIRECTORY_URL
- + FlexPMDFormat.XML.toString() );
-
- final SchemaFactory factory = SchemaFactory.newInstance( "http://www.w3.org/2001/XMLSchema" );
-
- final URL schemaResource = getClass().getResource( "/pmd.xsd" );
-
- assertNotNull( "pmd.xsd is not loaded",
- schemaResource );
-
- try
- {
- factory.newSchema( schemaResource ).newValidator().validate( new StreamSource( outXmlReport ) );
- }
- catch ( final SAXException e )
- {
- fail( e.getMessage() );
- }
- catch ( final IOException e )
- {
- fail( e.getMessage() );
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/LoadRulesetWithNonUTF8CharTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/LoadRulesetWithNonUTF8CharTest.java b/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/LoadRulesetWithNonUTF8CharTest.java
deleted file mode 100644
index 69eb795..0000000
--- a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/LoadRulesetWithNonUTF8CharTest.java
+++ /dev/null
@@ -1,38 +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.pmd;
-
-public class LoadRulesetWithNonUTF8CharTest extends AbstractEntireRulesetTest
-{
- @Override
- protected String getRuleSetPath()
- {
- return "/broken_pmd.xml";
- }
-
- @Override
- protected int getRulesNb()
- {
- return 70;
- }
-
- @Override
- protected int getViolatedFilesNb()
- {
- return 66;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/engines/AbstractTestFlexPmdEngineTest.java
----------------------------------------------------------------------
diff --git a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/engines/AbstractTestFlexPmdEngineTest.java b/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/engines/AbstractTestFlexPmdEngineTest.java
deleted file mode 100644
index df495f5..0000000
--- a/FlexPMD/flex-pmd-core/src/test/java/com/adobe/ac/pmd/engines/AbstractTestFlexPmdEngineTest.java
+++ /dev/null
@@ -1,73 +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.pmd.engines;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import junit.framework.TestCase;
-import net.sourceforge.pmd.PMDException;
-
-import org.junit.Test;
-import org.xml.sax.SAXException;
-
-import com.adobe.ac.pmd.FlexPmdViolations;
-
-public abstract class AbstractTestFlexPmdEngineTest extends TestCase
-{
- private static final String OUTPUT_DIRECTORY_URL = "target/report/";
-
- public AbstractTestFlexPmdEngineTest( final String name )
- {
- super( name );
- }
-
- @Test
- public final void testExecuteReport() throws PMDException,
- SAXException,
- URISyntaxException,
- IOException
- {
- final URL sourceDirectoryResource = getClass().getResource( "/test" );
-
- assertNotNull( "Source directory is not found as a resource",
- sourceDirectoryResource );
-
- assertNotNull( "Source directory is not found as a resource",
- sourceDirectoryResource.toURI() );
-
- final File sourceDirectory = new File( sourceDirectoryResource.toURI().getPath() );
- final File outputDirectory = new File( OUTPUT_DIRECTORY_URL );
-
- getFlexPmdEngine( sourceDirectory,
- outputDirectory,
- "",
- null ).executeReport( new FlexPmdViolations() );
-
- onTestExecuteReportDone();
- }
-
- protected abstract AbstractFlexPmdEngine getFlexPmdEngine( final File sourceDirectory,
- final File outputDirectory,
- final String packageToExclude,
- final File ruleSet ) throws URISyntaxException,
- IOException;
-
- protected abstract void onTestExecuteReportDone();
-}
\ No newline at end of file