LinuxCommandLibrary

reek

Detect code smells in Ruby source files

TLDR

Check Ruby code for smells

$ reek [file.rb]
copy
Check entire project
$ reek
copy
Check with specific format
$ reek --format [yaml] [file.rb]
copy
Show available smell types
$ reek --smell-types
copy
Exclude specific smells
$ reek --except [TooManyStatements] [file.rb]
copy

SYNOPSIS

reek [options] [files...]

DESCRIPTION

Reek is a static analysis tool that detects code smells in Ruby source files, reporting potential design problems such as long methods, feature envy, data clumps, and excessive parameter lists. It examines code structure and naming patterns to identify areas that may benefit from refactoring, based on principles from Martin Fowler's refactoring catalog.
Output can be formatted as text, YAML, JSON, or HTML for integration with CI pipelines and code review workflows. Individual smell types can be included or excluded with --only and --except, and project-wide configuration in .reek.yml allows tuning thresholds and excluding paths.

PARAMETERS

-f, --format format

Output format (text, yaml, json, html).
--smell-types
List available smells.
--except smells
Exclude smells.
--only smells
Check only specified smells.
-c, --config file
Configuration file.

EXAMPLES

$ # Check file
reek app/models/user.rb

# Check directory
reek app/

# JSON output
reek --format json app/ > smells.json

# List smell types
reek --smell-types

# Specific smells only
reek --only "TooManyStatements,LongMethod" app/

# With configuration
reek -c .reek.yml
copy

SMELL TYPES

$ TooManyStatements  - Method too long
FeatureEnvy        - Wrong class responsibility
DataClump          - Data always together
LongParameterList  - Too many parameters
DuplicateMethodCall - Repeated calls
copy

CONFIGURATION (.reek.yml)

$ detectors:
  TooManyStatements:
    max_statements: 10
  exclude_paths:
    - spec/
copy

CAVEATS

Ruby-specific. Some smells may be false positives. Configure per project.

HISTORY

Reek was created by Kevin Rutherford as a Ruby code smell detector based on Martin Fowler's refactoring concepts.

SEE ALSO

rubocop(1), ruby(1), brakeman(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community