Class: Vtasks::Lint

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/vtasks/lint.rb

Overview

Lint tasks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Lint

Returns a new instance of Lint.



8
9
10
11
# File 'lib/vtasks/lint.rb', line 8

def initialize(options = {})
  @file_list ||= options.fetch(:file_list, FileList['{lib,spec}/**/*.rb'])
  define_tasks
end

Instance Attribute Details

#file_listObject (readonly)

Returns the value of attribute file_list.



6
7
8
# File 'lib/vtasks/lint.rb', line 6

def file_list
  @file_list
end

Instance Method Details

#define_tasksObject

Define tasks



14
15
16
17
18
19
20
21
22
23
# File 'lib/vtasks/lint.rb', line 14

def define_tasks
  desc 'Check for code smells with Reek and Rubocop'
  task lint: ['lint:reek', 'lint:rubocop']

  namespace :lint do
    rubocop
    reek
    rubycritic
  end
end

#reekObject

Reek



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/vtasks/lint.rb', line 40

def reek
  begin
    require 'reek/rake/task'
  rescue LoadError
    nil # Might be in a group that is not installed
  end
  ::Reek::Rake::Task.new do |task|
    task.source_files  = file_list
    task.fail_on_error = false
    task.reek_opts     = '--wiki-links --color'
  end
end

#rubocopObject

RuboCop



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vtasks/lint.rb', line 26

def rubocop
  begin
    require 'rubocop/rake_task'
  rescue LoadError
    nil # Might be in a group that is not installed
  end
  desc 'Run RuboCop on the tasks and lib directory'
  ::RuboCop::RakeTask.new(:rubocop) do |task|
    task.patterns = file_list
    task.options  = ['--display-cop-names', '--extra-details']
  end
end

#rubycriticObject

Ruby Critic



54
55
56
57
58
59
60
61
62
63
# File 'lib/vtasks/lint.rb', line 54

def rubycritic
  begin
    require 'rubycritic/rake_task'
  rescue LoadError
    nil # Might be in a group that is not installed
  end
  ::RubyCritic::RakeTask.new do |task|
    task.paths = file_list
  end
end