Sha256: 4f5aa39e81a2e21d3d2ab1f70166a29bd997c53fae3d679e7b1eeac30f15d343

Contents?: true

Size: 901 Bytes

Versions: 17

Compression:

Stored size: 901 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

17 entries across 17 versions & 1 rubygems

Version Path
reek-4.0.1 docs/Nil-Check.md
reek-4.0.0 docs/Nil-Check.md
reek-4.0.0.pre1 docs/Nil-Check.md
reek-3.11 docs/Nil-Check.md
reek-3.10.2 docs/Nil-Check.md
reek-3.10.1 docs/Nil-Check.md
reek-3.10.0 docs/Nil-Check.md
reek-3.9.1 docs/Nil-Check.md
reek-3.9.0 docs/Nil-Check.md
reek-3.8.3 docs/Nil-Check.md
reek-3.8.2 docs/Nil-Check.md
reek-3.8.1 docs/Nil-Check.md
reek-3.8.0 docs/Nil-Check.md
reek-3.7.1 docs/Nil-Check.md
reek-3.7.0 docs/Nil-Check.md
reek-3.6.1 docs/Nil-Check.md
reek-3.6.0 docs/Nil-Check.md