diff --git a/src/main/resources/com/sonar/sqale/pmd-model.xml b/src/main/resources/com/sonar/sqale/pmd-model.xml
index 4fc6478..66b26f0 100644
--- a/src/main/resources/com/sonar/sqale/pmd-model.xml
+++ b/src/main/resources/com/sonar/sqale/pmd-model.xml
@@ -4507,6 +4507,86 @@
Look for qualified this usages in the same class.
+Examples:
++ Negative example: + List\ No newline at end of file diff --git a/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/ClassCastExceptionWithToArrayRule.html b/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/ClassCastExceptionWithToArrayRule.html new file mode 100644 index 0000000..5a96cf8 --- /dev/null +++ b/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/ClassCastExceptionWithToArrayRule.html @@ -0,0 +1,9 @@ +list = new ArrayList (); + list.add("22"); + //warn + List test = (ArrayList ) list.subList(0, 1); + + Positive example: + List list2 = new ArrayList (list.subList(0, 1)); +
Look for qualified this usages in the same class.
+Examples:
++ Negative example: + Integer[] a = (Integer [])c.toArray(); + + Positive example: + Integer[] b = (Integer [])c.toArray(new Integer[c.size()]); +\ No newline at end of file diff --git a/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/CollectionInitShouldAssignCapacityRule.html b/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/CollectionInitShouldAssignCapacityRule.html new file mode 100644 index 0000000..5210e97 --- /dev/null +++ b/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/CollectionInitShouldAssignCapacityRule.html @@ -0,0 +1,9 @@ +
Look for qualified this usages in the same class.
+Examples:
++ Negative example: + Map\ No newline at end of file diff --git a/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/ConcurrentExceptionWithModifyOriginSubListRule.html b/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/ConcurrentExceptionWithModifyOriginSubListRule.html new file mode 100644 index 0000000..bf8151a --- /dev/null +++ b/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/ConcurrentExceptionWithModifyOriginSubListRule.html @@ -0,0 +1,10 @@ +map = new HashMap (); + + Positive example: + Map map = new HashMap (16); +
Look for qualified this usages in the same class.
+Examples:
++ Negative example: + List\ No newline at end of file diff --git a/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/DontModifyInForeachCircleRule.html b/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/DontModifyInForeachCircleRule.html new file mode 100644 index 0000000..c002874 --- /dev/null +++ b/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/DontModifyInForeachCircleRule.html @@ -0,0 +1,20 @@ +originList = new ArrayList (); + originList.add("22"); + List subList = originList.subList(0, 1); + //warn + originList.add("22"); +
Look for qualified this usages in the same class.
+Examples:
++ Negative example: + List\ No newline at end of file diff --git a/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/UnsupportedExceptionWithModifyAsListRule.html b/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/UnsupportedExceptionWithModifyAsListRule.html new file mode 100644 index 0000000..6fb0815 --- /dev/null +++ b/src/main/resources/org/sonar/l10n/pmd/rules/pmd-p3c/UnsupportedExceptionWithModifyAsListRule.html @@ -0,0 +1,13 @@ +originList = new ArrayList (); + originList.add("22"); + for (String item : originList) { + //warn + list.add("bb"); + } + + Positive example: + Iterator it=b.iterator(); + while(it.hasNext()){ + Integer temp = it.next(); + if (delCondition) { + it.remove(); + } + } +
Look for qualified this usages in the same class.
+Examples:
++ Positive example: + List\ No newline at end of file diff --git a/src/main/resources/org/sonar/plugins/pmd/rules-p3c.xml b/src/main/resources/org/sonar/plugins/pmd/rules-p3c.xml index 3572a2c..3a02b70 100644 --- a/src/main/resources/org/sonar/plugins/pmd/rules-p3c.xml +++ b/src/main/resources/org/sonar/plugins/pmd/rules-p3c.xml @@ -169,19 +169,45 @@t = Arrays.asList("a","b","c"); + //warn + t.add("22"); + //warn + t.remove("22"); + //warn + t.clear(); + +