Comments (6)
PMD uses regular expressions to define the include and exclude pattern and (unfortunately) silently ignores an invalid pattern. In your case both the exclude and the includes pattern are invalid and that is why PMD analyses the SQL files in the first place. You might want to change your patterns to the following:
<exclude-pattern>.*</exclude-pattern>
<include-pattern>.*\.java$</include-pattern>
I tried to reproduce the problem with my own SQL files but was unable to do so. My currently best guess for the reason why mvn pmd:pmd
runs without issue and eclipse-pmd hangs is that mvn pmd:pmd
does not actually analyse the SQL files. Please make sure that
- your maven configuration uses PMD 5.1.1. The maven-pmd-plugin currently uses PMD 5.0.5 and SQL support was only introduced with PMD 5.1.
- your maven configuration includes all files. The maven-pmd-plugin default include pattern is */.java which excludes your SQL files.
- you don't use any include/exclude patterns in your PMD rule set file.
Your maven configuration should look like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.1</version>
<configuration>
<targetJdk>1.7</targetJdk>
<rulesets>
<ruleset>${basedir}/pmd.xml</ruleset>
</rulesets>
<verbose>true</verbose>
<includes>
<include>**/*</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>5.1.1</version>
</dependency>
</dependencies>
</plugin>
Please let me know if the above maven configuration also hangs when analysing your SQL files. This would help me find out if this is a problem with eclipse-pmd or PMD itself.
from eclipse-pmd.
Thanks for looking into this. Indeed I was mistakenly using Ant-like patterns in my rule set.
I've added the include to my maven-pmd-plugin configuration, leaving the rest as it was. Per mvn help:effective-pom
:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/sql</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/it/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.1</version>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>5.1.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<configuration>
<targetJdk>1.6</targetJdk>
<rulesets>
<ruleset>file:///Users/ibrandt/myproject/db/../pmd.xml</ruleset>
</rulesets>
<includes>
<include>**/*</include>
</includes>
<includeTests>true</includeTests>
<verbose>true</verbose>
</configuration>
</plugin>
[...]
I removed the exclude and include from my rule set:
<?xml version="1.0" encoding="UTF-8" ?>
<ruleset name="myruleset" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>My Ruleset</description>
<rule ref="rulesets/java/basic.xml" />
<rule ref="rulesets/java/braces.xml" />
[...]
It doesn't seem to get hung up on the SQL:
$ mvn pmd:pmd
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DB 7.2.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-pmd-plugin:3.1:pmd (default-cli) @ db ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.238s
[INFO] Finished at: Sun Jul 13 08:53:55 PDT 2014
[INFO] Final Memory: 18M/81M
[INFO] ------------------------------------------------------------------------
Of note the SQL files are in an added resource folder, "src/main/sql". This is also a source folder in Eclipse. Might the maven-pmd-plugin not scan added resource folders, where eclipse-pmd does on account of them being source folders?
from eclipse-pmd.
I added the correct exclude patterns to my rule set:
<exclude-pattern>.*</exclude-pattern>
<include-pattern>.*\.java$</include-pattern>
I can now enable the PMD nature on my DB project, and the build completes just fine.
from eclipse-pmd.
I don't know if the maven-pmd-plugin scans resource folders. You could run PMD from the command line and specify the resource folder explicitly with -d <path>
to make sure the SQL files are included.
from eclipse-pmd.
I'm going to go ahead and close this as eclipse-pmd is now working fine for me with .sql files properly excluded. I assume the root performance issue is with the PLSQLParser
upstream. I'll file an issue for that with PMD directly.
from eclipse-pmd.
The PLSQL Parser was inherited / migrated from PLDoc where it concentrates on PLSQL, but tries to support other commands that might be found in a SQL script file:- SQL*Plus, DDL, GRANTS, etc.
It does attempt to support Table and View DDL, but that support has not been maintained or updated, simply because other tools do Table and View documentation much, much better - I use maven-schemaspy-plugin .
I infer from a look at the stack trace that the parser is having problems parsing a View DDL statement
"
...
net.sourceforge.pmd.lang.plsql.ast.PLSQLParser.View
...
"
I will have a look at the parser - it would help if you could post the problem View definition.
from eclipse-pmd.
Related Issues (20)
- An error occurred while automatically activating bundle ch.acanda.eclipse.pmd.core HOT 3
- Eclipse Neon (4.6) install through marked but nothing shows up HOT 2
- Diff to pmd/pmd-eclipse-plugin HOT 3
- Improve ruleset feedback HOT 2
- Remote ruleset: rules caching/refresh frequency? HOT 2
- Automatically update workspace relative configurations when the project name changes
- The rule set configuration at the given location is invalid HOT 9
- Eclipse PDT. Cannot change PMD nature of project <projectName> HOT 2
- New releases HOT 3
- Release 1.9 HOT 9
- XML parsing problem in Eclipse Oxygen HOT 1
- NoClassDefFoundError with version 1.12 in Eclipse Photon
- pmd can not find my enum class (configure auxclasspath) HOT 2
- eclipse-pmd 1.14 depends on pmd 6.6.0 and asm 6.1.1, but pmd 6.6.0 depends on asm 6.2 HOT 1
- Cannot use apex rules HOT 1
- Problem installing on STS 4 HOT 2
- Bug: After importing an exising project, no more PMD checks were performed HOT 2
- Bug: ruleset of other projects are also listed HOT 2
- Developer should be able to exclude violation HOT 4
- Use Rulesets with unkonwn rules (from newer PMD versions) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eclipse-pmd.