Sha256: fd5c02f5a13c1ecd7998831b5b2be9378558064ce7520653772d91c6dccecea6

Contents?: true

Size: 1.16 KB

Versions: 49

Compression:

Stored size: 1.16 KB

Contents

# Control Couple

## Introduction

Control coupling occurs when a method or block checks the value of a parameter
in order to decide which execution path to take. The offending parameter is
often called a _Control Couple_.

Control Coupling is a kind of duplication, because the calling method already knows which path should be taken.

Control Coupling reduces the code's flexibility by creating a dependency
between the caller and callee: any change to the possible values of the
controlling parameter must be reflected on both sides of the call. A _Control
Couple_ also reveals a loss of simplicity: the called method probably has more
than one responsibility, because it includes at least two different code paths.

You can find a good write-up regarding this problem [here](http://solnic.eu/2012/04/11/get-rid-of-that-code-smell-control-couple.html).

## Current Support in Reek

Reek performs the following checks that fall in this category:

* [Control-Parameter](Control-Parameter.md) - a method parameter or block
  parameter is the tested value in a conditional statement
* [Boolean-Parameter](Boolean-Parameter.md) - a method parameter is defaulted
  to `true` or `false`.

Version data entries

49 entries across 47 versions & 2 rubygems

Version Path
reek-5.6.0 docs/Control-Couple.md
reek-5.5.0 docs/Control-Couple.md
reek-5.4.1 docs/Control-Couple.md
reek-5.4.0 docs/Control-Couple.md
reek-5.3.2 docs/Control-Couple.md
reek-5.3.1 docs/Control-Couple.md
reek-5.3.0 docs/Control-Couple.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/Control-Couple.md
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/docs/Control-Couple.md
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/reek-5.2.0/docs/Control-Couple.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/Control-Couple.md
reek-5.2.0 docs/Control-Couple.md
reek-5.1.0 docs/Control-Couple.md
reek-5.0.2 docs/Control-Couple.md
reek-5.0.1 docs/Control-Couple.md
reek-5.0.0 docs/Control-Couple.md
reek-4.8.2 docs/Control-Couple.md
reek-4.8.1 docs/Control-Couple.md
reek-4.8.0 docs/Control-Couple.md
reek-4.7.3 docs/Control-Couple.md