Saturday, February 15, 2014

New Check: Grammar in names and negative names restrictions

One more ambitions for Checkstyle - check grammar in method names and negative names restrictions.

Reason:
- developers do typos
- not all developers are good in English, and this nightmare to other team members who English by native
- Force developers to avoid negative name usage "isIncorrect()", "isNotIgnoredClass()"

Why negative name is bad approach - as it force to use that Negative Logic in other places.

Example:

Negative logic/name:
public boolean isNotCorrect() {...}

force other to have code like :
if (isNotCorrect())  // OK
if (!isNotCorrect())  // is NOT OK - it is unreadable!!!

So lets remove negative logic/name:
public boolean isCorrect() {...}

force other to have code like :
if (!isCorrect())  // it is OK
if (isCorrect())  // it is OK

BUT live is not that ideal sometime it is convenient to use negative logic or even more it is dependency from thirdparty code or legacy code.

That idea depends on grammar check in names base on vocabulary http://grammarist.com/usage/negative-prefixes/

we need options to check "boolean methods" "setter/getter" .... user might not need to test all names, option to check base on visibility - public/private/... .


http://www.liferay.com/community/wiki/-/wiki/Main/Javadoc+Guidelines#section-Javadoc+Guidelines-General+Guidelines , search for "Refer to parameters with "the", not "a" or "given"" - it will be good validation

Class: Initial and detailed description # "The first sentence of the initial class description starts with a verb (two verbs, in fact)."




If you run to this page and share idea with me, please let me know.

No comments:

Post a Comment