Sha256: 443f169822c15b1cb07b42863ebd4a745952610310012bbe9ca57cb1f5cf475e

Contents?: true

Size: 902 Bytes

Versions: 15

Compression:

Stored size: 902 Bytes

Contents

# Nil Check

## Introduction

A `NilCheck` is a type check. Failures of `NilCheck` violate the ["tell, don't ask"](http://robots.thoughtbot.com/tell-dont-ask) principle.
Additionally to that, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

## Example

Given

```Ruby
class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end
```

`reek` would emit the following warning:

```
test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)
```

##  Current Support in Reek

`NilCheck` reports use of 

* <code>.nil?</code> method
* <code>==</code> and <code>===</code> operators when checking vs. <code>nil</code>
* case statements that use syntax like <code>when nil</code>

## Configuration

`Nil Check` offers the [Basic Smell Options](Basic-Smell-Options.md).

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
reek-3.5.0 docs/Nil-Check.md
reek-3.4.1 docs/Nil-Check.md
reek-3.4.0 docs/Nil-Check.md
reek-3.3.1 docs/Nil-Check.md
reek-3.3.0 docs/Nil-Check.md
reek-3.2.1 docs/Nil-Check.md
reek-3.2 docs/Nil-Check.md
reek-3.1 docs/Nil-Check.md
reek-3.0.4 docs/Nil-Check.md
reek-3.0.3 docs/Nil-Check.md
reek-3.0.2 docs/Nil-Check.md
reek-3.0.1 docs/Nil-Check.md
reek-3.0.0 docs/Nil-Check.md
reek-2.2.1 docs/Nil-Check.md
reek-2.2.0 docs/Nil-Check.md