Sha256: d1db82b2a0eaf97dd25aa73603656e406438bd3541b0a5fe9b9d757bb927314d

Contents?: true

Size: 999 Bytes

Versions: 53

Compression:

Stored size: 999 Bytes

Contents

## Introduction

_Too Many Instance Variables_ is a case of [Large Class](Large-Class.md).

## Example

Given this configuration

```yaml
TooManyInstanceVariables:
  max_instance_variables: 3
```

and this code:

```Ruby
class Smelly
  def initialize
    @arg_1 = :dummy
    @arg_2 = :dummy
    @arg_3 = :dummy
    @arg_4 = :dummy
  end
end
```

Reek would emit the following warning:

```
test.rb -- 5 warnings:
  [1]:TooManyInstanceVariables: Smelly has at least 4 instance variables
```
## Current Support in Reek

Reek only counts the instance variables you use explicitly like in the example above. Class macros like `attr_accessor` are disregarded.

## Configuration

Reek's _Too Many Instance Variables_ detector offers the [Basic Smell Options](Basic-Smell-Options.md), plus:

| Option                   | Value   | Effect  |
| -------------------------|---------|---------|
| `max_instance_variables` | integer | The maximum number of instance variables that are permitted. Defaults to 4 |

Version data entries

53 entries across 51 versions & 2 rubygems

Version Path
reek-6.0.3 docs/Too-Many-Instance-Variables.md
reek-6.0.2 docs/Too-Many-Instance-Variables.md
reek-6.0.1 docs/Too-Many-Instance-Variables.md
reek-6.0.0 docs/Too-Many-Instance-Variables.md
reek-5.6.0 docs/Too-Many-Instance-Variables.md
reek-5.5.0 docs/Too-Many-Instance-Variables.md
reek-5.4.1 docs/Too-Many-Instance-Variables.md
reek-5.4.0 docs/Too-Many-Instance-Variables.md
reek-5.3.2 docs/Too-Many-Instance-Variables.md
reek-5.3.1 docs/Too-Many-Instance-Variables.md
reek-5.3.0 docs/Too-Many-Instance-Variables.md
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/docs/Too-Many-Instance-Variables.md
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/docs/Too-Many-Instance-Variables.md
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/docs/Too-Many-Instance-Variables.md
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/docs/Too-Many-Instance-Variables.md
reek-5.2.0 docs/Too-Many-Instance-Variables.md
reek-5.1.0 docs/Too-Many-Instance-Variables.md
reek-5.0.2 docs/Too-Many-Instance-Variables.md
reek-5.0.1 docs/Too-Many-Instance-Variables.md
reek-5.0.0 docs/Too-Many-Instance-Variables.md