diff --git a/README.md b/README.md index 35c34cb..3386ec4 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ You need to include `checkstyle` as the version bundled with the `maven-checksty * [EmptyPublicCtorInClass](#emptypublicctorinclass) - sevntu - disabled * [EmptyStatement](#emptystatement) - checkstyle - enabled * [EnumValueName](#enumvaluename) - sevntu - enabled -* [EqualsAvoidNull](#equalsavoidnull) - checkstyle - disabled +* [EqualsAvoidNull](#equalsavoidnull) - checkstyle - enabled * [EqualsHashCode](#equalshashcode) - checkstyle - enabled * [ExecutableStatementCount](#executablestatementcount) - checkstyle - enabled * [ExplicitInitialization](#explicitinitialization) - checkstyle - enabled @@ -918,6 +918,22 @@ Invalid: doSomething();; ```` +#### [EqualsAvoidNull](http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull) + +Checks that string literals are on the left side in an `equals()` comparison. + +Valid: +```` +String nullString = null; +"value".equals(nullString); +```` + +Invalid: +```` +String nullString = null; +nullString.equals("value"); +```` + #### [EqualsHashCode](http://checkstyle.sourceforge.net/config_coding.html#EqualsHashCode) Checks that when a class overrides the `equals()` method, that it also overrides the `hashCode()` method. @@ -2613,10 +2629,6 @@ These checks are not enabled. Notes are included for each explaining why. Couldn't get my IDE's (IntelliJ) code style to match. -#### [EqualsAvoidNull](http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull) - -> TODO: enable - #### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable) > TODO: enable diff --git a/src/main/resources/net/kemitix/checkstyle.xml b/src/main/resources/net/kemitix/checkstyle.xml index 459fa79..47e8301 100644 --- a/src/main/resources/net/kemitix/checkstyle.xml +++ b/src/main/resources/net/kemitix/checkstyle.xml @@ -74,6 +74,7 @@ +