<commit_before># Nil Check

## Introduction

A _Nil Check_ is a type check. Failures of _Nil Check_ 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.

The _Nil Check_ code smell is a case of [Simulated Polymorphism](Simulated-Polymorphism.md).

## 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

_Nil Check_ reports use of 

* <code>.nil?</code> method
* <code>==</code> and <code>===</code> operators when checking vs. <code>nil</code><commit_msg>Fix incorrect Nil Check example<commit_after># Nil Check

## Introduction

A _Nil Check_ is a type check. Failures of _Nil Check_ 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.

The _Nil Check_ code smell is a case of [Simulated Polymorphism](Simulated-Polymorphism.md).

## Example

Given

```Ruby
class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument is 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

_Nil Check_ reports use of 

* <code>.nil?</code> method
* <code>==</code> and <code>===</code> operators when checking vs. <code>nil</code>
{'fraction_non_alphanumeric': 0.11401020986954055, 'fraction_numerical': 0.0022688598979013048, 'mean_word_length': 4.054441260744985, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4693098', 'n_tokens_mistral': 601, 'n_tokens_neox': 560, 'n_words': 211}