Sha256: 7d1b1eaccffa1fb87ed7e3c32ba438ec3de295b299219da886ed107378a7e58e

Contents?: true

Size: 1.61 KB

Versions: 20

Compression:

Stored size: 1.61 KB

Contents

# Prima Donna Method

## Introduction

Candidate methods for the _Prima Donna Method_ smell are methods whose names
end with an exclamation mark.

An exclamation mark in method names means (the explanation below is taken from
[here](http://dablog.rubypal.com/2007/8/15/bang-methods-or-danger-will-rubyist)):

> The ! in method names that end with ! means, “This method is dangerous”—or,
> more precisely, this method is the “dangerous” version of an otherwise
> equivalent method, with the same name minus the !. “Danger” is relative; the
> ! doesn’t mean anything at all unless the method name it’s in corresponds to
> a similar but bang-less method name.
> 
> So, for example, gsub! is the dangerous version of gsub. exit! is the
> dangerous version of exit. flatten! is the dangerous version of flatten. And
> so forth.

Such a method is called _Prima Donna Method_ if and only if her non-bang
version does not exist and this method is reported as a smell.

## Example

Given

```Ruby
class C
  def foo; end
  def foo!; end
  def bar!; end
end
```

Reek would report the _Prima Donna Method_ smell for `bar!`, but not for `foo!`.

Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:


```Ruby
class Parent
  def foo; end
end

module Dangerous
  def foo!; end
end

class Son < Parent
  include Dangerous
end

class Daughter < Parent
end
```

In this example, Reek would not report the _Prima Donna Method_ smell for the
method `foo` of the `Dangerous` module.

## Configuration

_Prima Donna Method_ offers the [Basic Smell Options](Basic-Smell-Options.md).

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
reek-4.5.3 docs/Prima-Donna-Method.md
reek-4.5.2 docs/Prima-Donna-Method.md
reek-4.5.1 docs/Prima-Donna-Method.md
reek-4.5.0 docs/Prima-Donna-Method.md
reek-4.4.2 docs/Prima-Donna-Method.md
reek-4.4.1 docs/Prima-Donna-Method.md
reek-4.4.0 docs/Prima-Donna-Method.md
reek-4.3.0 docs/Prima-Donna-Method.md
reek-4.2.5 docs/Prima-Donna-Method.md
reek-4.2.4 docs/Prima-Donna-Method.md
reek-4.2.3 docs/Prima-Donna-Method.md
reek-4.2.2 docs/Prima-Donna-Method.md
reek-4.2.1 docs/Prima-Donna-Method.md
reek-4.2.0 docs/Prima-Donna-Method.md
reek-4.1.1 docs/Prima-Donna-Method.md
reek-4.1.0 docs/Prima-Donna-Method.md
reek-4.0.5 docs/Prima-Donna-Method.md
reek-4.0.4 docs/Prima-Donna-Method.md
reek-4.0.3 docs/Prima-Donna-Method.md
reek-4.0.2 docs/Prima-Donna-Method.md