Skip to content

Commit

Permalink
Move wiki pages to /docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
troessner committed May 2, 2015
1 parent 0d4e2a7 commit c20d10c
Show file tree
Hide file tree
Showing 42 changed files with 1,693 additions and 21 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
## Quickstart

`reek` is a tool that examines Ruby classes, modules and methods and reports any
[Code Smells](https://github.com/troessner/reek/wiki/Code-Smells) it finds.
[Code Smells](docs/Code-Smells.md) it finds.
Install it like this:

```Bash
Expand Down Expand Up @@ -94,16 +94,16 @@ $stdin -- 3 warnings:
## Code smells

`reek` currently includes checks for some aspects of
[Control Couple](https://github.com/troessner/reek/wiki/Control-Couple),
[Data Clump](https://github.com/troessner/reek/wiki/Data-Clump),
[Feature Envy](https://github.com/troessner/reek/wiki/Feature-Envy),
[Large Class](https://github.com/troessner/reek/wiki/Large-Class),
[Long Parameter List](https://github.com/troessner/reek/wiki/Long-Parameter-List),
[Simulated Polymorphism](https://github.com/troessner/reek/wiki/Simulated-Polymorphism),
[Too Many Statements](https://github.com/troessner/reek/wiki/Too-Many-Statements),
[Uncommunicative Name](https://github.com/troessner/reek/wiki/Uncommunicative-Name),
[Unused Parameters](https://github.com/troessner/reek/wiki/Unused-Parameters)
and more. See the [Code Smells](https://github.com/troessner/reek/wiki/Code-Smells)
[Control Couple](docs/Control-Couple.md),
[Data Clump](docs/Data-Clump.md),
[Feature Envy](docs/Feature-Envy.md),
[Large Class](docs/Large-Class.md),
[Long Parameter List](docs/Long-Parameter-List.md),
[Simulated Polymorphism](docs/Simulated-Polymorphism.md),
[Too Many Statements](docs/Too-Many-Statements.md),
[Uncommunicative Name](docs/Uncommunicative-Name.md),
[Unused Parameters](docs/Unused-Parameters.md)
and more. See the [Code Smells](docs/Code-Smells.md)
for up to date details of exactly what `reek` will check in your code.

## Configuration
Expand All @@ -116,7 +116,7 @@ For a basic overview, run
reek --help
```

For a summary of those CLI options see [Command-Line Options](https://github.com/troessner/reek/wiki/Command-Line-Options).
For a summary of those CLI options see [Command-Line Options](docs/Command-Line-Options.md).

### Configuration file

Expand Down Expand Up @@ -145,12 +145,12 @@ of how many `*.reek` files you might have on your filesystem.
#### Configuration options

The first thing you probably want to check out are the
[Basic Smell Options](https://github.com/troessner/reek/wiki/Basic-Smell-Options)
[Basic Smell Options](docs/Basic-Smell-Options.md)
which are supported by every smell type. Certain smell
types offer a configuration that goes beyond that
of the basic smell options, for instance
[Data Clump](https://github.com/troessner/reek/wiki/Data-Clump).
All options that go beyond the [Basic Smell Options](https://github.com/troessner/reek/wiki/Basic-Smell-Options)
[Data Clump](docs/Data-Clump.md).
All options that go beyond the [Basic Smell Options](docs/Basic-Smell-Options.md)
should be documented in the corresponding smell type wiki page,
but if you want to get a quick and full overview over all possible
configurations you can always check out [the `config/default.reek`
Expand Down Expand Up @@ -188,7 +188,7 @@ def smelly_method foo
end
```

This is further explained under [Smell Suppresion](https://github.com/troessner/reek/wiki/Smell-Suppression).
This is further explained under [Smell Suppresion](docs/Smell-Suppression.md).


## Integration
Expand All @@ -201,8 +201,8 @@ reek [options] [dir_or_source_file]*

there are quite a few other ways how to use `reek` in your projects:

* Use `reek`'s [Rake task](https://github.com/troessner/reek/wiki/Rake-Task) to automate detecting code smells
* Add `reek`'s custom matcher to your [RSpec examples](https://github.com/troessner/reek/wiki/RSpec-matchers)
* Use `reek`'s [Rake task](docs/Rake-Task.md) to automate detecting code smells
* Add `reek`'s custom matcher to your [RSpec examples](docs/RSpec-matchers.md)
* Include `reek` using the [Developer API](docs/API.md)

## Developing `reek` / Contributing
Expand Down Expand Up @@ -232,8 +232,8 @@ From then on please check out [the contributing guide](CONTRIBUTING.md).

If you don't feel like getting your hands dirty with code there are still other ways you can help us:

* Work on the [wiki](https://github.com/troessner/reek/wiki)
* Open up an [issue](https://github.com/troessner/reek/issues) and report bugs or suggest other improvements
* Open up an [issue](https://github.com/troessner/reek/issues) and report bugs
* Suggest other improvements like additional smells for instance

## Output formats

Expand Down
4 changes: 3 additions & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Using `reek` inside your Ruby application
# API

## Using `reek` inside your Ruby application

`reek` can be used inside another Ruby project.

Expand Down
43 changes: 43 additions & 0 deletions docs/Attribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Attribute

## Introduction

A class that publishes a getter or setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

## Example

Given:

```Ruby
class Klass
attr_accessor :dummy
end
```

`reek` would emit the following warning:

```
reek test.rb
test.rb -- 1 warning:
[2]:Klass declares the attribute dummy (Attribute)
```

## Support in Reek

Right now this smell is disabled by default since it is highly subjective.

When this detector is enabled it raises a warning for every `attr`, `attr_reader`, `attr_writer` and `attr_accessor` -- including those that are private.

## Configuration

If you want to enable it you can do so by placing

```yaml
Attribute:
enabled: true
```
in your reek configuration file.
`Attribute` supports only the [Basic Smell Options](Basic-Smell-Options.md).
44 changes: 44 additions & 0 deletions docs/Basic-Smell-Options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Basic Smell Options

## Introduction

Every smell detector in Reek offers at least the following configuration options:

| Option | Value | Effect |
| ---------------|-------------|---------|
| `enabled` | Boolean | Determines whether the smell detector is active. Defaults to `true` |
| `exclude` | an array of strings or regular expressions | Ignores any context whose full description (see <strong>%c</strong> in [Command-Line Options](Command-Line-Options.md)) matches any element of this array. |

The file `config/defaults.reek` (shipped with the Reek gem) lists any default exclusions for each smell.

## Examples

<u>An easy one:</u>

To stop Reek reporting smells in any method called `write` you might create a configuration file containing this:

```yaml
ControlCouple:
exclude:
- write
```
Or a little more sophisticated using a ruby regex like this:
```yaml
ControlCouple:
exclude:
- !ruby/regexp /write/
```
<u>A more sophisticated one:</u>
```yaml
FeatureEnvy:
exclude:
- "MyModel#do_things"
- "MyHelper"
- "ApplicationController#respond"
```
This would not report FeatureEnvy for the instance method `MyModel#do_things`, the whole module `MyHelper` and the `respond` instance method of `ApplicationController`
52 changes: 52 additions & 0 deletions docs/Boolean-Parameter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Boolean Parameter

## Introduction

`Boolean Parameter` is a special case of [Control Couple](Control-Couple.md), where a method parameter is defaulted
to true or false. A _Boolean Parameter_ effectively permits a method's caller
to decide which execution path to take. This is a case of bad cohesion. You're creating a dependency between methods that is not really necessary, thus increasing coupling.

## Example

Given

```Ruby
class Dummy
def hit_the_switch(switch = true)
if switch
puts 'Hitting the switch'
# do other things...
else
puts 'Not hitting the switch'
# do other things...
end
end
end
```

`reek` would emit the following warning:

```
test.rb -- 3 warnings:
[1]:Dummy#hit_the_switch has boolean parameter 'switch' (BooleanParameter)
[2]:Dummy#hit_the_switch is controlled by argument switch (ControlParameter)
```

Note that both smells are reported, `Boolean Parameter` and `Control Parameter`.

## Getting rid of the smell

This is highly dependant on your exact architecture, but looking at the example above what you could do is:

* Move everything in the `if` branch into a separate method
* Move everything in the `else` branch into a separate method
* Get rid of the `hit_the_switch` method alltogether
* Make the decision what method to call in the initial caller of `hit_the_switch`

## Current support in Reek

Reek can only detect a Boolean parameter when it has a default initializer like in the example above.

## Configuration

`Boolean Parameter` supports the [Basic Smell Options](Basic-Smell-Options.md).
40 changes: 40 additions & 0 deletions docs/Class-Variable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Class Variable

## Introduction

Class variables form part of the global runtime state, and as such make it easy for one part of the system to accidentally or inadvertently depend on another part of the system. So the system becomes more prone to problems where changing something over here breaks something over there. In particular, class variables can make it hard to set up tests (because the context of the test includes all global state).

For a detailed explanation, check out [this article](http://4thmouse.com/index.php/2011/03/20/why-class-variables-in-ruby-are-a-bad-idea/)

## Example

Given

```Ruby
class Dummy
@@class_variable = :whatever
end
```

`reek` would emit the following warning:

```
reek test.rb
test.rb -- 1 warning:
[2]:Dummy declares the class variable @@class_variable (ClassVariable)
```

## Getting rid of the smell

You can use class-instance variable to mitigate the problem (as also suggested in the linked article above):

```Ruby
class Dummy
@class_variable = :whatever
end
```

## Configuration

`Class Variable` supports the [Basic Smell Options](Basic-Smell-Options.md).
34 changes: 34 additions & 0 deletions docs/Code-Smells.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Code Smells

Smells are indicators of where your code might be hard to read, maintain or evolve, rather than things that are specifically _wrong_. Naturally this means that Reek is looking towards your code's future (and that can make its reports seem somewhat subjective, of course).

Reek currently includes checks for the following smells:

* [Attribute](Attribute.md) (disabled by default)
* [Class Variable](Class-Variable.md)
* [Control Couple](Control-Couple.md), including
* [Boolean Parameter](Boolean-Parameter.md)
* [Control Parameter](Control-Parameter.md)
* [Data Clump](Data-Clump.md)
* [Duplicate Method Call](Duplicate-Method-Call.md)
* [Irresponsible Module](Irresponsible-Module.md)
* [Large Class](Large-Class.md), including
* [Too Many Instance Variables](Too-Many-Instance-Variables.md)
* [Too Many Methods](Too-Many-Methods.md)
* [Long Parameter List](Long-Parameter-List.md), and its special case [Long Yield List](Long-Yield-List.md)
* Low Cohesion, including
* [Feature Envy](Feature-Envy.md)
* [Utility Function](Utility-Function.md)
* [Module Initialize](Module-Initialize.md)
* [Nested Iterators](Nested-Iterators.md)
* [Prima-Donna-Method](Prima-Donna-Method.md)
* [Simulated Polymorphism](Simulated-Polymorphism.md), including
* [Nil Check](Nil-Check.md)
* [Repeated Conditional](Repeated-Conditional.md)
* [Too Many Statements](Too-Many-Statements.md)
* [Uncommunicative Name](Uncommunicative-Name.md), including
* [Uncommunicative Method Name](Uncommunicative-Method-Name.md)
* [Uncommunicative Module Name](Uncommunicative-Module-Name.md)
* [Uncommunicative Parameter Name](Uncommunicative-Parameter-Name.md)
* [Uncommunicative Variable Name](Uncommunicative-Variable-Name.md)
* [Unused Parameters](Unused-Parameters.md)
Loading

0 comments on commit c20d10c

Please sign in to comment.