pmd

Eclipse duplication annotation @SurpressWarnings for PMD

荒凉一梦 提交于 2019-12-11 08:35:45
问题 I am trying to disable several arbitrary PMD warnings for my class. How can I list several PMD rules to be ignored? I was not able to find with Google. @SuppressWarnings("PMD.OnlyOneReturn") @SuppressWarnings("PMD.ShortVariable") public class MyClass { it gives Eclipse compile time error: Duplicate annotation @SurpressWarnings This is compilable but ignored @SuppressWarnings("PMD.OnlyOneReturn, PMD.ShortVariable") This @SuppressWarnings("PMD.OnlyOneReturn", "PMD.ShortVariable") result is

pmd rule for checking java code for comments

此生再无相见时 提交于 2019-12-11 07:35:42
问题 i need a PMD java class for checking comments on java code. I am working on MyEclipse IDE. any idea? 回答1: You don't need a PMD rule, you can use the internal compiler to raise missing documentation as warning (or even error). Look under Eclipse preferences -> Java -> Compiler -> JavaDoc 来源: https://stackoverflow.com/questions/3965937/pmd-rule-for-checking-java-code-for-comments

combine two PMD checks

試著忘記壹切 提交于 2019-12-11 05:43:05
问题 I met a problem while using PMD to check my code errors. I do not know how to satisfy two requirements at the same time. For example, if I want to check a method named ABC not existing in file extends from BCD. I know how to check whether ABC exists or whether it extends from BCD separately using PMD. Like this: //PrimaryExpression/PrimaryPrefix/Name [@Image = "ABC"]; //ExtendsList/ClassOrInterfaceType [@Image != "BCD"]; now, is there anyway that I can check these two together. For example, I

PMD - skip checking methods annotaded by @PostConstruct or @PreDestroy

核能气质少年 提交于 2019-12-11 03:23:40
问题 I have the following class: import javax.annotation.PostConstruct; public class PmdUnusedMethod { private void unusedMethod() { } @PostConstruct private void postConstructAnnotatedMethod() { } } and defined PMD rule-set: <rule ref="rulesets/java/unusedcode.xml"/> In that case PMD report me two errors about unused methods ("unusedMethod" and "postConstructAnnotatedMethod"), but I want to ignore rule "UnusedPrivateMethod" for methods annotated with @PreDestroy and @PostConstruct. I know I could

PMD - How to exclude files from violation check

Deadly 提交于 2019-12-10 23:29:54
问题 We're checking our code using the PMD 'check' goal that is bound to the 'verify' life cycle. (http://maven.apache.org/plugins/maven-pmd-plugin/examples/violationChecking.html) For the 'pmd' goal you can add 'excludes' and 'excludeRoots' but not for the 'check' goal. How does one exclude eg. generated sources directories? 回答1: You need to do the pmd:pmd first and afterwards do a pmd:check. You can configure that simply by using. Bind that to a particular lifecycle-phase which is before verify.

Use PMD to check someObject.methodCall when someObject exists in base class

六月ゝ 毕业季﹏ 提交于 2019-12-10 21:05:43
问题 We have applications that use the Spring framework's NamedParameterJdbcTemplate to execute various JDBC statements. Most of the methods in this class are overloaded. For example, one version of update() accepts a Map, where the keys are bind variable names, values are variable substitutions. Another version accepts a SqlParameterSource, which allows column type information to be supplied as well. I would like to write a rule that flags use of the Map version, because supplying type

How to get InetAddress with wildcard ip 0.0.0.0?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 17:08:18
问题 InetAddress doesn't provide any static method or constructor to get InetAddress with wildcard IP 0.0.0.0 . The only way is InetAddress.getByName("0.0.0.0") But PMD gives AvoidUsingHardCodedIP if we pass hard coded IP. Is there any way to get InetAddress with wildcard IP but without hard coding the IP? 回答1: I know that this is a little bit old. But i was in the same situation: InetAddress wildCard = new InetSocketAddress(0).getAddress(); does the trick. The main constructor public

在解决了ORA-600 [2662]后,库启动的时候出现ORA-600[4193]错误

坚强是说给别人听的谎言 提交于 2019-12-10 15:53:24
ORA-600[4193]解决 在解决了ORA-600 [2662]后,库启动的时候出现ORA-600[4193]错误 Tue Feb 14 09:34:11 2012 Errors in file d:\oracle\product\10.2.0\admin\interlib\bdump\interlib_smon_2784.trc: ORA-01595: error freeing extent (2) of rollback segment (3)) ORA-00607: Internal error occurred while making a change to a data block ORA-00600: internal error code, arguments: [4194], [6], [30], , , , , Tue Feb 14 09:35:34 2012 Errors in file d:\oracle\product\10.2.0\admin\interlib\udump\interlib_ora_2824.trc: ORA-00603: ORACLE server session terminated by fatal error ORA-00600: internal error code, arguments: [4193], [2005],

Difference with Checkstyle and PMD configuration in maven parent module

别等时光非礼了梦想. 提交于 2019-12-10 14:01:56
问题 I have a java application with maven having below structure: parent | - pom.xml | - child | - pom.xml | - analyzers | - pmdrules.xml | - checkstyle.xml I have configured both PMD and checkstyle in parent pom.xml. For PMD the rulesets are configured as below, and it works fine both for parent and child modules: <configuration> <rulesets> <ruleset>${basedir}/../analyzers/pmdrules.xml</ruleset> </rulesets> </configuration> However, for checkstyle if I configure configLocation in the same way, it

PMD with Maven - How to disable one rule within a ruleset?

大兔子大兔子 提交于 2019-12-10 13:19:10
问题 I have PMD running via Maven 2. Right now I have all the rulesets in place to see what gets generated (see code below). I'm going through and fixing things that make sense to me to fix. However, there are cases such as in the "optimizations" ruleset where I want to keep the rule set, but disable just one of the rules within the rule set . In my case, I want to disable the "AvoidInstantiatingObjectsInLoopss" rule. Here is the reporting section of my pom.xml <reporting> <plugins> <plugin>