Compare commits

..
334 Commits
Author SHA1 Message Date
Andreas Dangel 253d35a926 Update release script 2016-11-04 20:24:51 +01:00
Andreas Dangel 6007840346 Prepare next development version 2016-11-04 19:58:50 +01:00
Andreas Dangel dcb4ecc674 [maven-release-plugin] prepare for next development iteration 2016-11-04 19:02:30 +01:00
Andreas Dangel 14cdf0b550 [maven-release-plugin] prepare release pmd_releases/5.3.8 2016-11-04 19:02:30 +01:00
Andreas Dangel 40ed778e43 Prepare pmd release 5.3.8 2016-11-04 18:37:25 +01:00
Andreas Dangel 3a46e9bab2 Merge branch 'bug-1520' into pmd/5.3.x 2016-11-04 16:24:48 +01:00
Andreas Dangel d7b8bae1c9 plsql: adjust code samples, since "ONLY" is now a keyword 2016-11-04 16:21:25 +01:00
Andreas Dangel 4ab1d0cbee Fixes #1520 [plsql] Missing PL/SQL language constructs in parser: Is Of Type, Using 2016-11-04 16:10:07 +01:00
Andreas Dangel 8444b2fea6 Merge branch 'bug-1532' into pmd/5.3.x 2016-11-04 12:46:05 +01:00
Andreas Dangel a9d0de9450 Fixes #1532 [java] CloneMethodMustImplementCloneable: Implemented Interface extends Cloneable 2016-11-04 12:41:57 +01:00
Andreas Dangel 08b7959557 Merge branch 'bug-1527' into pmd/5.3.x 2016-11-04 10:23:33 +01:00
Andreas Dangel 495dcb5ea9 Fixes #1527 [plsql] PRAGMA AUTONOMOUS_TRANSACTION gives processing errors 2016-11-04 10:19:24 +01:00
Andreas Dangel 7339227e9c Merge branch 'pr-119' into pmd/5.3.x 2016-10-30 19:16:52 +01:00
Andreas Dangel 2cc91732ec Update changelog 2016-10-30 19:11:54 +01:00
Frits Jalvingh 4310b36344 Fix PMD issue 1531- endless loop followed by OOM while parsing (PL)SQL 2016-10-30 19:09:11 +01:00
Andreas Dangel 575a5b6547 Add unit test for #1531 [plsql] OOM/Endless loop while parsing (PL)SQL 2016-10-30 19:08:00 +01:00
Andreas Dangel 45dfd29a46 Merge branch 'pr-113' into pmd/5.3.x 2016-10-30 17:25:14 +01:00
Andreas Dangel f8f0afb5b4 Update changelog 2016-10-30 17:21:18 +01:00
Juan Martín Sotuyo Dodero f8d1162886 Fix ClassCastException on SignatureDeclareThrowsException
- Java 8 code allows for things such as
   `class UnmodifiableList<T> implements @Readonly List<@Readonly T> {}`
    where not all token in the ASTImplementsList are ASTClassOrInterfaceType
2016-10-30 17:19:16 +01:00
Andreas Dangel 020170bd76 Add test for #1535 [java] SignatureDeclareThrowsException: ClassCastException with Annotation 2016-10-30 17:18:31 +01:00
Andreas Dangel 5c80473108 Merge branch 'pr-112' into pmd/5.3.x 2016-10-29 18:27:56 +02:00
Andreas Dangel 9de0727e43 Update changelog 2016-10-29 18:21:55 +02:00
Andreas Dangel 127a2be871 whitespaces 2016-10-29 18:19:59 +02:00
Juan Martín Sotuyo Dodero 238f6b721b Fix ClassCastException on CloneMethodMustImplementCloneable
- Java 8 code allows for things such as
    `class UnmodifiableList<T> implements @Readonly List<@Readonly T> {}`
    where not all token in the ASTImplementsList are ASTClassOrInterfaceType
2016-10-29 18:19:00 +02:00
Andreas Dangel f4f2402661 Add test for #1534 [java] CloneMethodMustImplementCloneable: ClassCastException with Annotation (java8) 2016-10-29 18:17:59 +02:00
Andreas Dangel c95051e97d Merge branch 'pr-111' into pmd/5.3.x 2016-10-29 17:19:47 +02:00
Andreas Dangel 7d5be34cd2 Update changelog 2016-10-29 17:16:01 +02:00
Juan Martín Sotuyo Dodero 1e5c1c05ca In Java 8, annotations may appear as first child
- For instance `Object o = new @Interned MyObject();` would fail with a ClassCastException
 - The current code deals with it gracefully
2016-10-29 17:13:33 +02:00
Andreas Dangel 5d11e77208 Add test for #1533 [java] BooleanInstantiation: ClassCastException with Annotation 2016-10-29 17:12:20 +02:00
Andreas Dangel 461365f543 Merge branch 'bug-1529' into pmd/5.3.x 2016-10-01 17:49:33 +02:00
Andreas Dangel 8667aea076 Fixes #1529 [java] UnusedImports: The created rule violation has no class name 2016-10-01 17:45:47 +02:00
Andreas Dangel b07c2f4409 Merge branch 'bug-1522' into pmd/5.3.x 2016-09-25 18:36:47 +02:00
Andreas Dangel db44bc4745 Fixes #1522 [java] CommentRequired: false positive 2016-09-25 18:32:26 +02:00
Andreas Dangel 7421f28414 Merge branch 'bug-1506' into pmd/5.3.x 2016-08-07 10:53:32 +02:00
Andreas Dangel cf4938a65b Fixes #1506 [core] When runing any RuleTst, start/end methods not called 2016-08-07 10:44:44 +02:00
Andreas Dangel 5b6580448e #1508 - Only close the classloader if its ours 2016-07-27 19:43:31 +02:00
Andreas Dangel 229fc57073 Merge branch 'bug-1508' into pmd/5.3.x 2016-07-26 21:39:17 +02:00
Andreas Dangel 65708ef704 Update changelog 2016-07-26 21:39:03 +02:00
Andreas Dangel d76b689c07 Fixes #1508 [core] [java] PMD is leaking file handles
Closes class loader after PMD has processed all files
2016-07-25 21:42:21 +02:00
Andreas Dangel 293731f009 Fixes #1508 [core] [java] PMD is leaking file handles
Closes class loader after ant task is finished
2016-07-25 21:34:40 +02:00
Andreas Dangel 88d1823c2e Fixes #1508 [core] [java] PMD is leaking file handles
Fixes InputStreams and Readers
2016-07-25 21:25:34 +02:00
Andreas Dangel 4adbeb04f1 Merge branch 'pr-103' into pmd/5.3.x 2016-07-07 22:34:30 +02:00
Andreas Dangel 648e697ab0 Update changelog 2016-07-07 22:29:30 +02:00
Andreas Dangel 0660097db2 Add unit test for #1501 [java] CyclomaticComplexity rule causes OOM when class reporting is disabled 2016-07-07 22:27:16 +02:00
Frits Jalvingh afc0f25795 Fix for 1501: CyclomaticComplexity rule causes OOM when class reporting is disabled 2016-07-07 22:26:27 +02:00
Andreas Dangel c041f756c2 Merge branch 'bug-1499' into pmd/5.3.x 2016-07-02 16:49:19 +02:00
Andreas Dangel 553cafff6e Fixes #1499 [core] CPD test break PMD 5.5.1 build on Windows 2016-07-02 16:48:46 +02:00
Andreas Dangel 6efabd6909 Merge branch 'pr-35' into pmd/5.3.x 2016-06-12 18:50:07 +02:00
Andreas Dangel f880d2ab95 Update changelog 2016-06-12 18:47:12 +02:00
Jan van Nunen 63293f8b31 Javascript tokenizer now ignores comment tokens. 2016-06-06 09:31:04 +02:00
Andreas Dangel 836af8d493 Merge branch 'bug-1479' into pmd/5.3.x 2016-05-29 18:23:34 +02:00
Andreas Dangel 04f16d7627 Fixes #1479 CloseResource false positive on Statement 2016-05-29 18:20:04 +02:00
Andreas Dangel ef0891d527 Merge branch 'bug-1480' into pmd/5.3.x 2016-05-28 16:36:57 +02:00
Andreas Dangel 6afe513225 Fixes #1480 false positive on public modifier used with inner interface in enum 2016-05-28 16:33:10 +02:00
Andreas Dangel d1b9b3bc1f Merge branch 'bug-1481' into pmd/5.3.x 2016-05-28 11:36:55 +02:00
Andreas Dangel 379b0de186 Update changelog 2016-05-28 11:36:41 +02:00
Andreas Dangel e71324e08c Fix unit test for #1481 2016-05-28 11:36:35 +02:00
Andreas Dangel 13f7675b67 Fixes #1481 no problems found results in blank file instead of empty xml 2016-05-28 11:27:22 +02:00
Andreas Dangel 1efdb72ba9 Merge branch 'bug-1484' into pmd/5.3.x 2016-05-21 11:37:28 +02:00
Andreas Dangel 0d20fe7e1c Fixes #1484 UnusedLocalVariable - false positive - parenthesis 2016-05-21 11:37:10 +02:00
Andreas Dangel 58085e1520 Merge branch 'issue-1360-ruleset-compatibility' into pmd/5.3.x 2016-05-18 20:52:39 +02:00
Andreas Dangel f32beeb726 Provide a command line option for #1360 - "-noRuleSetCompatibility" 2016-05-18 20:38:44 +02:00
Andreas Dangel 1816c1708a Merge branch 'issue-1360-ruleset-compatibility' into pmd/5.3.x 2016-05-13 18:58:39 +02:00
Andreas Dangel a8a18e6648 Fixes #1360 Provide backwards compatibility for PMD configuration file
Update changelog
2016-05-13 18:58:23 +02:00
Andreas Dangel 1b65c7fe91 References #1360 Provide backwards combatibility for PMD configuration file
Handle exclusions
2016-05-13 18:53:00 +02:00
Andreas Dangel 44ee51d5a6 References #1360 Provide backwards combatibility for PMD configuration file
Add test cases for excluded rules
2016-05-06 11:08:25 +02:00
Andreas Dangel 15fd444b7a References #1360 Provide backwards combatibility for PMD configuration file 2016-05-06 10:52:43 +02:00
Andreas Dangel 147662e035 Prepare next development version 2016-04-30 23:54:24 +02:00
Andreas Dangel 2afd30c283 [maven-release-plugin] prepare for next development iteration 2016-04-30 23:15:13 +02:00
Andreas Dangel d89549f994 [maven-release-plugin] prepare release pmd_releases/5.3.7 2016-04-30 23:15:13 +02:00
Andreas Dangel 8b8bb6d504 Fix site generation 2016-04-30 23:03:14 +02:00
Andreas Dangel ef6bb6ed53 Prepare pmd release 5.3.7 2016-04-30 22:03:24 +02:00
Andreas Dangel 7d053d41c2 Merge branch 'bug-1470' into pmd/5.3.x 2016-04-30 19:18:08 +02:00
Andreas Dangel 81378fe8ed Fixes #1470 Error with type-bound lambda 2016-04-30 19:14:46 +02:00
Andreas Dangel ce8c4bf1a8 Merge branch 'bug-1475' into pmd/5.3.x 2016-04-30 18:36:44 +02:00
Andreas Dangel 325fcaf5e4 Fixes #1475 False positive of MethodReturnsInternalArray 2016-04-30 18:33:39 +02:00
Andreas Dangel 361370db5d Merge branch 'bug-1476' into pmd/5.3.x 2016-04-30 12:00:09 +02:00
Andreas Dangel b9b0059797 Fixes #1476 False positive of ArrayIsStoredDirectly 2016-04-30 11:46:29 +02:00
Andreas Dangel baad0f2abe Merge branch 'bug-1471' into pmd/5.3.x 2016-04-23 19:46:07 +02:00
Andreas Dangel 176cc2344d Fix NPEs 2016-04-23 19:43:13 +02:00
Andreas Dangel cb5ac3086e Fixes #1471 False positives for DoubleCheckedLocking 2016-04-23 19:34:32 +02:00
Andreas Dangel 803d35005a Merge branch 'toolchains' into pmd/5.3.x 2016-04-10 17:03:40 +02:00
Andreas Dangel 6fc617bd11 Java version is now handled by toolchain 2016-04-10 17:03:30 +02:00
Andreas Dangel 6be8547f3e Add maven toolchains 2016-04-10 16:55:25 +02:00
Andreas Dangel 93227d1372 Merge branch 'bug-1458' into pmd/5.3.x 2016-04-01 21:08:40 +02:00
Andreas Dangel 5f9114a02a Merge branch 'bug-1467' into pmd/5.3.x 2016-04-01 21:08:20 +02:00
Andreas Dangel 494719d8ea Fixes #1458 Performance degradation scanning large XML files with XPath custom rules 2016-04-01 20:52:38 +02:00
Andreas Dangel 3d84e3af74 Fixes #1467 UseUtilityClass can't correctly check functions with multiple annotations 2016-04-01 19:04:53 +02:00
Andreas Dangel cbde6f48ea Merge branch 'pr-33' into pmd/5.3.x 2016-03-29 20:01:12 +02:00
Andreas Dangel c3f98356f8 Move antlr dependency definitions up into parent pom 2016-03-29 19:49:04 +02:00
Andreas Dangel ccd0badd4a Update changelog and docu to add swift 2016-03-29 19:44:50 +02:00
Andreas Dangel 2ce28f0ae3 Merge branch 'tiobe/add_swift_language' of https://github.com/tiobe/pmd into pr-33 2016-03-29 19:21:17 +02:00
Andreas Dangel c571abdb1d Merge branch 'bug-1461-doc' into pmd/5.3.x 2016-03-13 15:28:58 +01:00
Andreas Dangel 0725586b9a Update documentation about thread safety of rules (see #1461) 2016-03-13 15:28:37 +01:00
Andreas Dangel ccbb372a4f Fix compile error (pmd 5.3.x is on java6) 2016-03-10 20:19:30 +01:00
Andreas Dangel be51afc2b4 Merge branch 'bug-1461' into pmd/5.3.x 2016-03-10 20:18:58 +01:00
Andreas Dangel 5f9e90761d Fixes #1461 Possible threading issue due to PR#75
Update changelog
2016-03-10 20:12:13 +01:00
Andreas Dangel 4a0802a269 Revert "RuleSetFactory Performance Enhancement:-"
This reverts commit 9da51952ef.
2016-03-10 20:11:06 +01:00
Andreas Dangel 3de70426cf Revert "Update changelog, keep backwards compatible createRuleSets methods by overloading"
This reverts commit b753cc5ec5.
2016-03-10 20:10:58 +01:00
Andreas Dangel 54ce3036b2 Add unit test to verify concurrency issue #1461
References pr #75
2016-03-10 20:10:51 +01:00
Jan van Nunen 92678c0c0a Added support for Swift to CPD.
The tokenizer uses the ANTLR4 grammar of the Tailor static analyzer for
Swift. (https://github.com/sleekbyte/tailor)
2016-03-02 11:11:02 +01:00
Andreas Dangel 1726c33c19 Merge branch 'bug-1464' into pmd/5.3.x 2016-02-28 15:12:22 +01:00
Andreas Dangel 573186be69 fixes #1464 UnnecessaryFinalModifier false positive on a @SafeVarargs method 2016-02-28 14:22:04 +01:00
Andreas Dangel 090636e2db Merge branch 'pr-85' into pmd/5.3.x
Closes #85
Note: pr-85 has been rebased onto pmd/5.3.x
2016-02-28 14:04:57 +01:00
Andreas Dangel fc35a162d9 Update changelog, whitespaces, improve test case 2016-02-28 14:01:32 +01:00
albfernandez 08fb59180d remove trailing spaces 2016-02-28 13:07:03 +01:00
albfernandez 40bf82244f Fix the fix for #1340 2016-02-28 13:07:03 +01:00
albfernandez 3c0516b86f Fix #1340 UseStringBufferForStringAppends False Positive with ternary
operator (used both in condition and options)
2016-02-28 13:07:03 +01:00
Andreas Dangel 32cc07d7cb Merge branch 'bug-1465' into pmd/5.3.x 2016-02-27 19:37:29 +01:00
Andreas Dangel 1c08f94691 fixes #1465 False Positve UnusedImports with javadoc @link 2016-02-27 19:30:16 +01:00
Andreas Dangel aab525196c Merge branch 'tiobe-tiobe/fix_UTF8_escape_in_OBJC_string_literals' into pmd/5.3.x 2016-02-24 21:53:16 +01:00
Andreas Dangel 518f1eff6d Update changelog 2016-02-24 21:48:41 +01:00
Jan van Nunen 7915f08bc9 Extended Objective-C grammar to accept UTF-8 escapes (\uXXXX) in string literals. 2016-02-18 13:40:32 +01:00
Andreas Dangel 84cfa37b94 Merge branch 'bug-1457' into pmd/5.3.x 2016-02-07 12:32:02 +01:00
Andreas Dangel 079ffeb4df fixes #1457 TooManyMethods counts inner class methods 2016-02-07 12:31:49 +01:00
Andreas Dangel 6509f78448 Merge branch 'bug-1456' into pmd/5.3.x 2016-02-07 12:03:44 +01:00
Andreas Dangel 89ffb56e4e fixes #1456 UnusedFormalParameter should ignore overriding methods 2016-02-07 12:03:30 +01:00
Andreas Dangel dc7762b910 Merge branch 'bug-1453' into pmd/5.3.x 2016-01-28 22:24:57 +01:00
Andreas Dangel b9f8f2d4fb fixes #1453 Test Class Without Test Cases gives false positive 2016-01-28 22:24:34 +01:00
Andreas Dangel 80c10534b3 Merge branch 'bug-1455' into pmd/5.3.x 2016-01-25 10:32:50 +01:00
Andreas Dangel e6f5380719 fixes #1455 PMD doesn't handle Java 8 explicit receiver parameters
Those parameters are correctly parsed now and can be found
with "//FormalParameter[@ExplicitReceiverParameter='true']"
2016-01-25 10:29:00 +01:00
Andreas Dangel e4438ff8a2 Merge branch 'bug-1449' into pmd/5.3.x 2016-01-24 17:29:22 +01:00
Andreas Dangel 44a8c0defe fixes #1449 false positive when casting a variable to short 2016-01-24 17:18:50 +01:00
Andreas Dangel 314ae4414b Merge branch 'pr-31' into pmd/5.3.x 2016-01-21 20:23:22 +01:00
Andreas Dangel 04527bc4cb Update changelog 2016-01-21 20:23:02 +01:00
Andreas Dangel 82178809fa Merge branch 'detect_file_encoding_using_UTF_BOM' of https://github.com/tiobe/pmd into pr-31 2016-01-21 20:10:22 +01:00
Andreas Dangel 641ab25850 Merge branch 'pr-30' into pmd/5.3.x 2016-01-20 22:21:18 +01:00
Andreas Dangel 8c4d307ddd Refactor command line tests for CPD and create a BaseCPDCLITest class 2016-01-20 22:13:25 +01:00
Andreas Dangel 7a33d59a95 Add unit test for new behavior 2016-01-20 22:08:45 +01:00
Andreas Dangel b9b6e13849 Update changelog 2016-01-20 22:08:28 +01:00
Andreas Dangel 64441c8e93 Merge branch 'tiobe/remove_filefilter_for_files' of https://github.com/tiobe/pmd into pr-30 2016-01-20 21:38:23 +01:00
Andreas Dangel d76c5b0de6 Merge branch 'bug-1452' into pmd/5.3.x 2016-01-15 10:42:47 +01:00
Andreas Dangel 7bf00118a7 Refactoring AccessorClassGenerationRule 2016-01-15 10:42:19 +01:00
Andreas Dangel 69dbbdfe2d references #81 2016-01-15 10:42:08 +01:00
Andreas Dangel 699077fc7d Merge branch 'codeclimate-doc' into pmd/5.3.x 2016-01-15 09:54:00 +01:00
Andreas Dangel e8e950ad20 Add codeclimate renderer to the documentation 2016-01-15 09:53:43 +01:00
Jan van Nunen 607606534d Added file encoding detection to CPD. 2016-01-11 13:57:04 +01:00
Andreas Dangel 207cf4842e Merge branch 'pr-29' into pmd/5.3.x 2016-01-07 10:58:46 +01:00
Andreas Dangel 03411d620e Update changelog 2016-01-07 10:58:33 +01:00
Andreas Dangel 4a90118222 Merge branch 'tiobe/UTF8_BOM_support_for_JSP_tokenizer' of https://github.com/tiobe/pmd into pr-29 2016-01-07 10:58:05 +01:00
Andreas Dangel 907a05670a Merge branch 'pr-27' into pmd/5.3.x 2016-01-07 10:56:09 +01:00
Andreas Dangel eee4bf2550 Update changelog 2016-01-07 10:55:56 +01:00
Andreas Dangel a33e83addc Merge branch 'tiobe/raw-CPP11-literals' of https://github.com/tiobe/pmd into pr-27 2016-01-07 10:55:27 +01:00
Andreas Dangel e5a046007a Merge branch 'pr-83' into pmd/5.3.x
Closes #83 (rebased)
2016-01-07 10:51:20 +01:00
Andreas Dangel e08ba3ea30 Update changelog 2016-01-07 10:50:48 +01:00
Bob W. Hogg b2d5342493 Adds new Code Climate-compliant JSON renderer 2016-01-07 10:47:47 +01:00
Andreas Dangel f4a3e77185 Merge branch 'pr-80' into pmd/5.3.x
Closes #80 (rebased onto pmd/5.3.x)
2016-01-07 10:36:37 +01:00
Andreas Dangel d783bdcfb0 Update changelog 2016-01-07 10:36:25 +01:00
Wim Deblauwe 8bb07ad5f5 Update mvn-plugin.md
The correct name of the property to configure linking to source code is `linkXRef` and not `linkXref`. If you use `<linkXRef>false</linkXRef>` then the warning "[WARNING] Unable to locate Source XRef to link to - DISABLED" is no longer printed. See also http://stackoverflow.com/a/18390459/40064
2016-01-07 10:35:12 +01:00
Andreas Dangel 1dbf832d24 Merge branch 'pr-79' into pmd/5.3.x
Closes #79
2016-01-07 10:25:30 +01:00
Andreas Dangel 985ed57c52 Update changelog 2016-01-07 10:20:47 +01:00
Matt Benson f67dbb85f6 do not flag public static void main(String[]) as UseVarargs; ignore @Override for UseVarargs 2016-01-07 10:16:26 +01:00
Jan van Nunen 10db98bfee Removed file filter for files that are explicitly specified on the CPD command line using the '--files' command line option. 2015-12-10 16:47:58 +01:00
Jan van Nunen a735fb057e Added support for files with UTF-8 BOM to JSP tokenizer. 2015-12-10 16:24:51 +01:00
Jan van Nunen c099d50397 Added support for Raw String Literals (C++11). 2015-12-10 16:15:40 +01:00
Andreas Dangel 14510cdc5c Fix pom of pmd-java8 2015-12-04 21:03:58 +01:00
Andreas Dangel fda6bef16e Prepare next development version 2015-12-04 20:01:31 +01:00
Andreas Dangel 83eceab455 [maven-release-plugin] prepare for next development iteration 2015-12-04 19:15:01 +01:00
Andreas Dangel c141c91612 [maven-release-plugin] prepare release pmd_releases/5.3.6 2015-12-04 19:15:01 +01:00
Andreas Dangel beb07e883f Prepare pmd release 5.3.6 2015-12-04 19:00:54 +01:00
Andreas Dangel 6a3e7ce6ec Merge branch 'bug-1434' into pmd/5.3.x 2015-12-03 20:15:42 +01:00
Andreas Dangel 735b3e59f2 #1434 CommentRequired raises violation on serialVersionUID field 2015-12-03 20:15:25 +01:00
Andreas Dangel af57d270e4 Merge branch 'bug-1373' into pmd/5.3.x 2015-11-30 10:10:18 +01:00
Andreas Dangel 2452db15f4 #1373 JUnitAssertionsShouldIncludeMessage is no longer compatible with TestNG 2015-11-30 10:05:42 +01:00
Andreas Dangel 06cce6055a Merge branch 'bug-1374' into pmd/5.3.x 2015-11-30 09:46:15 +01:00
Andreas Dangel bc9379d9b4 verify #1374 JUnitAssertionsShouldIncludeMessage does not work 2015-11-30 09:35:27 +01:00
Andreas Dangel 9075c66a3a Merge branch 'bug-1446' into pmd/5.3.x 2015-11-30 09:30:56 +01:00
Andreas Dangel 2a52757aa5 #1446 False positive with JUnit4TestShouldUseBeforeAnnotation when TestNG is used 2015-11-30 09:26:13 +01:00
Andreas Dangel da50aa33ea Merge branch 'bug-1436' into pmd/5.3.x 2015-11-20 11:23:12 +01:00
Andreas Dangel b4c2a51781 #1436 UnnecessaryFullyQualifiedName false positive on clashing static imports with enums 2015-11-20 11:23:01 +01:00
Andreas Dangel 07aa990ccc Merge branch 'bug-1431' into pmd/5.3.x 2015-11-19 22:11:40 +01:00
Andreas Dangel d621707e2f #1431 SuspiciousEqualsMethodName false positive 2015-11-19 22:06:51 +01:00
Andreas Dangel 1c7d1a1f1d Merge branch 'bug-1438' into pmd/5.3.x 2015-11-19 21:41:21 +01:00
Andreas Dangel f2ec1be93f #1438 UseNotifyAllInsteadOfNotify gives false positive 2015-11-19 21:35:50 +01:00
Andreas Dangel aab043787b Merge branch 'bug-1443' into pmd/5.3.x 2015-11-16 21:34:33 +01:00
David Burström 90b1f65ea2 #1443 RedundantFieldInitializer: False positive for small floats 2015-11-16 21:33:51 +01:00
Andreas Dangel 41b51c2158 Merge branch 'travis-pull-request-fix' into pmd/5.3.x 2015-11-14 18:09:10 +01:00
Andreas Dangel f1a319d6ee Make sure the pull request validation builds don't fail 2015-11-14 18:08:56 +01:00
Andreas Dangel c8a1307684 Merge branch 'bug-1441' into pmd/5.3.x 2015-11-14 17:54:13 +01:00
Andreas Dangel c9dca8dc92 #1441 PMD: Update documentation how to compile after modularization 2015-11-14 17:53:52 +01:00
Andreas Dangel 0b1fc2b39f Merge branch 'bug-1440' into pmd/5.3.x 2015-11-13 19:09:27 +01:00
Andreas Dangel 02c49ce881 #1440 NPE in AvoidCallingFinalize 2015-11-13 19:05:24 +01:00
Andreas Dangel b0a1223748 Merge branch 'pull-request-25' into pmd/5.3.x 2015-10-26 20:54:39 +01:00
Andreas Dangel ba92715b19 CPD GUI: Add ignoreUsings option 2015-10-26 20:47:34 +01:00
Andreas Dangel 2fa869a868 CPD Ant Task: Add ignoreUsings option 2015-10-26 20:36:07 +01:00
Andreas Dangel 88634a220a Add "--ignore-usings" parameter to CPD commandline for C# 2015-10-25 19:10:18 +01:00
Andreas Dangel 3a7de73d96 Update changelog 2015-10-25 18:57:35 +01:00
Jan van Nunen 7be198aaa3 Added option to exclude C# using directives from duplicated code analysis.
To exclude C# using directives the system property 'ignore_usings=true' has to be specified on the command line with '-Dignore_usings=true'.
2015-10-23 15:48:25 +02:00
Jan van Nunen aa87701ee5 Extended Objective-C grammar to accept Unicode characters in identifiers. 2015-10-23 15:46:38 +02:00
Andreas Dangel 933002de34 Merge branch 'amitbitcse-pmd/5.3.x' into pmd/5.3.x 2015-10-16 17:50:14 +02:00
Andreas Dangel b753cc5ec5 Update changelog, keep backwards compatible createRuleSets methods by overloading 2015-10-16 17:49:45 +02:00
Andreas Dangel b5706d0726 Merge branch 'travis-fix' into pmd/5.3.x 2015-10-16 16:34:43 +02:00
Andreas Dangel 763bd9a478 travis: only deploy if we have the env vars and if it is not a pull request 2015-10-16 14:27:10 +02:00
Andreas Dangel 7fe60c0747 Merge branch 'bug-1425' into pmd/5.3.x 2015-10-16 12:25:51 +02:00
Andreas Dangel 3393507082 #1425 Invalid XML Characters in Output
XMLRenderer correctly escapes the surrogate characters
AvoidDuplicateLiterals tries to reconstruct original string literal
2015-10-16 12:18:15 +02:00
amitbitcse 9da51952ef RuleSetFactory Performance Enhancement:-
To enhance performance of RuleSetFactory, the RuleSets generated by RuleSetFactory from ruleSetString is set in PMDConfiguration and is checked before generating it again in MonoThreadProcessor, MutliThreadProcessor and PMDRunnable classes.
2015-10-13 17:50:37 +05:30
Andreas Dangel ce73691d5d Merge branch 'bug-1428' into pmd/5.3.x 2015-10-10 18:59:21 +02:00
Andreas Dangel 808943e366 #1428 False positive in UnusedPrivateField when local variable hides member variable 2015-10-10 18:54:31 +02:00
Andreas Dangel 63afc1ec94 Merge branch 'pr-72' into pmd/5.3.x 2015-10-10 17:40:13 +02:00
Andreas Dangel d788b6ce74 Update changelog for pr-72 2015-10-10 17:37:58 +02:00
Andreas Dangel 1e0b8cfa21 Merge branch 'pmd/5.3.x' of https://github.com/amitbitcse/pmd into pr-72 2015-10-10 17:22:59 +02:00
Andreas Dangel 79853cdace Merge branch 'travis-prevent-building-tags' into pmd/5.3.x 2015-10-10 16:53:31 +02:00
Andreas Dangel 2760827dc7 Prevent travis from building release tags 2015-10-10 16:53:19 +02:00
Andreas Dangel a7a84766bd #1429 Java - Parse Error: Cast in return expression 2015-10-10 16:08:38 +02:00
Andreas Dangel 6b60b4be34 Fix travis build failure for pull requests 2015-10-10 15:20:25 +02:00
amitbitcse 1d190605e5 Added capability in Java and JSP parser for tracking tokens. It is often useful to keep track of each node's first and last token so that input can be easily reproduced again. Ref - https://javacc.java.net/doc/JJTree.html 2015-10-06 11:04:22 +05:30
Andreas Dangel 84c407f5d2 add src zip file in do-release.sh upload instructions 2015-10-04 14:07:12 +02:00
Andreas Dangel 79e9b7616a Prepare next development version 2015-10-04 13:54:43 +02:00
Andreas Dangel af9f9d477d [maven-release-plugin] prepare for next development iteration 2015-10-04 12:48:25 +02:00
Andreas Dangel f357da73b6 [maven-release-plugin] prepare release pmd_releases/5.3.5 2015-10-04 12:48:25 +02:00
Andreas Dangel 98e0c1f914 Prepare pmd release 5.3.5 2015-10-04 12:40:49 +02:00
Andreas Dangel 73fe285b1a #1418 RedundantFieldInitializer false positive with large long value 2015-10-03 17:36:07 +02:00
Andreas Dangel 3bf91a84d6 travis - don't try to deploy pull request builds... 2015-10-03 16:57:16 +02:00
Andreas Dangel 8b80efbd88 Merge branch 'mkordas-patch-1' into pmd/5.3.x 2015-10-03 16:53:42 +02:00
Andreas Dangel 87db2a5736 Update changelog 2015-10-03 16:49:36 +02:00
Michal Kordas 4a395ee8b7 #1410 Improve description of DefaultPackage rule 2015-09-30 22:36:00 +02:00
Andreas Dangel 98278cfdfc #1413 False positive StringBuffer constructor with ?: int value 2015-09-26 11:08:21 +02:00
Andreas Dangel 145780de9c #1407 UselessParentheses "&" and "+" operator precedence 2015-09-26 10:23:43 +02:00
Andreas Dangel f3da33cca2 #1387 CloseResource has false positive for ResultSet 2015-09-26 09:55:02 +02:00
Andreas Dangel 4cce31418a Add travis.yml - see https://travis-ci.org/pmd/pmd
Cherry picked from master
* 1a110587f0
* 51f17c6010
* 36bc2c2dee
* cbf598c92c
2015-09-26 09:26:43 +02:00
Andreas Dangel d8d8a9539f #1409 NullPointerException in InsufficientStringBufferRule 2015-09-20 20:51:09 +02:00
Andreas Dangel 365e7a1f68 #1410 DefaultPackage triggers on field annotated with @VisibleForTesting 2015-09-20 20:24:46 +02:00
Andreas Dangel 3fb43a060a Prepare next development version 2015-09-18 13:46:06 +02:00
Andreas Dangel 819611dd23 [maven-release-plugin] prepare for next development iteration 2015-09-18 12:36:07 +02:00
Andreas Dangel 0ffbe97a04 [maven-release-plugin] prepare release pmd_releases/5.3.4 2015-09-18 12:36:06 +02:00
Andreas Dangel 06d77b371a Use release profile PMD_GPG_PROFILE 2015-09-18 12:24:27 +02:00
Andreas Dangel 972eac40f0 Specify gpg.keyname via -Darguments 2015-09-18 11:57:09 +02:00
Andreas Dangel 336c06fb10 Actually use the variables PMD_GPG_KEY and PMD_SF_USER 2015-09-18 11:49:20 +02:00
Andreas Dangel 87803ed27a Prepare pmd release 5.3.4 2015-09-18 11:44:40 +02:00
Andreas Dangel ca2794bf7d Fixes for the release script 2015-09-18 11:40:16 +02:00
Andreas Dangel d921ffe1e3 Add the release shell script 2015-09-18 11:25:30 +02:00
Andreas Dangel 0f48fd501d #1393 PMD hanging during DataflowAnomalyAnalysis 2015-09-18 10:17:01 +02:00
Andreas Dangel e1a41bdf98 #1405 UnusedPrivateMethod false positive?
Don't use the auxclasspath if not provided.
2015-09-17 20:26:07 +02:00
Andreas Dangel ad1ffa5835 #1404 Java8 'Unnecessary use of fully qualified name' in Streams Collector 2015-09-16 22:11:18 +02:00
Andreas Dangel 64012cc0b4 verified #1405 UnusedPrivateMethod false positive? 2015-09-16 21:37:17 +02:00
Andreas Dangel 2500412b14 #1403 False positive UnusedPrivateMethod with JAVA8 2015-09-14 22:36:05 +02:00
Andreas Dangel 9f6190f3b6 #1380 InsufficientStringBufferDeclaration false positive when literal string passed to a lookup service 2015-09-13 10:20:58 +02:00
Andreas Dangel 9e620c2661 #1388 ConstructorCallsOverridableMethodRule doesn't work with params? 2015-09-12 17:56:45 +02:00
Andreas Dangel ac9fd51f84 #1392 SimplifyStartsWith false-negative 2015-09-11 12:22:49 +02:00
Andreas Dangel 93b4ce9bb4 #1394 dogfood.xml - Unable to exclude rules [UncommentedEmptyMethod] 2015-09-08 20:03:28 +02:00
Andreas Dangel f242c5c5f4 Upgrade maven-pmd-plugin to 3.5 and add pmd execution
The profile "reports" was accidently deactivated by adding other
profiles. Now pmd and checkstyle are executed with all builds.
2015-09-08 19:58:21 +02:00
Andreas Dangel 1984f5ac8a #1395 UnusedPrivateMethod false positive for array element method call 2015-09-08 19:45:49 +02:00
Andreas Dangel b553c52ef5 #1396 PrematureDeclaration lambda false positive 2015-09-07 20:23:10 +02:00
Andreas Dangel 3abfc2fccb #1397 StringToString should ignore method references 2015-09-07 20:01:18 +02:00
Andreas Dangel 100dd09b28 #1398 False positive for GuardLogStatementJavaUtil with Log4j 2015-09-06 11:06:48 +02:00
Andreas Dangel a1ab0d6657 #1399 False positive for VariableNamingConventions with annotation @interface 2015-09-05 19:53:05 +02:00
Andreas Dangel f0dd2b0519 #1400 False positive with JUnit4TestShouldUseBeforeAnnotation 2015-09-05 19:39:31 +02:00
Andreas Dangel 58292bfc38 #1401 False positive for StringBuilder.append called with constructor 2015-09-05 12:10:38 +02:00
Andreas Dangel bd83821dd9 Fix unit test 2015-09-04 21:58:01 +02:00
Andreas Dangel c0c79e522f #1371 fix unit test 2015-09-04 21:55:16 +02:00
Andreas Dangel 0027fcdd77 Update changelog 2015-09-04 21:55:08 +02:00
José Manuel Rolón abe800dfa9 Fixed InsufficientStringBufferDeclaration error detection.
Summary:
Added new method to obtaint the lenght of strings added after a constructor.
Added new test for this case.

Fix: http://sourceforge.net/p/pmd/bugs/1371/

Test Plan: Run tests.

Reviewers: jmsotuyo

Reviewed By: jmsotuyo

Differential Revision: http://ph.monits.com/D12322
2015-09-04 21:53:45 +02:00
Andreas Dangel 203e39b9b3 Added a new if to check for the append statements after an append contructor.
Summary:
Now the rule check for appends after a contructor call.
Added a new test for this case.
Issue: http://sourceforge.net/p/pmd/bugs/1370/

Test Plan: Run tests.

Reviewers: jmsotuyo

Reviewed By: jmsotuyo

Differential Revision: http://ph.monits.com/D12292
2015-09-04 21:34:38 +02:00
Andreas Dangel 922e35453a #1402 Windows-Only: File exclusions are not case insensitive 2015-09-04 21:22:47 +02:00
Andreas Dangel 22671445e2 #1370 ConsecutiveAppendsShouldReuse not detected properly on StringBuffer
Extended unit test
2015-09-04 20:15:07 +02:00
Andreas Dangel e3357987f2 Update changelog 2015-09-04 20:14:56 +02:00
José Manuel Rolón dd8262cf69 Added new append validation.
Check for an append even when the block first child is a LocalVariableDeclaration.
Added new test to check the validation.

Issue: http://sourceforge.net/p/pmd/bugs/1370/
2015-09-04 20:14:09 +02:00
Andreas Dangel 89a3d5dd1e #1384 NullPointerException in ConsecutiveLiteralAppendsRule 2015-08-01 20:28:38 +02:00
Andreas Dangel c5216fed79 Fix site build 2015-07-25 20:38:03 +02:00
Andreas Dangel d182626618 Update release-process with github 2015-07-25 19:59:28 +02:00
Andreas Dangel 4ecb295b06 Fix version of pmd-java8 module 2015-07-25 19:59:07 +02:00
Andreas Dangel 0785cef364 Prepare next development version 2015-07-25 16:00:08 +02:00
Andreas Dangel 0671c2e478 [maven-release-plugin] prepare for next development iteration 2015-07-25 15:28:23 +02:00
Andreas Dangel 1348ed8e06 [maven-release-plugin] prepare release pmd_releases/5.3.3 2015-07-25 15:28:22 +02:00
Andreas Dangel c2ec86bac5 Prepare pmd release 5.3.3 2015-07-25 15:16:54 +02:00
Andreas Dangel 53a1f5280c Create the site separately, so that javadoc aggreate can work 2015-07-25 15:10:19 +02:00
Andreas Dangel 9d8a2dd0a5 Use github page 2015-07-25 15:10:12 +02:00
Andreas Dangel e93e9224ae #1381 CPD Cannot use CSV/VS Renderers because they don't support encoding property 2015-07-19 22:34:57 +02:00
Andreas Dangel df14ea9c95 #1379 PMD CLI: Cannot specify multiple properties 2015-07-13 19:50:40 +02:00
Andreas Dangel 617ca01a68 #1369 ConsecutiveLiteralAppends not detected properly on StringBuffer 2015-06-29 20:28:53 +02:00
Andreas Dangel ee5885065e reformat, whitespace 2015-06-29 19:58:48 +02:00
Andreas Dangel 0b7cca49f1 fix typo 2015-06-28 21:56:55 +02:00
Andreas Dangel 8dc25abcfe #1376 CompareObjectsWithEquals fails for type annotated method parameter 2015-06-28 21:51:04 +02:00
Andreas Dangel 2b92e22546 #1372 False Negative for CloseResource rule.
already fixed with #1375
2015-06-20 18:38:09 +02:00
Andreas Dangel 1b35a59997 #1375 CloseResource not detected properly 2015-06-20 18:15:02 +02:00
Juan Pablo Civile 39eb581134 Fix run.sh for paths with spaces
When redirecting arguments, "$@" must be used.

cherry-picked: 429e1a91a1
cherry-picked: 59f5c86392
2015-06-06 19:38:02 +02:00
Andreas Dangel d28e4f1fb5 #1366 UselessParentheses false positive on multiple equality operators 2015-06-01 20:06:01 +02:00
Andreas Dangel 66c1191984 #1365 Aggregated javadoc report is missing 2015-05-31 14:01:40 +02:00
Andreas Dangel 42726428c5 Fix links on the integrations page 2015-05-31 12:14:45 +02:00
Andreas Dangel 19a13c0ab9 #1364 FieldDeclarationsShouldBeAtStartOfClass false positive using multiple annotations 2015-05-31 10:29:42 +02:00
Andreas Dangel 00ff9f25ae Prepare next development version 2015-05-22 19:28:37 +02:00
Andreas Dangel 793af091c0 [maven-release-plugin] prepare for next development iteration 2015-05-22 18:23:42 +02:00
Andreas Dangel 2c99fbd5e5 [maven-release-plugin] prepare release pmd_releases/5.3.2 2015-05-22 18:23:41 +02:00
Andreas Dangel 2aa1942015 Prepare pmd release 5.3.2 2015-05-22 18:18:12 +02:00
Andreas Dangel c34b55285b Adding back missing changelog entry for 5.3.1 2015-05-21 21:33:29 +02:00
Andreas Dangel b50e49777f #1355 NullPointerException in a java file having a single comment line 2015-05-18 21:17:16 +02:00
Andreas Dangel a416513fc9 reformat, whitespaces 2015-05-18 21:14:12 +02:00
Andreas Dangel 357f206102 #1330 AvoidReassigningParameters does not work with varargs 2015-05-15 20:24:06 +02:00
Andreas Dangel cc43e6f8be #1354 Complex FieldDeclarationsShouldBeAtStartOfClass false positive with Spring annotations 2015-05-15 16:06:29 +02:00
Andreas Dangel 3c316c2018 #1343 MethodNamingConventions for overrided methods 2015-05-15 15:33:40 +02:00
Andreas Dangel cae16d39d7 #1353 False positive "Only One Return" with lambda 2015-05-13 21:33:30 +02:00
Andreas Dangel b5e7cbbaf3 verify #1349 VariableNamingConventions : underscore in final but at first position ? 2015-05-09 18:41:42 +02:00
Andreas Dangel 7d630f6cb3 verify #1347 False positive for GuardLogStatementJavaUtil 2015-05-09 18:37:02 +02:00
Andreas Dangel bc41b00206 verify #1346 VariableNamingConventions do not work for method parameters 2015-05-09 18:31:48 +02:00
Andreas Dangel 171fdb877f #1345 UseCollectionIsEmpty throws NullPointerException 2015-05-09 18:25:12 +02:00
Andreas Dangel 12bbb65ebd Update fluido skin version to 1.4 2015-05-09 18:12:38 +02:00
Andreas Dangel 3d73198ba9 verify #1340 UseStringBufferForStringAppends False Positive with ternary operator 2015-05-01 18:41:21 +02:00
Andreas Dangel e2a7356ccb verify #1341 pmd:GuardDebugLogging violates LOGGER.debug with format "{}"
It's a duplicate of #1224
2015-05-01 18:33:16 +02:00
Andreas Dangel a0d116ca6d #1335 GuardLogStatementJavaUtil should not apply to SLF4J Logger 2015-05-01 18:27:18 +02:00
Andreas Dangel 857ae074e1 #1342 UseConcurrentHashMap false positive (with documentation example) 2015-04-30 20:07:54 +02:00
Andreas Dangel 770fc5763e Update project info reports, display modules after the main pages 2015-04-27 19:47:26 +02:00
Andreas Dangel fba55905b6 Prepare next development version 2015-04-20 21:30:15 +02:00
Andreas Dangel a720b93431 [maven-release-plugin] prepare for next development iteration 2015-04-20 20:15:12 +02:00
Andreas Dangel de7a81202f [maven-release-plugin] prepare release pmd_releases/5.3.1 2015-04-20 20:15:11 +02:00
Andreas Dangel f93a7bc67e Prepare pmd release 5.3.1 2015-04-20 19:55:55 +02:00
Andreas Dangel b6c12fe449 Added deprecated old name for UseSingleton/UseUtilityClass
#1059 and #1339
2015-04-20 19:46:16 +02:00
Andreas Dangel fdb54ecc0e #1337 False positive "Avoid throwing raw exception types" when exception is not thrown 2015-04-18 18:21:11 +02:00
Andreas Dangel 1910a6844c #1332 False Positive: UnusedPrivateMethod 2015-04-18 10:04:31 +02:00
Andreas Dangel 342e0c4789 Update changelog 2015-04-16 19:28:52 +02:00
Andreas Dangel a56f5545fa Merge branch 'fix-null-pointer-exceptions' of https://github.com/Vampire/pmd into Vampire-fix-null-pointer-exceptions 2015-04-16 19:21:47 +02:00
Andreas Dangel 4d03c95158 #1338 The pmd-java8 POM bears the wrong parent module version 2015-04-14 19:50:32 +02:00
Björn Kautler d8961a903a Fix NullPointerException in ClassScope.resolveGenericType() 2015-04-14 11:24:23 +02:00
Björn Kautler f310138f9d Fix NullPointerException in ClassScope.qualifyTypeName() 2015-04-14 11:24:21 +02:00
Björn Kautler e8c36b34f8 Make TypeSet resolvers null-safe 2015-04-14 11:24:20 +02:00
Andreas Dangel 29a32bb2a7 #1333 Error while processing Java file with Lambda expressions 2015-04-13 20:01:28 +02:00
Andreas Dangel fa9a4705e6 Prepare next development version 2015-04-13 19:57:34 +02:00
Andreas Dangel 63f1814c80 Define the goals for releaseing explicitly 2015-04-04 12:39:18 +02:00
Andreas Dangel c44a89cce3 [maven-release-plugin] prepare for next development iteration 2015-04-01 20:06:39 +02:00
Andreas Dangel 094c9c0ec9 [maven-release-plugin] prepare release pmd_releases/5.3.0 2015-04-01 20:06:38 +02:00
Andreas Dangel 8fd4528feb [maven-release-plugin] prepare branch pmd/5.3.x 2015-04-01 19:57:15 +02:00
Andreas Dangel 53055517d1 Prepare pmd release 5.3.0 2015-04-01 19:56:05 +02:00
Andreas Dangel 330708a35b #1197 JUnit4TestShouldUseTestAnnotation for private method 2015-03-27 20:47:58 +01:00
Andreas Dangel ddb7c89505 #1307 False positive: SingularField and lambda-expression 2015-03-27 20:36:18 +01:00
Andreas Dangel 4ad83be724 #1326 PMD 5.3.0-SNAPSHOT doesn't compile under Windows 2015-03-27 19:15:36 +01:00
Andreas Dangel 63017dbf08 pmd-core: convert util/database to junit 4 tests, indentation fixes 2015-03-26 20:48:45 +01:00
Andreas Dangel 79b92b71f1 #1322 MethodReturnsInternalArray on private methods 2015-03-26 20:33:57 +01:00
Andreas Dangel e46bea857a #1323 False positive case of UseAssertTrueInsteadOfAssertEquals 2015-03-26 20:25:19 +01:00
Andreas Dangel 65c2493ec7 #1325 Inner class declared within a method fails to parse (ClassCastException) 2015-03-26 19:54:04 +01:00
Andreas Dangel 12cc353d38 #1324 MethodReturnsInternalArray false positive with clone() 2015-03-25 21:31:17 +01:00
Andreas Dangel e57007e1be dogfood, whitespaces 2015-03-25 20:16:55 +01:00
Andreas Dangel 61e8412afe dogfood, whitespaces 2015-03-24 22:48:01 +01:00
Andreas Dangel 056b2fbaea dogfood, whitespaces 2015-03-23 22:11:23 +01:00
Andreas Dangel 45a0227f17 Use released version 0.9 of pmd-build plugin 2015-03-23 20:32:59 +01:00
Andreas Dangel 231a416c87 [maven-release-plugin] prepare for next development iteration 2015-03-23 20:25:49 +01:00
326 changed files with 14270 additions and 5432 deletions

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>${env.CI_DEPLOY_USERNAME}</username>
<password>${env.CI_DEPLOY_PASSWORD}</password>
</server>
</servers>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
+29
View File
@@ -0,0 +1,29 @@
language: java
before_script:
- SHOULD_DEPLOY=no
- '[ "${TRAVIS_SECURE_ENV_VARS}" = "true" ] && [ "${TRAVIS_PULL_REQUEST}" = "false" ] && SHOULD_DEPLOY=yes || ( [ "${SHOULD_DEPLOY}" != "yes" ] && echo "Skipping Deploy" )'
- export SHOULD_DEPLOY
matrix:
include:
- jdk: oraclejdk7
script:
- '[ "${SHOULD_DEPLOY}" = "yes" ] && mvn test deploy --settings .travis-settings.xml || ( [ "${SHOULD_DEPLOY}" != "yes" ] && echo "Skipping Deploy" )'
- '[ "${SHOULD_DEPLOY}" = "yes" ] || mvn test'
- jdk: oraclejdk8
script: mvn test
branches:
except:
- /^pmd_releases\/\d/
notifications:
email:
recipients:
- adangel@users.sourceforge.net
on_success: always
on_failure: always
cache:
directories:
- "$HOME/.m2"
env:
global:
- secure: KBEuB6U1p5RQXSYe157AwydFr/zpXQPA0IChVCgZV+X1mMyy9ZtrjH1J1AXuviseDDXDbaT25sRnsvpl82rfRw2xOkMGXHy4N95/ylTSr8DjHxTao71BhXsvFycNobFva5y2EGNWqDvpS8I2oSZo7Qk4la3yep3rcJQvcy6RDbbhpDTbL1QMFyadunIBm0WtqbunrMqtjSqaoPsXz8TiQuxHvX4vEXzVbaxV1QQt79Vi+daa6wAV3mRQAugnx+UffsC8JqMxgm06usWeJgCJzxgm8E7clZCLmf53B2TL8dK6bIYbqyvOY3uFxitsTG0d8Z0GOJwXBgZNgbniTRO8ZJSty5eZP8LBybbjVLSL25DNTWtCjADUL/uySnXIEidlMt2N/3QmH7zrGAfAk/tIwKpdRca2GLLydeXf6PSkiahnPEkIY/QupcsOLELhdifpdOjb8QW1OenA+vUbNM9dccLwKnX6Fj9cu4VQG601AcYDr2eyhq8WYkr3wYdw/6KdUa3hmplowTBs+qguppP+eOSgGuEsy38KLtqnvm6WlHy6tcLmcVYKG3DmR1b7TWXsOXC6/VMH8BHBkvsF1QdRg9+Cgx07vX3Hw7roPiYzmaO9Ajs20ATsUfRskMuWCTeTSK5pN8X27veRCZlhFjeKQMDdmfVwzpAfRgKsl3TEn1I=
- secure: U1DfAv6acUUWe+dao/ZSDUX64JRadNJY16rITsdrM4ZNAJSuXpEY3p/LWcYjN7D49YmyutbXH9+L3KKQUQGrGXj9QTarfYvd8ZsKt4FK8yv7AFy+RQNIbAjNEHBzHx15p+srMheTaetl7aLwY0qhF+D/RtGapxHKyY4dBHrb0lp8VGyiCiL7Aop8GGskosi1mtirPBp/BStPZ2bEyxG0QzU5SsVWkJWwV9aWLPVAR/n7Xgx/6Gjl6Fed2c/WSrWi4vchm3Ny8pfTweOax3PGYYjBVxIfuX0mqmwuJsY7gNfXCfN3dPiPKGJPFy1pC+LGyGkklO5ReKFLd4O1ME6fU0dlIGfD6n+Q4H6/w9FHXegcKTfWIJm/MFa6vA/tJM5R6zJQuiTQJboHm/UmS/iQj76z0p6sK15Xp5vFId+/dHKqa8xY+Bt6HiXy6z401HOc8QcYBAf7TqhqUt/ZE7HN4be46uR90KmzIrWz6wEoDW7HfwQ9ZMbs55zoOXrvekyE9/gXskypO0p2JT3Y0vlvO27KQvIrSwI480kOVOrlyrYA+LZqlcKaayOuCuZh4lITQUYinUoZZict5joYthH+Cyh2zovoBpxsntDJdMnaZNLtSC7hlhpbMBYaT2y1O6vZH5Yix0mxuDvs/x6ogP5CNBeUYlXhaL+g4GnwKyr0ZA0=
+36 -14
View File
@@ -1,27 +1,49 @@
[![PMD - Don't shoot the messenger][PMDLogo]][website]
# PMD
PMD
===
[![Build Status](https://travis-ci.org/pmd/pmd.svg?branch=master)](https://travis-ci.org/pmd/pmd)
## About
About
-----
PMD is a source code analyzer. It finds common programming flaws like unused variables, empty catch blocks,
unnecessary object creation, and so forth. It supports Java, JavaScript, XML, XSL.
Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code in
Java, C, C++, C#, PHP, Ruby, Fortran, JavaScript.
Source
------
Our latest source of PMD can be found on [GitHub]. Fork us!
The current status of this repo can be seen at [BuildHive].
## Source
Our latest source of PMD can be found on [GitHub]. Fork us!
### How to build PMD?
You'll need to have a `~/.m2/toolchains.xml` file setup with jdk 1.6 (for pmd 5.3.x), jdk 1.7 (for pmd 5.4.x and pmd 5.5.x)
and jdk 1.8 (for some features in pmd 5.5.x). See [maven toolchains](https://maven.apache.org/guides/mini/guide-using-toolchains.html).
A example file can be found here: [example-toolchains.xml](https://github.com/pmd/pmd/blob/master/example-toolchains.xml).
Use maven in the top-level directory:
mvn clean package
This will create the zip files in the directory `pmd-dist/target`:
cd pmd-dist/target
ls *.zip
That's all !
### Bug Reports
We are using Sourceforge for bug tracking. Please file your bugs at <https://sourceforge.net/p/pmd/bugs/>.
### Pull Requests
Pull requests are always welcome: <https://github.com/pmd/pmd/pulls>
## News and Website
News and Website
----------------
More information can be found on our [Website] and on [SourceForge].
[PMDLogo]: http://pmd.sourceforge.net/pmd_logo.png
[GitHub]: https://github.com/pmd/pmd
[BuildHive]: https://buildhive.cloudbees.com/job/pmd/
[Website]: http://pmd.sourceforge.net
[Website]: https://pmd.github.io
[SourceForge]: https://sourceforge.net/projects/pmd/
Executable
+308
View File
File diff suppressed because it is too large. Load diff
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<!-- place this file in ${user.home}/.m2/toolchains.xml -->
<toolchain>
<type>jdk</type>
<provides>
<version>1.6</version>
</provides>
<configuration>
<jdkHome>/path/to/jdk/1.6</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.7</version>
</provides>
<configuration>
<jdkHome>/path/to/jdk/1.7</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<version>1.8</version>
</provides>
<configuration>
<jdkHome>/path/to/jdk/1.8</jdkHome>
</configuration>
</toolchain>
</toolchains>
+2 -2
View File
@@ -12,7 +12,7 @@
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-build</artifactId>
<name>PMD Build Plugin</name>
<version>0.9</version>
<version>0.10-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<description>
<![CDATA[
@@ -42,7 +42,7 @@ only if you modify the java code.
<connection>scm:git:git://github.com/pmd/pmd.git</connection>
<developerConnection>scm:git:ssh://git@github.com/pmd/pmd.git</developerConnection>
<url>https://github.com/pmd/pmd</url>
<tag>pmd-build/0.9</tag>
<tag>HEAD</tag>
</scm>
<developers>
-19
View File
@@ -1,19 +0,0 @@
How to build PMD ?
==================
Simply use maven: $ mvn compile
PMD now uses a small plugin to generate its website, so if you want to build the
website ($ mvn site), you'll need to install it:
$ cd ../maven-plugin-pmd-build
$ mvn clean install
That's all !
How to quickly build a "release" (zipfiles - for testing purpose only) ?
------------------------------------------------------------------------
$ mvn -Dmaven.test.skip=true -Dmaven.clover.skip=true verify post-site
Full release process is documented in src/site/xdocs/pmd-release-process.xml
+7 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>5.3.0-SNAPSHOT</version>
<version>5.3.9-SNAPSHOT</version>
</parent>
<properties>
@@ -93,6 +93,12 @@
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>net.sourceforge.saxon</groupId>
@@ -22,16 +22,25 @@ import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.io.IOUtils;
import net.sourceforge.pmd.benchmark.Benchmark;
import net.sourceforge.pmd.benchmark.Benchmarker;
import net.sourceforge.pmd.benchmark.TextReport;
import net.sourceforge.pmd.cli.PMDCommandLineInterface;
import net.sourceforge.pmd.cli.PMDParameters;
import net.sourceforge.pmd.lang.*;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageFilenameFilter;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.lang.LanguageVersionDiscoverer;
import net.sourceforge.pmd.lang.LanguageVersionHandler;
import net.sourceforge.pmd.lang.Parser;
import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.processor.MonoThreadProcessor;
import net.sourceforge.pmd.processor.MultiThreadProcessor;
import net.sourceforge.pmd.renderers.Renderer;
import net.sourceforge.pmd.stat.Metric;
import net.sourceforge.pmd.util.ClasspathClassLoader;
import net.sourceforge.pmd.util.FileUtil;
import net.sourceforge.pmd.util.IOUtil;
import net.sourceforge.pmd.util.SystemUtils;
@@ -353,6 +362,10 @@ public class PMD {
} else {
new MonoThreadProcessor(configuration).processFiles(ruleSetFactory, files, ctx, renderers);
}
if (configuration.getClassLoader() instanceof ClasspathClassLoader) {
IOUtil.tryCloseClassLoader(configuration.getClassLoader());
}
}
private static void sortFiles(final PMDConfiguration configuration, final List<DataSource> files) {
@@ -380,6 +393,13 @@ public class PMD {
*/
public static List<DataSource> getApplicableFiles(PMDConfiguration configuration, Set<Language> languages) {
long startFiles = System.nanoTime();
List<DataSource> files = internalGetApplicableFiles(configuration, languages);
long endFiles = System.nanoTime();
Benchmarker.mark(Benchmark.CollectFiles, endFiles - startFiles, 0);
return files;
}
private static List<DataSource> internalGetApplicableFiles(PMDConfiguration configuration, Set<Language> languages) {
LanguageFilenameFilter fileSelector = new LanguageFilenameFilter(languages);
List<DataSource> files = new ArrayList<DataSource>();
@@ -398,8 +418,6 @@ public class PMD {
throw new RuntimeException("Problem with DBURI: " + uriString, ex);
}
}
long endFiles = System.nanoTime();
Benchmarker.mark(Benchmark.CollectFiles, endFiles - startFiles, 0);
return files;
}
@@ -495,6 +513,8 @@ public class PMD {
pmdVersion = properties.getProperty("version");
} catch (IOException e) {
LOG.log(Level.FINE, "Couldn't determine version of PMD", e);
} finally {
IOUtils.closeQuietly(stream);
}
}
if (pmdVersion == null) {
@@ -54,6 +54,8 @@ import net.sourceforge.pmd.util.IOUtil;
* <li>A comma separated list of input paths to process for source files.
* This may include files, directories, archives (e.g. ZIP files), etc.
* {@link #getInputPaths()}</li>
* <li>A flag which controls, whether {@link RuleSetFactoryCompatibility} filter
* should be used or not: #isRuleSetFactoryCompatibilityEnabled;
* </ul>
* <p>
* <ul>
@@ -94,6 +96,7 @@ public class PMDConfiguration extends AbstractConfiguration {
private RulePriority minimumPriority = RulePriority.LOW;
private String inputPaths;
private String inputUri;
private boolean ruleSetFactoryCompatibilityEnabled = true;
// Reporting options
private String reportFormat;
@@ -493,4 +496,27 @@ public class PMDConfiguration extends AbstractConfiguration {
public void setBenchmark(boolean benchmark) {
this.benchmark = benchmark;
}
/**
* Checks if the rule set factory compatibility feature is enabled.
*
* @return true, if the rule set factory compatibility feature is enabled
*
* @see RuleSetFactoryCompatibility
*/
public boolean isRuleSetFactoryCompatibilityEnabled() {
return ruleSetFactoryCompatibilityEnabled;
}
/**
* Sets the rule set factory compatibility feature enabled/disabled.
*
* @param ruleSetFactoryCompatibilityEnabled <code>true</code> if the feature should be enabled
*
* @see RuleSetFactoryCompatibility
*/
public void setRuleSetFactoryCompatibilityEnabled(boolean ruleSetFactoryCompatibilityEnabled) {
this.ruleSetFactoryCompatibilityEnabled = ruleSetFactoryCompatibilityEnabled;
}
}
@@ -13,6 +13,12 @@ import net.sourceforge.pmd.lang.rule.properties.StringProperty;
/**
* This is the basic Rule interface for PMD rules.
*
* <p><strong>Thread safety:</strong>
* PMD will create one instance of a rule per thread. The instances are
* not shared across different threads. However, a single rule instance is
* reused for analyzing multiple files.
* </p>
*/
// FUTURE Implement Cloneable and clone()
public interface Rule extends PropertySource {
@@ -309,17 +309,15 @@ public class RuleSet {
Benchmarker.mark(Benchmark.Rule, rule.getName(), end - start, 1);
start = end;
}
} catch (Throwable t) {
if (t instanceof ThreadDeath) {
throw (ThreadDeath)t;
} else if (ctx.isIgnoreExceptions()) {
} catch (RuntimeException e) {
if (ctx.isIgnoreExceptions()) {
if (LOG.isLoggable(Level.WARNING)) {
LOG.log(Level.WARNING, "Exception applying rule " + rule.getName()
+ " on file " + ctx.getSourceCodeFilename() + ", continuing with next rule",
t);
e);
}
} else {
throw new RuntimeException(t);
throw e;
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,190 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.nio.charset.Charset;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
/**
* Provides a simple filter mechanism to avoid failing to parse an old ruleset, which references rules, that
* have either been removed from PMD already or renamed or moved to another ruleset.
*
* @see <a href="https://sourceforge.net/p/pmd/bugs/1360/">issue 1360</a>
*/
public class RuleSetFactoryCompatibility {
private static final Logger LOG = Logger.getLogger(RuleSetFactoryCompatibility.class.getName());
private List<RuleSetFilter> filters = new LinkedList<RuleSetFilter>();
/**
* Creates a new instance of the compatibility filter with the built-in filters for the
* modified PMD rules.
*/
public RuleSetFactoryCompatibility() {
// PMD 5.3.0
addFilterRuleRenamed("java", "design", "UncommentedEmptyMethod", "UncommentedEmptyMethodBody");
addFilterRuleRemoved("java", "controversial", "BooleanInversion");
// PMD 5.3.1
addFilterRuleRenamed("java", "design", "UseSingleton", "UseUtilityClass");
// PMD 5.4.0
addFilterRuleMoved("java", "basic", "empty", "EmptyCatchBlock");
addFilterRuleMoved("java", "basic", "empty", "EmptyIfStatement");
addFilterRuleMoved("java", "basic", "empty", "EmptyWhileStmt");
addFilterRuleMoved("java", "basic", "empty", "EmptyTryBlock");
addFilterRuleMoved("java", "basic", "empty", "EmptyFinallyBlock");
addFilterRuleMoved("java", "basic", "empty", "EmptySwitchStatements");
addFilterRuleMoved("java", "basic", "empty", "EmptySynchronizedBlock");
addFilterRuleMoved("java", "basic", "empty", "EmptyStatementNotInLoop");
addFilterRuleMoved("java", "basic", "empty", "EmptyInitializer");
addFilterRuleMoved("java", "basic", "empty", "EmptyStatementBlock");
addFilterRuleMoved("java", "basic", "empty", "EmptyStaticInitializer");
addFilterRuleMoved("java", "basic", "unnecessary", "UnnecessaryConversionTemporary");
addFilterRuleMoved("java", "basic", "unnecessary", "UnnecessaryReturn");
addFilterRuleMoved("java", "basic", "unnecessary", "UnnecessaryFinalModifier");
addFilterRuleMoved("java", "basic", "unnecessary", "UselessOverridingMethod");
addFilterRuleMoved("java", "basic", "unnecessary", "UselessOperationOnImmutable");
addFilterRuleMoved("java", "basic", "unnecessary", "UnusedNullCheckInEquals");
addFilterRuleMoved("java", "basic", "unnecessary", "UselessParentheses");
}
void addFilterRuleRenamed(String language, String ruleset, String oldName, String newName) {
filters.add(RuleSetFilter.ruleRenamed(language, ruleset, oldName, newName));
}
void addFilterRuleMoved(String language, String oldRuleset, String newRuleset, String ruleName) {
filters.add(RuleSetFilter.ruleMoved(language, oldRuleset, newRuleset, ruleName));
}
void addFilterRuleRemoved(String language, String ruleset, String name) {
filters.add(RuleSetFilter.ruleRemoved(language, ruleset, name));
}
/**
* Applies all configured filters against the given input stream.
* The resulting reader will contain the original ruleset modified by
* the filters.
*
* @param stream
* @return
* @throws IOException
*/
public Reader filterRuleSetFile(InputStream stream) throws IOException {
byte[] bytes = IOUtils.toByteArray(stream);
String encoding = determineEncoding(bytes);
String ruleset = new String(bytes, encoding);
ruleset = applyAllFilters(ruleset);
return new StringReader(ruleset);
}
private String applyAllFilters(String in) {
String result = in;
for (RuleSetFilter filter : filters) {
result = filter.apply(result);
}
return result;
}
private static final Pattern ENCODING_PATTERN = Pattern.compile("encoding=\"([^\"]+)\"");
/**
* Determines the encoding of the given bytes, assuming this is a XML document, which specifies
* the encoding in the first 1024 bytes.
*
* @param bytes the input bytes, might be more or less than 1024 bytes
* @return the determined encoding, falls back to the default UTF-8 encoding
*/
String determineEncoding(byte[] bytes) {
String firstBytes = new String(bytes, 0, bytes.length > 1024 ? 1024 : bytes.length, Charset.forName("ISO-8859-1"));
Matcher matcher = ENCODING_PATTERN.matcher(firstBytes);
String encoding = Charset.forName("UTF-8").name();
if (matcher.find()) {
encoding = matcher.group(1);
}
return encoding;
}
private static class RuleSetFilter {
private final Pattern refPattern;
private final String replacement;
private Pattern exclusionPattern;
private String exclusionReplacement;
private final String logMessage;
private RuleSetFilter(String refPattern, String replacement, String logMessage) {
this.logMessage = logMessage;
if (replacement != null) {
this.refPattern = Pattern.compile("ref=\"" + Pattern.quote(refPattern) + "\"");
this.replacement = "ref=\"" + replacement + "\"";
} else {
this.refPattern = Pattern.compile("<rule\\s+ref=\"" + Pattern.quote(refPattern) + "\"\\s*/>");
this.replacement = "";
}
}
private void setExclusionPattern(String oldName, String newName) {
exclusionPattern = Pattern.compile("<exclude\\s+name=[\"']" + Pattern.quote(oldName) + "[\"']\\s*/>");
if (newName != null) {
exclusionReplacement = "<exclude name=\"" + newName + "\" />";
} else {
exclusionReplacement = "";
}
}
public static RuleSetFilter ruleRenamed(String language, String ruleset, String oldName, String newName) {
String base = "rulesets/" + language + "/" + ruleset + ".xml/";
RuleSetFilter filter = new RuleSetFilter(base + oldName, base + newName,
"The rule \"" + oldName + "\" has been renamed to \"" + newName + "\". Please change your ruleset!");
filter.setExclusionPattern(oldName, newName);
return filter;
}
public static RuleSetFilter ruleMoved(String language, String oldRuleset, String newRuleset, String ruleName) {
String base = "rulesets/" + language + "/";
return new RuleSetFilter(base + oldRuleset + ".xml/" + ruleName, base + newRuleset + ".xml/" + ruleName,
"The rule \"" + ruleName + "\" has been moved from ruleset \"" + oldRuleset + "\" to \"" + newRuleset + "\". Please change your ruleset!");
}
public static RuleSetFilter ruleRemoved(String language, String ruleset, String name) {
RuleSetFilter filter = new RuleSetFilter("rulesets/" + language + "/" + ruleset + ".xml/" + name, null,
"The rule \"" + name + "\" in ruleset \"" + ruleset + "\" has been removed from PMD and no longer exists. Please change your ruleset!");
filter.setExclusionPattern(name, null);
return filter;
}
String apply(String in) {
String result = in;
Matcher matcher = refPattern.matcher(in);
if (matcher.find()) {
result = matcher.replaceAll(replacement);
if (LOG.isLoggable(Level.WARNING)) {
LOG.warning("Applying rule set filter: " + logMessage);
}
}
if (exclusionPattern == null) return result;
Matcher exclusions = exclusionPattern.matcher(result);
if (exclusions.find()) {
result = exclusions.replaceAll(exclusionReplacement);
if (LOG.isLoggable(Level.WARNING)) {
LOG.warning("Applying rule set filter for exclusions: " + logMessage);
}
}
return result;
}
}
}
@@ -67,6 +67,9 @@ public final class RulesetsFactoryUtils {
public static RuleSetFactory getRulesetFactory(PMDConfiguration configuration) {
RuleSetFactory ruleSetFactory = new RuleSetFactory();
ruleSetFactory.setMinimumPriority(configuration.getMinimumPriority());
if (!configuration.isRuleSetFactoryCompatibilityEnabled()) {
ruleSetFactory.disableCompatibilityFilter();
}
return ruleSetFactory;
}
@@ -27,6 +27,7 @@ public class PMDTask extends Task {
private boolean shortFilenames;
private String suppressMarker;
private String rulesetFiles;
private boolean noRuleSetCompatibility;
private String encoding;
private int threads;
private int minimumPriority;
@@ -236,4 +237,11 @@ public class PMDTask extends Task {
return nestedRules;
}
public boolean isNoRuleSetCompatibility() {
return noRuleSetCompatibility;
}
public void setNoRuleSetCompatibility(boolean noRuleSetCompatibility) {
this.noRuleSetCompatibility = noRuleSetCompatibility;
}
}
@@ -14,6 +14,14 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Handler;
import java.util.logging.Level;
import org.apache.commons.io.IOUtils;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
import net.sourceforge.pmd.PMD;
import net.sourceforge.pmd.PMDConfiguration;
import net.sourceforge.pmd.Report;
@@ -31,20 +39,13 @@ import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.renderers.AbstractRenderer;
import net.sourceforge.pmd.renderers.Renderer;
import net.sourceforge.pmd.util.IOUtil;
import net.sourceforge.pmd.util.StringUtil;
import net.sourceforge.pmd.util.datasource.DataSource;
import net.sourceforge.pmd.util.datasource.FileDataSource;
import net.sourceforge.pmd.util.log.AntLogHandler;
import net.sourceforge.pmd.util.log.ScopedLogHandlersManager;
import org.apache.commons.io.IOUtils;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
public class PMDTaskImpl {
private Path classpath;
@@ -68,6 +69,7 @@ public class PMDTaskImpl {
this.failOnRuleViolation = true;
}
configuration.setRuleSets(task.getRulesetFiles());
configuration.setRuleSetFactoryCompatibilityEnabled(!task.isNoRuleSetCompatibility());
if (task.getEncoding() != null) {
configuration.setSourceEncoding(task.getEncoding());
}
@@ -100,6 +102,9 @@ public class PMDTaskImpl {
// Setup RuleSetFactory and validate RuleSets
RuleSetFactory ruleSetFactory = new RuleSetFactory();
ruleSetFactory.setClassLoader(configuration.getClassLoader());
if (!configuration.isRuleSetFactoryCompatibilityEnabled()) {
ruleSetFactory.disableCompatibilityFilter();
}
try {
// This is just used to validate and display rules. Each thread will
// create its own ruleset
@@ -228,25 +233,25 @@ public class PMDTaskImpl {
}
private void setupClassLoader() {
if (classpath == null) {
project.log("Using the normal ClassLoader", Project.MSG_VERBOSE);
} else {
project.log("Using the AntClassLoader", Project.MSG_VERBOSE);
// must be true, otherwise you'll get ClassCastExceptions as classes
// are loaded twice
// and exist in multiple class loaders
boolean parentFirst = true;
configuration.setClassLoader(new AntClassLoader(Thread.currentThread().getContextClassLoader(), project,
classpath, parentFirst));
classpath = new Path(project);
}
/*
* 'basedir' is added to the path to make sure that relative paths
* such as "<ruleset>resources/custom_ruleset.xml</ruleset>" still
* work when ant is invoked from a different directory using "-f"
*/
classpath.add(new Path(null, project.getBaseDir().toString()));
project.log("Using the AntClassLoader: " + classpath, Project.MSG_VERBOSE);
// must be true, otherwise you'll get ClassCastExceptions as classes
// are loaded twice
// and exist in multiple class loaders
boolean parentFirst = true;
configuration.setClassLoader(new AntClassLoader(Thread.currentThread().getContextClassLoader(), project,
classpath, parentFirst));
try {
/*
* 'basedir' is added to the path to make sure that relative paths
* such as "<ruleset>resources/custom_ruleset.xml</ruleset>" still
* work when ant is invoked from a different directory using "-f"
*/
configuration.prependClasspath(project.getBaseDir().toString());
if (auxClasspath != null) {
project.log("Using auxclasspath: " + auxClasspath, Project.MSG_VERBOSE);
configuration.prependClasspath(auxClasspath.toString());
@@ -263,6 +268,7 @@ public class PMDTaskImpl {
doTask();
} finally {
logManager.close();
IOUtil.tryCloseClassLoader(configuration.getClassLoader());
}
}
@@ -130,11 +130,12 @@ public class Benchmarker {
long start = System.currentTimeMillis();
for (DataSource dataSource: dataSources) {
parser.parse(
dataSource.getNiceFileName(false, null),
new InputStreamReader(dataSource.getInputStream()
)
);
InputStreamReader reader = new InputStreamReader(dataSource.getInputStream());
try {
parser.parse(dataSource.getNiceFileName(false, null), reader);
} finally {
IOUtils.closeQuietly(reader);
}
}
if (debug) {
@@ -169,13 +170,15 @@ public class Benchmarker {
RuleContext ctx = new RuleContext();
long start = System.currentTimeMillis();
Reader reader = null;
for (DataSource dataSource: dataSources) {
reader = new InputStreamReader(dataSource.getInputStream());
ctx.setSourceCodeFilename(dataSource.getNiceFileName(false, null));
new SourceCodeProcessor(config).processSourceCode(reader, ruleSets, ctx);
IOUtils.closeQuietly(reader);
}
Reader reader = new InputStreamReader(dataSource.getInputStream());
try {
ctx.setSourceCodeFilename(dataSource.getNiceFileName(false, null));
new SourceCodeProcessor(config).processSourceCode(reader, ruleSets, ctx);
} finally {
IOUtils.closeQuietly(reader);
}
}
long end = System.currentTimeMillis();
long elapsed = end - start;
results.add(new RuleDuration(elapsed, rule));
@@ -4,6 +4,8 @@
package net.sourceforge.pmd.cli;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import net.sourceforge.pmd.PMDConfiguration;
@@ -60,8 +62,9 @@ public class PMDParameters {
@Parameter(names = { "-minimumpriority", "-min" }, description = "Rule priority threshold; rules with lower priority than configured here won't be used. Default is '5' which is the lowest priority.", converter = RulePriorityConverter.class)
private RulePriority minimumPriority = RulePriority.LOW;
@Parameter(names = { "-property", "-P" }, description = "{name}={value}: Define a property for the report format.", converter = PropertyConverter.class)
private Properties properties = new Properties();
@Parameter(names = { "-property", "-P" }, description = "{name}={value}: Define a property for the report format.",
converter = PropertyConverter.class)
private List<Properties> properties = new ArrayList<Properties>();
@Parameter(names = { "-reportfile", "-r" }, description = "Sends report output to a file; default to System.out.")
private String reportfile = null;
@@ -75,13 +78,15 @@ public class PMDParameters {
@Parameter(names = "-auxclasspath", description = "Specifies the classpath for libraries used by the source code. This is used by the type resolution. Alternatively, a 'file://' URL to a text file containing path elements on consecutive lines can be specified.")
private String auxclasspath;
@Parameter(names = "-norulesetcompatibility", description = "Disable the ruleset compatibility filter. The filter is active by default and tries automatically 'fix' old ruleset files with old rule names")
private boolean noRuleSetCompatibility = false;
// this has to be a public static class, so that JCommander can use it!
public static class PropertyConverter implements IStringConverter<Properties> {
private static final char SEPARATOR = '=';
public Properties convert(String value) {
Properties properties = new Properties();
int indexOfSeparator = value.indexOf(SEPARATOR);
if (indexOfSeparator < 0) {
throw new ParameterException(
@@ -89,6 +94,7 @@ public class PMDParameters {
}
String propertyName = value.substring(0, indexOfSeparator);
String propertyValue = value.substring(indexOfSeparator + 1);
Properties properties = new Properties();
properties.put(propertyName, propertyValue);
return properties;
}
@@ -127,6 +133,7 @@ public class PMDParameters {
configuration.setReportProperties(params.getProperties());
configuration.setReportShortNames(params.isShortnames());
configuration.setRuleSets(params.getRulesets());
configuration.setRuleSetFactoryCompatibilityEnabled(!params.noRuleSetCompatibility);
configuration.setShowSuppressedViolations(params.isShowsuppressed());
configuration.setSourceEncoding(params.getEncoding());
configuration.setStressTest(params.isStress());
@@ -186,7 +193,11 @@ public class PMDParameters {
}
public Properties getProperties() {
return properties;
Properties result = new Properties();
for (Properties p : properties) {
result.putAll(p);
}
return result;
}
public String getReportfile() {
@@ -12,44 +12,50 @@ import java.util.List;
*/
public abstract class AbstractTokenizer implements Tokenizer {
//FIXME depending on subclasses to assign local vars is rather fragile - better to make private and setup via explicit hook methods
protected List<String> stringToken; // List<String>, should be set by sub classes
protected List<String> ignorableCharacter; // List<String>, should be set by sub classes
// FIXME:Maybe an array of 'char' would be better for performance ?
protected List<String> ignorableStmt; // List<String>, should be set by sub classes
protected char oneLineCommentChar = '#'; // Most script languages ( shell, ruby, python,...) use this symbol for comment line
// FIXME depending on subclasses to assign local vars is rather fragile -
// better to make private and setup via explicit hook methods
private List<String> code;
private int lineNumber = 0;
private String currentLine;
protected List<String> stringToken; // List<String>, should be set by sub
// classes
protected List<String> ignorableCharacter; // List<String>, should be set by
// sub classes
// FIXME:Maybe an array of 'char'
// would be better for
// performance ?
protected List<String> ignorableStmt; // List<String>, should be set by sub
// classes
protected char oneLineCommentChar = '#'; // Most script languages ( shell,
// ruby, python,...) use this
// symbol for comment line
protected boolean spanMultipleLinesString = true; // Most languages do, so default is true
protected Character spanMultipleLinesLineContinuationCharacter = null;
private List<String> code;
private int lineNumber = 0;
private String currentLine;
private boolean downcaseString = true;
protected boolean spanMultipleLinesString = true; // Most languages do, so
// default is true
protected Character spanMultipleLinesLineContinuationCharacter = null;
private boolean downcaseString = true;
public void tokenize(SourceCode tokens, Tokens tokenEntries) {
code = tokens.getCode();
for ( lineNumber = 0; lineNumber < code.size(); lineNumber++ ) {
currentLine = code.get(lineNumber);
for (lineNumber = 0; lineNumber < code.size(); lineNumber++) {
currentLine = code.get(lineNumber);
int loc = 0;
while ( loc < currentLine.length() ) {
while (loc < currentLine.length()) {
StringBuilder token = new StringBuilder();
loc = getTokenFromLine(token,loc);
loc = getTokenFromLine(token, loc);
if (token.length() > 0 && !isIgnorableString(token.toString())) {
if (downcaseString) {
token = new StringBuilder(token.toString().toLowerCase());
}
// need to re-think how to link this
// if ( CPD.debugEnable ) {
// System.out.println("Token added:" + token.toString());
// }
tokenEntries.add(new TokenEntry(token.toString(),
tokens.getFileName(),
lineNumber)
);
// need to re-think how to link this
// if ( CPD.debugEnable ) {
// System.out.println("Token added:" + token.toString());
// }
tokenEntries.add(new TokenEntry(token.toString(), tokens.getFileName(), lineNumber));
}
}
@@ -69,7 +75,8 @@ public abstract class AbstractTokenizer implements Tokenizer {
}
} else if (isString(tok)) {
if (token.length() > 0) {
return j; // we need to now parse the string as a separate token.
return j; // we need to now parse the string as a
// separate token.
} else {
// we are at the start of a string
return parseString(token, j, tok);
@@ -91,66 +98,67 @@ public abstract class AbstractTokenizer implements Tokenizer {
boolean escaped = false;
boolean done = false;
char tok = ' '; // this will be replaced.
while ((loc < currentLine.length()) && ! done) {
while (loc < currentLine.length() && !done) {
tok = currentLine.charAt(loc);
if (escaped && tok == stringDelimiter) { // Found an escaped string
escaped = false;
} else if (tok == stringDelimiter && (token.length() > 0)) { // We are done, we found the end of the string...
} else if (tok == stringDelimiter && token.length() > 0) {
// We are done, we found the end of the string...
done = true;
} else if (tok == '\\') { // Found an escaped char
escaped = true;
} else { // Adding char...
} else { // Adding char...
escaped = false;
}
//Adding char to String:" + token.toString());
// Adding char to String:" + token.toString());
token.append(tok);
loc++;
}
// Handling multiple lines string
if ( ! done && // ... we didn't find the end of the string
loc >= currentLine.length() && // ... we have reach the end of the line ( the String is incomplete, for the moment at least)
spanMultipleLinesString && // ... the language allow multiple line span Strings
lineNumber < code.size() - 1 // ... there is still more lines to parse
) {
// removes last character, if it is the line continuation (e.g. backslash) character
if (!done && // ... we didn't find the end of the string
loc >= currentLine.length() && // ... we have reach the end of
// the line ( the String is
// incomplete, for the moment at
// least)
spanMultipleLinesString && // ... the language allow multiple
// line span Strings
lineNumber < code.size() - 1 // ... there is still more lines to
// parse
) {
// removes last character, if it is the line continuation (e.g.
// backslash) character
if (spanMultipleLinesLineContinuationCharacter != null && token.length() > 0
&& token.charAt(token.length() - 1) == spanMultipleLinesLineContinuationCharacter.charValue()) {
token.deleteCharAt(token.length() - 1);
}
// parsing new line
currentLine = code.get(++lineNumber);
// Warning : recursive call !
loc = parseString(token, 0, stringDelimiter);
// parsing new line
currentLine = code.get(++lineNumber);
// Warning : recursive call !
loc = parseString(token, 0, stringDelimiter);
}
return loc + 1;
}
private boolean ignoreCharacter(char tok)
{
return ignorableCharacter.contains(String.valueOf(tok));
private boolean ignoreCharacter(char tok) {
return ignorableCharacter.contains(String.valueOf(tok));
}
private boolean isString(char tok)
{
return stringToken.contains(String.valueOf(tok));
private boolean isString(char tok) {
return stringToken.contains(String.valueOf(tok));
}
private boolean isComment(char tok)
{
private boolean isComment(char tok) {
return tok == oneLineCommentChar;
}
private int getCommentToken(StringBuilder token, int loc)
{
while (loc < currentLine.length())
{
private int getCommentToken(StringBuilder token, int loc) {
while (loc < currentLine.length()) {
token.append(currentLine.charAt(loc++));
}
return loc;
}
private boolean isIgnorableString(String token)
{
return ignorableStmt.contains(token);
private boolean isIgnorableString(String token) {
return ignorableStmt.contains(token);
}
}
@@ -5,7 +5,6 @@ package net.sourceforge.pmd.cpd;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Arrays;
@@ -77,7 +76,7 @@ public class CPDCommandLineInterface {
//Add files
if ( null != arguments.getFiles() && ! arguments.getFiles().isEmpty() )
{
addSourcesFilesToCPD(arguments.getFiles(), arguments.filenameFilter(), cpd, !arguments.isNonRecursive());
addSourcesFilesToCPD(arguments.getFiles(), cpd, !arguments.isNonRecursive());
}
//Add Database URIS
@@ -87,13 +86,13 @@ public class CPDCommandLineInterface {
}
cpd.go();
System.out.println(arguments.getRenderer().render(cpd.getMatches()));
if (cpd.getMatches().hasNext()) {
System.out.println(arguments.getRenderer().render(cpd.getMatches()));
setStatusCodeOrExit(DUPLICATE_CODE_FOUND);
}
}
private static void addSourcesFilesToCPD(List<File> files, FilenameFilter filter, CPD cpd, boolean recursive) {
private static void addSourcesFilesToCPD(List<File> files, CPD cpd, boolean recursive) {
try {
for (File file : files) {
if (!file.exists()) {
@@ -105,13 +104,7 @@ public class CPDCommandLineInterface {
cpd.addAllInDirectory(file);
}
} else {
//Add a single file if it is accepted by the file filter
File directory = file.getAbsoluteFile().getParentFile();
String filename = file.getName();
if (filter.accept(directory, filename)) {
cpd.add(file);
}
cpd.add(file);
}
}
} catch (IOException e) {
File diff suppressed because it is too large. Load diff
@@ -47,6 +47,7 @@ public class CPDTask extends Task {
private boolean ignoreLiterals;
private boolean ignoreIdentifiers;
private boolean ignoreAnnotations;
private boolean ignoreUsings;
private boolean skipLexicalErrors;
private boolean skipDuplicateFiles;
private boolean skipBlocks = true;
@@ -104,6 +105,9 @@ public class CPDTask extends Task {
if (ignoreAnnotations) {
p.setProperty(Tokenizer.IGNORE_ANNOTATIONS, "true");
}
if (ignoreUsings) {
p.setProperty(Tokenizer.IGNORE_USINGS, "true");
}
p.setProperty(Tokenizer.OPTION_SKIP_BLOCKS, Boolean.toString(skipBlocks));
p.setProperty(Tokenizer.OPTION_SKIP_BLOCKS_PATTERN, skipBlocksPattern);
return LanguageFactory.createLanguage(language, p);
@@ -188,6 +192,10 @@ public class CPDTask extends Task {
this.ignoreAnnotations = value;
}
public void setIgnoreUsings(boolean value) {
this.ignoreUsings = value;
}
public void setSkipLexicalErrors(boolean skipLexicalErrors) {
this.skipLexicalErrors = skipLexicalErrors;
}
@@ -85,6 +85,7 @@ public class GUI implements CPDListener {
public boolean canIgnoreIdentifiers() { return false; }
public boolean canIgnoreLiterals() { return false; }
public boolean canIgnoreAnnotations() { return false; }
public boolean canIgnoreUsings() { return false; }
public abstract String[] extensions();
}
@@ -121,6 +122,10 @@ public class GUI implements CPDListener {
public boolean canIgnoreLiterals() {
return "java".equals(terseName);
}
@Override
public boolean canIgnoreUsings() {
return "cs".equals(terseName);
}
};
}
LANGUAGE_SETS[index][0] = "by extension...";
@@ -277,6 +282,7 @@ public class GUI implements CPDListener {
private JCheckBox ignoreIdentifiersCheckbox = new JCheckBox("", false);
private JCheckBox ignoreLiteralsCheckbox = new JCheckBox("", false);
private JCheckBox ignoreAnnotationsCheckbox = new JCheckBox("", false);
private JCheckBox ignoreUsingsCheckbox = new JCheckBox("", false);
private JComboBox languageBox = new JComboBox();
private JTextField extensionField = new JTextField();
private JLabel extensionLabel = new JLabel("Extension:", SwingConstants.RIGHT);
@@ -362,6 +368,7 @@ public class GUI implements CPDListener {
ignoreIdentifiersCheckbox.setEnabled(current.canIgnoreIdentifiers());
ignoreLiteralsCheckbox.setEnabled(current.canIgnoreLiterals());
ignoreAnnotationsCheckbox.setEnabled(current.canIgnoreAnnotations());
ignoreUsingsCheckbox.setEnabled(current.canIgnoreUsings());
extensionField.setText(current.extensions()[0]);
boolean enableExtension = current.extensions()[0].length() == 0;
extensionField.setEnabled(enableExtension);
@@ -414,6 +421,13 @@ public class GUI implements CPDListener {
helper.nextRow();
helper.addLabel("Ignore annotations?");
helper.add(ignoreAnnotationsCheckbox);
helper.addLabel("");
helper.addLabel("");
helper.nextRow();
helper.nextRow();
helper.addLabel("Ignore usings?");
helper.add(ignoreUsingsCheckbox);
helper.add(goButton);
helper.add(cxButton);
helper.nextRow();
@@ -590,6 +604,7 @@ public class GUI implements CPDListener {
config.setIgnoreIdentifiers(ignoreIdentifiersCheckbox.isSelected());
config.setIgnoreLiterals(ignoreLiteralsCheckbox.isSelected());
config.setIgnoreAnnotations(ignoreAnnotationsCheckbox.isSelected());
config.setIgnoreUsings(ignoreUsingsCheckbox.isSelected());
p.setProperty(LanguageFactory.EXTENSION, extensionField.getText());
LanguageConfig conf = languageConfigFor((String)languageBox.getSelectedItem());
@@ -15,158 +15,167 @@ import java.util.List;
import net.sourceforge.pmd.PMD;
import org.apache.commons.io.ByteOrderMark;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.BOMInputStream;
public class SourceCode {
public static abstract class CodeLoader {
private SoftReference<List<String>> code;
private SoftReference<List<String>> code;
public List<String> getCode() {
List<String> c = null;
if (code != null) {
c = code.get();
}
if (c != null) {
return c;
}
this.code = new SoftReference<List<String>>(load());
return code.get();
}
public List<String> getCode() {
List<String> c = null;
if (code != null) {
c = code.get();
}
if (c != null) {
return c;
}
this.code = new SoftReference<List<String>>(load());
return code.get();
}
public abstract String getFileName();
public abstract String getFileName();
protected abstract Reader getReader() throws Exception;
protected abstract Reader getReader() throws Exception;
protected List<String> load() {
LineNumberReader lnr = null;
try {
lnr = new LineNumberReader(getReader());
List<String> lines = new ArrayList<String>();
String currentLine;
while ((currentLine = lnr.readLine()) != null) {
lines.add(currentLine);
}
return lines;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Problem while reading " + getFileName() + ":" + e.getMessage());
} finally {
IOUtils.closeQuietly(lnr);
}
}
protected List<String> load() {
LineNumberReader lnr = null;
try {
lnr = new LineNumberReader(getReader());
List<String> lines = new ArrayList<String>();
String currentLine;
while ((currentLine = lnr.readLine()) != null) {
lines.add(currentLine);
}
return lines;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Problem while reading " + getFileName() + ":" + e.getMessage());
} finally {
IOUtils.closeQuietly(lnr);
}
}
}
public static class FileCodeLoader extends CodeLoader {
private File file;
private String encoding;
private File file;
private String encoding;
public FileCodeLoader(File file, String encoding) {
this.file = file;
this.encoding = encoding;
}
public FileCodeLoader(File file, String encoding) {
this.file = file;
this.encoding = encoding;
}
@Override
public Reader getReader() throws Exception {
return new InputStreamReader(new FileInputStream(file), encoding);
}
@Override
public Reader getReader() throws Exception {
BOMInputStream inputStream =
new BOMInputStream(new FileInputStream(file),
ByteOrderMark.UTF_8, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_16LE);
@Override
public String getFileName() {
return file.getAbsolutePath();
}
if (inputStream.hasBOM()) {
encoding = inputStream.getBOMCharsetName();
}
return new InputStreamReader(inputStream, encoding);
}
public String getEncoding() {
return encoding;
}
@Override
public String getFileName() {
return file.getAbsolutePath();
}
}
public static class StringCodeLoader extends CodeLoader {
public static final String DEFAULT_NAME = "CODE_LOADED_FROM_STRING";
public static final String DEFAULT_NAME = "CODE_LOADED_FROM_STRING";
private String code;
private String code;
private String name;
private String name;
public StringCodeLoader(String code) {
this(code, DEFAULT_NAME);
}
public StringCodeLoader(String code) {
this(code, DEFAULT_NAME);
}
public StringCodeLoader(String code, String name) {
this.code = code;
this.name = name;
}
public StringCodeLoader(String code, String name) {
this.code = code;
this.name = name;
}
@Override
public Reader getReader() {
return new StringReader(code);
}
@Override
public Reader getReader() {
return new StringReader(code);
}
@Override
public String getFileName() {
return name;
}
@Override
public String getFileName() {
return name;
}
}
public static class ReaderCodeLoader extends CodeLoader {
public static final String DEFAULT_NAME = "CODE_LOADED_FROM_READER";
public static final String DEFAULT_NAME = "CODE_LOADED_FROM_READER";
private Reader code;
private Reader code;
private String name;
private String name;
public ReaderCodeLoader(Reader code) {
this(code, DEFAULT_NAME);
}
public ReaderCodeLoader(Reader code) {
this(code, DEFAULT_NAME);
}
public ReaderCodeLoader(Reader code, String name) {
this.code = code;
this.name = name;
}
public ReaderCodeLoader(Reader code, String name) {
this.code = code;
this.name = name;
}
@Override
public Reader getReader() {
return code;
}
@Override
public Reader getReader() {
return code;
}
@Override
public String getFileName() {
return name;
}
@Override
public String getFileName() {
return name;
}
}
private CodeLoader cl;
public SourceCode(CodeLoader cl) {
this.cl = cl;
this.cl = cl;
}
public List<String> getCode() {
return cl.getCode();
return cl.getCode();
}
public StringBuilder getCodeBuffer() {
StringBuilder sb = new StringBuilder();
List<String> lines = cl.getCode();
for (String line : lines) {
sb.append(line).append(PMD.EOL);
}
return sb;
StringBuilder sb = new StringBuilder();
List<String> lines = cl.getCode();
for (String line : lines) {
sb.append(line).append(PMD.EOL);
}
return sb;
}
public String getSlice(int startLine, int endLine) {
StringBuilder sb = new StringBuilder();
List<String> lines = cl.getCode();
for (int i = startLine == 0 ? startLine :startLine - 1; i < endLine && i < lines.size(); i++) {
StringBuilder sb = new StringBuilder();
List<String> lines = cl.getCode();
for (int i = startLine == 0 ? startLine : startLine - 1; i < endLine && i < lines.size(); i++) {
if (sb.length() != 0) {
sb.append(PMD.EOL);
}
sb.append(lines.get(i));
}
return sb.toString();
sb.append(PMD.EOL);
}
sb.append(lines.get(i));
}
return sb.toString();
}
public String getFileName() {
return cl.getFileName();
return cl.getFileName();
}
}
@@ -9,6 +9,13 @@ public interface Tokenizer {
String IGNORE_LITERALS = "ignore_literals";
String IGNORE_IDENTIFIERS = "ignore_identifiers";
String IGNORE_ANNOTATIONS = "ignore_annotations";
/**
* Ignore using directives in C#.
* The default value is <code>false</code>.
*/
String IGNORE_USINGS = "ignore_usings";
/**
* Enables or disabled skipping of blocks like a pre-processor.
* It is a boolean property.
@@ -77,7 +77,7 @@ public final class XMLRenderer implements Renderer {
transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, "codefragment");
StringWriter writer = new StringWriter();
transformer.transform(new DOMSource(doc), new StreamResult(writer));
return writer.getBuffer().toString();
return writer.toString();
} catch (TransformerException e) {
throw new IllegalStateException(e);
}
@@ -8,6 +8,8 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassReader;
@@ -51,7 +53,11 @@ public class UsageGraphBuilder {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(
classResourceName + ".class");
ClassReader classReader = new ClassReader(inputStream);
classReader.accept(getNewClassVisitor(), 0);
try {
classReader.accept(getNewClassVisitor(), 0);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
}
} catch (IOException e) {
@@ -15,7 +15,7 @@ import java.util.ServiceLoader;
*/
public final class LanguageRegistry {
private static LanguageRegistry instance;
private static LanguageRegistry instance = new LanguageRegistry();
private Map<String, Language> languages;
@@ -27,10 +27,7 @@ public final class LanguageRegistry {
}
}
protected static LanguageRegistry getInstance() {
if(instance == null) {
instance = new LanguageRegistry();
}
public static LanguageRegistry getInstance() {
return instance;
}
@@ -57,13 +54,13 @@ public final class LanguageRegistry {
public static LanguageVersion findLanguageVersionByTerseName(String terseName) {
String version = null;
if(terseName.contains(" ")) {
if (terseName.contains(" ")) {
version = terseName.substring(terseName.lastIndexOf(' ') + 1);
terseName = terseName.substring(0, terseName.lastIndexOf(' '));
}
Language language = findLanguageByTerseName(terseName);
if(language != null) {
if(version == null) {
if (language != null) {
if (version == null) {
return language.getDefaultVersion();
} else {
return language.getVersion(version);
@@ -84,8 +81,8 @@ public final class LanguageRegistry {
public static List<LanguageVersion> findAllVersions() {
List<LanguageVersion> versions = new ArrayList<LanguageVersion>();
for(Language language : getLanguages()) {
for(LanguageVersion languageVersion : language.getVersions()) {
for (Language language : getLanguages()) {
for (LanguageVersion languageVersion : language.getVersions()) {
versions.add(languageVersion);
}
}
@@ -94,6 +91,7 @@ public final class LanguageRegistry {
/**
* A utility method to find the Languages which have Rule support.
*
* @return A List of Languages with Rule support.
*/
public static List<Language> findWithRuleSupport() {
@@ -124,7 +122,7 @@ public final class LanguageRegistry {
StringBuilder builder = new StringBuilder();
builder.append(languageVersions.get(0).getTerseName());
for (int i=1; i<languageVersions.size(); i++) {
for (int i = 1; i < languageVersions.size(); i++) {
builder.append(", ").append(languageVersions.get(i).getTerseName());
}
return builder.toString();
@@ -14,6 +14,7 @@ import javax.xml.parsers.ParserConfigurationException;
import net.sourceforge.pmd.lang.ast.xpath.Attribute;
import net.sourceforge.pmd.lang.ast.xpath.DocumentNavigator;
import net.sourceforge.pmd.lang.dfa.DataFlowNode;
import net.sourceforge.pmd.lang.ast.GenericToken;
import org.jaxen.BaseXPath;
import org.jaxen.JaxenException;
@@ -114,7 +115,7 @@ public abstract class AbstractNode implements Node {
}
public boolean hasImageEqualTo(String image) {
return this.image != null && this.image.equals(image);
return this.getImage() != null && this.getImage().equals(image);
}
public int getBeginLine() {
@@ -397,4 +398,22 @@ public abstract class AbstractNode implements Node {
public void setUserData(Object userData) {
this.userData = userData;
}
protected GenericToken firstToken, lastToken;
public GenericToken jjtGetFirstToken() {
return firstToken;
}
public void jjtSetFirstToken(GenericToken token) {
this.firstToken = token;
}
public GenericToken jjtGetLastToken() {
return lastToken;
}
public void jjtSetLastToken(GenericToken token) {
this.lastToken = token;
}
}
Loaded 30 of 326 files, more files were not shown because too many files have changed in this diff. Show more