diff --git a/.all-contributorsrc b/.all-contributorsrc
index 5357d8fad6..2fc583bca3 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -3384,7 +3384,8 @@
"avatar_url": "https://avatars.githubusercontent.com/u/242337?v=4",
"profile": "https://github.com/jjlharrison",
"contributions": [
- "bug"
+ "bug",
+ "code"
]
},
{
diff --git a/docs/pages/pmd/projectdocs/credits.md b/docs/pages/pmd/projectdocs/credits.md
index c01402c827..838629d195 100644
--- a/docs/pages/pmd/projectdocs/credits.md
+++ b/docs/pages/pmd/projectdocs/credits.md
@@ -307,7 +307,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Ivo Šmíd 🐛 |
JJengility 🐛 |
Jake Hemmerle 🐛 |
- James Harrison 🐛 |
+ James Harrison 💻 🐛 |
Jan 🐛 |
diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md
index fe77034c8c..aab61eb788 100644
--- a/docs/pages/release_notes.md
+++ b/docs/pages/release_notes.md
@@ -15,6 +15,9 @@ This is a {{ site.pmd.release_type }} release.
### New and noteworthy
### Fixed Issues
+* java-design
+ * [#3981](https://github.com/pmd/pmd/issues/3981): \[java] ImmutableField reports fields annotated with @Value (Spring)
+ * [#3998](https://github.com/pmd/pmd/issues/3998): \[java] ImmutableField reports fields annotated with @Captor (Mockito)
* java-errorprone
* [#3936](https://github.com/pmd/pmd/issues/3936): \[java] AvoidFieldNameMatchingMethodName should consider enum class
* [#3937](https://github.com/pmd/pmd/issues/3937): \[java] AvoidDuplicateLiterals - uncompilable test cases
@@ -24,6 +27,7 @@ This is a {{ site.pmd.release_type }} release.
### External Contributions
* [#3985](https://github.com/pmd/pmd/pull/3985): \[java] Fix false negative problem about Enum in AvoidFieldNameMatchingMethodName #3936 - [@Scrsloota](https://github.com/Scrsloota)
* [#3993](https://github.com/pmd/pmd/pull/3993): \[java] AvoidDuplicateLiterals - Add the method "buz" definition to test cases - [@dalizi007](https://github.com/dalizi007)
+* [#4002](https://github.com/pmd/pmd/pull/4002): \[java] ImmutableField - Ignore fields annotated with @Value (Spring) or @Captor (Mockito) - [@jjlharrison](https://github.com/jjlharrison)
{% endtocmaker %}
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ImmutableFieldRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ImmutableFieldRule.java
index 69baff8219..4bbc274bdb 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ImmutableFieldRule.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/ImmutableFieldRule.java
@@ -46,9 +46,11 @@ public class ImmutableFieldRule extends AbstractLombokAwareRule {
@Override
protected Collection defaultSuppressionAnnotations() {
Collection defaultValues = new ArrayList<>(super.defaultSuppressionAnnotations());
- defaultValues.add("org.mockito.Mock");
+ defaultValues.add("org.mockito.Captor");
defaultValues.add("org.mockito.InjectMocks");
+ defaultValues.add("org.mockito.Mock");
defaultValues.add("org.springframework.beans.factory.annotation.Autowired");
+ defaultValues.add("org.springframework.beans.factory.annotation.Value");
defaultValues.add("org.springframework.boot.test.mock.mockito.MockBean");
return defaultValues;
diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/ImmutableField.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/ImmutableField.xml
index b6f6bfb687..722ffc8377 100644
--- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/ImmutableField.xml
+++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/ImmutableField.xml
@@ -603,4 +603,22 @@ class Baz {}
class Foo2 {}
]]>
+
+ #3981 #3998 [java] ImmutableField reports fields annotated with @Value (Spring) and @Captor (Mockito)
+ 0
+ baz2;
+}
+ ]]>
+