File tree Expand file tree Collapse file tree 3 files changed +3
-34
lines changed Expand file tree Collapse file tree 3 files changed +3
-34
lines changed Original file line number Diff line number Diff line change @@ -35,40 +35,9 @@ See also [Getting Started](https://pmd.github.io/latest/pmd_userdocs_installatio
35
35
36
36
** Demo:**
37
37
38
- For this sample file:
39
-
40
- ``` java
41
- import java.util.List ;
42
-
43
- public class MyClass {
44
- void loop (List<String > l ) {
45
- for (int i = 0 ; i < l. size(); i++ ) {
46
- System . out. println(l. get(i));
47
- }
48
- }
49
- }
50
- ```
51
-
52
- Run PMD on the command line:
53
-
54
- ``` bash
55
- $ run.sh pmd -d /usr/src -R rulesets/java/quickstart.xml -f xml
56
- < ? xml version=" 1.0" encoding=" UTF-8" ? >
57
- < pmd xmlns=" http://pmd.sourceforge.net/report/2.0.0" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://pmd.sourceforge.net/report/2.0.0 http://pmd.sourceforge.net/report_2_0_0.xsd" version=" 6.37.0" timestamp=" 2021-08-20T15:26:35.564" >
58
- < file name=" /home/andreas/temp/pmd-test/MyClass.java" >
59
- < violation beginline=" 3" endline=" 9" begincolumn=" 1" endcolumn=" 1" rule=" NoPackage" ruleset=" Code Style" class=" MyClass" externalInfoUrl=" https://pmd.github.io/pmd-6.37.0/pmd_rules_java_codestyle.html#nopackage" priority=" 3" >
60
- All classes, interfaces, enums and annotations must belong to a named package
61
- < /violation>
62
- < violation beginline=" 5" endline=" 7" begincolumn=" 5" endcolumn=" 5" rule=" ForLoopCanBeForeach" ruleset=" Best Practices" class=" MyClass" method=" loop" externalInfoUrl=" https://pmd.github.io/pmd-6.37.0/pmd_rules_java_bestpractices.html#forloopcanbeforeach" priority=" 3" >
63
- This for loop can be replaced by a foreach loop
64
- < /violation>
65
- < /file>
66
- < /pmd>
67
- ```
68
-
69
- PMD Eclipse Plugin:
70
-
71
- ![ Screenshot PMD Eclipse Plugin] ( docs/images/userdocs/screenshot_pmd-eclipse-plugin.png )
38
+ This shows how PMD can detect for loops, that can be replaced by for-each loops.
39
+
40
+ ![ Demo] ( docs/images/userdocs/pmd-demo.gif )
72
41
73
42
There are plugins for Maven and Gradle as well as for various IDEs.
74
43
See [ Tools / Integrations] ( https://pmd.github.io/latest/pmd_userdocs_tools.html )
You can’t perform that action at this time.
0 commit comments