From 5ed44301c8dfbb6bc5ccdcf345757e2eb2ada52d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 6 Sep 2016 19:01:44 +0100 Subject: [PATCH] EqualsAvoidNull: enabled --- README.md | 22 ++++++++++++++----- src/main/resources/net/kemitix/checkstyle.xml | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) 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 @@ +