New Check: ForbidWildcardAsReturnType #75

Closed
romani opened this Issue Nov 3, 2012 · 0 comments

Projects

None yet

2 participants

@romani
Member
romani commented Nov 3, 2012

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 Jul 11, 2013
@baratali baratali added a commit to baratali/sevntu.checkstyle that referenced this issue Jul 30, 2013
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. f49393e
@baratali baratali added a commit to baratali/sevntu.checkstyle that referenced this issue Aug 10, 2013
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. cafee49
@baratali baratali added a commit to baratali/sevntu.checkstyle that referenced this issue Aug 13, 2013
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. ebfa54e
@baratali baratali added a commit to baratali/sevntu.checkstyle that referenced this issue Aug 21, 2013
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. 575642a
@baratali baratali added a commit to baratali/sevntu.checkstyle that referenced this issue Aug 21, 2013
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. 9433cf1
@baratali baratali added a commit to baratali/sevntu.checkstyle that referenced this issue Aug 22, 2013
@baratali baratali Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. 0789b14
@romani romani closed this in #127 Aug 22, 2013
@daniilyar daniilyar added a commit to daniilyar/sevntu.checkstyle that referenced this issue Sep 4, 2013
@baratali @daniilyar baratali + daniilyar Fixes #75. ForbidWildcardAsReturnTypeCheck was introduced. d75b472
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment