Menu
  • HOME
  • TAGS

Can't get PMD 5.2.1 to check JSP files?

java,jsp,maven,pmd

http://maven.apache.org/plugins/maven-pmd-plugin/pmd-mojo.html#language There is no way currently to have it check for "jsp" as the source type without modifying the plugin. You might want to try maven-exec with direct command line options of PMD as short-cut. http://mojo.codehaus.org/exec-maven-plugin/ http:://pmd.sourceforge.net/pmd-5.2.1/usage/running.html...

Why shouldn't all function arguments be declared final?

java,oop,pmd

I can think of only 2 reasons not to make a parameter final: to save the use of a local variable if you need to overwrite the parameter's value in some edge cases (this is the reason you pointed out) to save 6 characters per parameter (not a good enough...

Save output from PMD Eclipse plugin

java,eclipse,pmd

This functionality is a bit hidden, but it exists. Go to "Window -> Preferences -> PMD -> Reports" and select the report format, you want, e.g. "text". Right-click on the project and select "PMD -> Check Code". Right-click on the project and select "PMD -> Generate Reports". Now, you should...

PMD plugin fails after upgrading Sonarqube to 4.5.4

java,ant,sonarqube,pmd

There seem to be two problems showing up. First, PMD doesn't handle the NoClassDefFoundError similar to ClassNotFoundException - I've created an issue for PMD here. Second, Sonar doesn't seem to provide the complete project classpath to PMD. In order for PMD to be able to take advantage of typeresolution, PMD...

PMD multiple rulesets pass build but single ruleset fails build

java,maven,maven-plugin,pmd

I found the issue. There was an issue with Maven Plugin version 3.3 . Now I am using version 3.1 and the exact same code is working as expected.

Maven PMD plug-in not generating a report with 'mvn site' command or 'pmd:pmd'

java,maven,pmd

The maven-pmd-plugin by default skips nowadays empty reports (property skipEmptyReport). You'll need to set this to false, to get in your site always a PMD/CPD report: <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> <version>3.4</version> <configuration> <skipEmptyReport>false</skipEmptyReport> </configuration> </plugin> </plugins> </reporting> This applies for both PMD and...

Eclipse-PMD Configure ruleset globally

java,eclipse,eclipse-plugin,pmd

Try eclipse-pmd (available in the Eclipse marketplace or via the update site http://www.acanda.ch/eclipse-pmd/release/latest). With eclipse-pmd you can configure your projects to use a single rule set file for several projects. It also stores its path relative to the workspace. You still have to configure each project individually though (for now,...

How to exclude a file for checking in PMD maven pom.xml file?

java,maven,pmd

If you want to exclude files from pmd checks your configuration should look something like this. The exclusions should be under the root of configuration not inside the rulesets tag. <configuration> <excludes> <exclude>.*/example/*.*</exclude> </excludes> </configuration> ...

With pmd rulesets in maven, how do you select an individual rule?

java,maven,pmd

This is not directly possible with maven. I'd recommend creating a custom ruleset file and reference this single ruleset in pom.xml instead. Custom Ruleset File: http://pmd.sourceforge.net/pmd-5.2.3/customizing/howtomakearuleset.html Example (filename custom-ruleset.xml): <?xml version="1.0"?> <ruleset name="Custom ruleset" 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...

How to activate PMD and Checkstyle in SonarQube

sonarqube,checkstyle,pmd,code-quality

Have you enabled any PMD and Checkstyle rules in the Quality Profile you are using to analyse?

Getting NoClassDefFoundError while running PMD task from Gradle

java,gradle,pmd

At last found the issue. I needed to resolve pmd and all it's transitive dependencies from a remote repo like Maven Central. repositories { mavenCentral() } pmd { toolVersion = "5.1.1" ignoreFailures = true } ...

Eclipse-PMD : error while installing through eclipse market place

java,eclipse,pmd,eclipse-kepler

I'm the creator of eclipse-pmd, the plugin you are trying to install. I tried to install it myself just now and it worked without any problems. So I can only guess what could be the problem in your case: The repository was temporarily not available Simply try again. You are...

PMD rules needs to be applied Junit files also?

junit,pmd

This question is more a definition of what the software architect / technical lead wants. We have a common rule, what the quality of the tests have to be in the same quality as the code for production. But why? Since the test code is ensuring the quality of the...

PMD can't find rule UseSingleton

java,eclipse,pmd

See also the answer on the bug report #1339 and the changelog for 5.3.1: Language Java, ruleset design.xml: The rule “UseSingleton” has been renamed to “UseUtilityClass”. See also bugs #1059 and #1339. This is fixed with PMD 5.3.1 and later. For the time being, you'll need to manually fix the...

Running all PMD ruleset from command line

pmd,command-line-interface

You can define a config file which includes the rulesets you wish to run. You can give this file as a parameter after the -R argument on the command line. An example file is here (MyRules.xml): <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <ruleset name="PMD.rul" 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>This ruleset was...

Using character instead of String for single-character values in StringBuffer append

java,string,optimization,string-concatenation,pmd

Appending a character as a char will always be faster than appending it as a String. But does the performance difference matter? If you just do it once, it doesn't. If it is inside a cycle repeating its body a million times, then yes, it might matter. If you already...

How to avoid premature initialization if the variable is only used inside of a scope

java,pmd

Use a single LoC for this: return someCondition() ? "some value" : "some other value"; The code in here: String token; String authorization = getAuthorization(token); if (authorization != null) { String[] parts = authorization.split(" "); if (parts.length == 2 && "Bearer".equals(part[0])) { token = parts[1]; } return token; In this...

How to Add custom JAR to the “eclipse-pmd” plugin?

java,eclipse,pmd

You can use your custom rule classes if you add your jar as an Eclipse plug-in fragment to your Eclipse installation. The host of the plug-in fragment must be ch.acanda.eclipse.pmd.core. To convert the jar to a plug-in fragment you have to modify the file MANIFEST.MF file and add a few...

writing custom pmd rule that checks for method not followed by chained method?

pmd,sonarqube,fest-assert

Please, do not double post. Thread closed. Continuing at http://sonarqube.15.x6.nabble.com/Write-a-custom-XPath-task-that-looks-for-a-method-that-is-NOT-followed-by-a-chained-method-call-td5024017.html

PMD violationSuppressXPath for all REST @GET methods?

pmd

We are using for example this rules to suppress checks on REST methods for final declaration. Maybe you need similar? <rule ref="rulesets/java/optimizations.xml/MethodArgumentCouldBeFinal"> <properties> <!-- Ignore Rest resources --> <property name="violationSuppressXPath" value=" //ClassOrInterfaceBodyDeclaration/Annotation/MarkerAnnotation//Name[@Image='GET'] | //ClassOrInterfaceBodyDeclaration/Annotation/MarkerAnnotation//Name[@Image='POST']|...

Why PMD suggests to declare the JSONArray as final

java,pmd

PMD has detected that jsarray_com is never reassigned, so it's suggesting to add final to the declaration to make this fact explicit. When you see final, you immediately know that jsarray_com will always reference the same object. It makes the code slightly easier to follow, but you are free to...

Adding a ruleset to PMD?

java,jsp,maven,pmd

This turned out be because I was using an old version of the Maven PMD plugin. The Maven plugin pulls in PMD by itself, which is convenient, but doesn't give you any control over what version it pulls in. The version I was using, 2.7.1, pulled in PMD version 4.3,...

Why java method name should not contain underscore?

java,pmd

It is a standard that has been set so that people can easily read each other's code, therefore making code more maintainable. The quote below is from Oracle's website on Java code conventions: 80% of the lifetime cost of a piece of software goes to maintenance. Hardly any software is...