Skip to content

Latest commit

 

History

History
66 lines (46 loc) · 1.69 KB

Rake-Task.md

File metadata and controls

66 lines (46 loc) · 1.69 KB

Rake Task

Introduction

Reek provides a Rake task that runs Reek on a set of source files. In its most simple form you just include something like that in your Rakefile:

require 'reek/rake/task'

Reek::Rake::Task.new do |t|
  t.fail_on_error = false
end

In its most simple form, that's it.

When you now run:

rake -T

you should see

rake reek  # Check for code smells

Configuration via task

An more sophisticated rake task that would make use of all available configuration options could look like this:

Reek::Rake::Task.new do |t|
  t.name          = 'custom_rake' # Whatever name you want. Defaults to "reek".
  t.config_file   = 'config/.reek.yml' # Defaults to nothing.
  t.source_files  = 'vendor/**/*.rb' # Glob pattern to match source files. Defaults to lib/**/*.rb
  t.reek_opts     = '-U'  # Defaults to ''. You can pass all the options here in that are shown by "reek -h"
  t.fail_on_error = false # Defaults to true
  t.verbose       = true  # Defaults to false
end

Alternatively, you can create your own Rake::FileList and use that for source_files:

Reek::Rake::Task.new do |t|
  t.source_files = FileList['lib/**/*.rb'].exclude('lib/templates/**/*.rb')
end

Configuration via environment variables

You can overwrite the following attributes by environment variables:

  • "reek_opts" by using REEK_OPTS
  • "config_file" by using REEK_CFG
  • "source_files" by using REEK_SRC

An example rake call using environment variables could look like this:

REEK_CFG="config/custom.reek" REEK_OPTS="-s" rake reek

See also: Reek-Driven-Development