# Java.S1201 false positive

**URL:** <https://community.sonarsource.com/t/java-s1201-false-positive/67488>\
**Category:** Report False-positive / False-negative...\
**Tags:** sonarqube\
**Created:** [July 5, 2022, 1:27pm UTC](https://community.sonarsource.com/t/java-s1201-false-positive/67488 "2022-07-05T13:27:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bthermans](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/bthermans/32/34911_2.png) [@bthermans](https://community.sonarsource.com/u/bthermans)\
**Post date:** [July 5, 2022, 1:27pm UTC](https://community.sonarsource.com/t/java-s1201-false-positive/67488/1 "2022-07-05T13:27:53Z")

</div>

Version: SonarQube \* Community Edition \* Version 9.3 (build 51899)

Rule: S1201 “equals” method overrides should accept “Object” parameters

Code that gives a false positive: (In our case this anonymous inner class was passed as a parameter to a function).

```auto
new HashMap<>() {
    @Override
    public int hashCode() {
        return size();
    }
  
    @Override
    public boolean equals(Object o) {
        if (!(o instanceof HashMap)) {
            return false;
        }
        return getOrDefault("id", "").equals(((HashMap) o).get("id"));
    }
}

```

---

<div class="post-metadata">

**Author:** ![Margarita\_Nedzelska](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/margarita_nedzelska/32/47493_2.png) [@Margarita\_Nedzelska](https://community.sonarsource.com/u/Margarita_Nedzelska)\
**Post date:** [January 17, 2023, 3:29pm UTC](https://community.sonarsource.com/t/java-s1201-false-positive/67488/5 "2023-01-17T15:29:13Z")

</div>

Hello @bthermans,

Thanks for the message. Could you please be more precise in terms of which line is reported as an issue and what is an error message?

I couldn’t reproduce the issue so far.

Regards,  
Margarita
