Class: Reek::Rake::Task

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/reek/rake/task.rb

Overview

A Rake task that runs reek on a set of source files.

Example:

require 'reek/rake/task'

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

This will create a task that can be run with:

rake reek

Examples:

rake reek                                # checks lib/**/*.rb
rake reek REEK_SRC=just_one_file.rb      # checks a single source file
rake reek REEK_OPTS=-s                   # sorts the report by smell

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :reek) {|_self| ... } ⇒ Task

Defines a new task, using the name name.

Yields:

  • (_self)

Yield Parameters:


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/reek/rake/task.rb', line 78

def initialize(name = :reek)
  @name = name
  @libs = [File.expand_path(File.dirname(__FILE__) + '/../../../lib')]
  @config_file = nil
  @source_files = nil
  @ruby_opts = []
  @reek_opts = ''
  @fail_on_error = true
  @sort = nil

  yield self if block_given?
  @config_file ||= Pathname.glob('config/**/*.reek').detect(&:file?)
  @source_files ||= 'lib/**/*.rb'
  define
end

Instance Attribute Details

#config_file=(value) ⇒ Object

Glob pattern to match config files. Setting the REEK_CFG environment variable overrides this. Defaults to 'config/*/.reek'.


46
47
48
# File 'lib/reek/rake/task.rb', line 46

def config_file=(value)
  @config_file = value
end

#fail_on_errorObject

Whether or not to fail Rake when an error occurs (typically when smells are found). Defaults to true.


71
72
73
# File 'lib/reek/rake/task.rb', line 71

def fail_on_error
  @fail_on_error
end

#libsObject

Array of directories to be added to $LOAD_PATH before running reek. Defaults to ['<the absolute path to reek's lib directory>']


41
42
43
# File 'lib/reek/rake/task.rb', line 41

def libs
  @libs
end

#nameObject

Name of reek task. Defaults to :reek.


37
38
39
# File 'lib/reek/rake/task.rb', line 37

def name
  @name
end

#reek_optsObject

String containing commandline options to be passed to Reek. Setting the REEK_OPTS environment variable overrides this value. Defaults to ''.


64
65
66
# File 'lib/reek/rake/task.rb', line 64

def reek_opts
  @reek_opts
end

#ruby_optsObject

Array of commandline options to pass to ruby. Defaults to [].


67
68
69
# File 'lib/reek/rake/task.rb', line 67

def ruby_opts
  @ruby_opts
end

#source_filesObject

Glob pattern to match source files. Setting the REEK_SRC environment variable overrides this. Defaults to 'lib/*/.rb'.


59
60
61
# File 'lib/reek/rake/task.rb', line 59

def source_files
  @source_files
end

#verboseObject

Use verbose output. If this is set to true, the task will print the reek command to stdout. Defaults to false.


75
76
77
# File 'lib/reek/rake/task.rb', line 75

def verbose
  @verbose
end

Instance Method Details

#config_filesObject


52
53
54
# File 'lib/reek/rake/task.rb', line 52

def config_files
  @config_file
end

#config_files=(value) ⇒ Object


48
49
50
# File 'lib/reek/rake/task.rb', line 48

def config_files=(value)
  @config_file = value
end