Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

New Check: ForbidWildcardAsReturnType #75

Closed
romani opened this Issue · 0 comments

2 participants

@romani
Owner

ForbidWildcardAsReturnType.

Joshua Bloch, "Effective Java (2nd edition)" Item 28: page 137 :
"Do not use wildcard types as return
types. Rather than providing additional flexibility for your users, it would force
them to use wildcard types in client code.
Properly used, wildcard types are nearly invisible to users of a class. They
cause methods to accept the parameters they should accept and reject those they
should reject. If the user of a class has to think about wildcard types, there is
probably something wrong with the class’s API."

Options:

  • check public method (boolean) (default value = true)
  • check protected method (boolean) (default value = true)
  • check protected-package methods (boolean) (default value = true)
  • check private methods (boolean) (default value = false)
  • allow Wildcard with "super" (boolean). example: "? super T" (default value = false)
  • allow Wildcard with "extends" (boolean). example: "? extends T" (default value = false)
  • ignore list for Class names (regexp), example "Comparable<? super T>". (default value = "Comparable|Comparator")

http://sourceforge.net/p/checkstyle/feature-requests/580/

@baratali baratali was assigned
@baratali baratali referenced this issue from a commit in baratali/sevntu.checkstyle
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. f49393e
@baratali baratali referenced this issue from a commit in baratali/sevntu.checkstyle
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. cafee49
@baratali baratali referenced this issue from a commit in baratali/sevntu.checkstyle
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. ebfa54e
@baratali baratali referenced this issue from a commit in baratali/sevntu.checkstyle
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. 575642a
@baratali baratali referenced this issue from a commit in baratali/sevntu.checkstyle
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. 9433cf1
@baratali baratali referenced this issue from a commit in baratali/sevntu.checkstyle
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. 0789b14
@romani romani closed this in #127
@daniilyar daniilyar referenced this issue from a commit in daniilyar/sevntu.checkstyle
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. d75b472
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.