# java:S107 misses some spring cases

**URL:** <https://community.sonarsource.com/t/java-s107-misses-some-spring-cases/50390>\
**Category:** Report False-positive / False-negative...\
**Tags:** java\
**Created:** [September 27, 2021, 10:18am UTC](https://community.sonarsource.com/t/java-s107-misses-some-spring-cases/50390 "2021-09-27T10:18:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![reitzmichnicht](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/reitzmichnicht/32/288_2.png) [@reitzmichnicht](https://community.sonarsource.com/u/reitzmichnicht)\
**Post date:** [September 27, 2021, 10:18am UTC](https://community.sonarsource.com/t/java-s107-misses-some-spring-cases/50390/1 "2021-09-27T10:18:25Z")

</div>

Sonarqube 9.0  
This rule complains about to much arguments used for methods, but it should exclude own bean definitions like this:

> @Configuration  
> public class BarConfiguration {  
> @Bean  
> public Foo foo(A1 a1, A2 a2, A3 a3, A4 a4, …)  
> }

As this is used to request other dependencies that might be needed to construct Foo.

There seems to be a releated problem with constructors that are not annotated with `@Autowired`. This is not needed anymore in spring boot as long as the class has a `@Component / @Service` annotation

> As of Spring 4.3, classes with a single constructor can omit the _@Autowired_ annotation. This is a nice little bit of convenience and boilerplate removal.

---

<div class="post-metadata">

**Author:** ![reitzmichnicht](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/reitzmichnicht/32/288_2.png) [@reitzmichnicht](https://community.sonarsource.com/u/reitzmichnicht)\
**Post date:** [September 27, 2021, 10:24am UTC](https://community.sonarsource.com/t/java-s107-misses-some-spring-cases/50390/2 "2021-09-27T10:24:01Z")

</div>

Not tested but maybe java:S4288 is also affected by this, at least the compliant example suggests the autowired annotation

---

<div class="post-metadata">

**Author:** ![alban.auzeill](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/alban.auzeill/32/36_2.png) [@alban.auzeill](https://community.sonarsource.com/u/alban.auzeill)\
**Post date:** [November 8, 2021, 6:04pm UTC](https://community.sonarsource.com/t/java-s107-misses-some-spring-cases/50390/4 "2021-11-08T18:04:15Z")

</div>

Hi @reitzmichnicht,  
About S107, I create this ticket [SONARJAVA-4072](https://jira.sonarsource.com/browse/SONARJAVA-4072), and about S4288 I updated the [S4288](https://sonarsource.github.io/rspec/#/rspec/S4288/java) example.  
Thanks for your feedback,  
Alban
