spotbugs / spotbugs

SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.

Home Page:https://spotbugs.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EI_EXPOSE_REP2 for Kotlin Collection

dnsbtchr opened this issue · comments

Good morning, I have a problem with the spotbugs-maven-plugin in a Kotlin project.
I have this class
data class Class( val myCollection: Collection<String>?, )
The documentation of the "Collection" interfaces says:
/**

  • A generic collection of elements. Methods in this interface support only read-only access to the collection;
  • read/write access is supported through the [MutableCollection] interface.
  • @param E the type of elements contained in the collection. The collection is covariant in its element type.
    */

For me this means that the collection is immutable but when building my project I still get "EI_EXPOSE_REP2" for the myCollection field. Am I missing something or is this an issue?

Thanks
Dennis

The same happens for Kotlins Map interface.

@dnsbtchr Believe this should be a report to spotbugs itself as the plugin here just runs it. Transferring it over there.

Thanks for opening your first issue here! 😃
Please check our contributing guideline. Especially when you report a problem, make sure you share a Minimal, Complete, and Verifiable example to reproduce it in this issue.