Class: TaskGen

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
rake_modules/taskgen.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ TaskGen

Returns a new instance of TaskGen.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'rake_modules/taskgen.rb', line 24

def initialize(path)
  @tasks_categories = [
    :puppet_lint,
    :typos,
    :syntax,
    :json_syntax,
    :rubocop,
    :common_yaml,
    :hiera_defaults,
    :shellcheck,
    :python_extensions,
    :spec,
    :tox,
    :per_module_tox,
  ]
  @git = GitOps.new(path)
  @changed_files_with_vendored = @git.changes_in_head
  vendor_paths = ['vendor/**/*', 'vendor_modules/**/*', 'core_modules/**/*']
  @changed_files = FileList[@changed_files_with_vendored].exclude(vendor_paths).to_a
  PuppetSyntax.exclude_paths = vendor_paths
  @tasks = setup_tasks + setup_spdx(@git)
  @failed_specs = []
end

Instance Attribute Details

#failed_specsObject

Returns the value of attribute failed_specs.



22
23
24
# File 'rake_modules/taskgen.rb', line 22

def failed_specs
  @failed_specs
end

#tasksObject

Returns the value of attribute tasks.



22
23
24
# File 'rake_modules/taskgen.rb', line 22

def tasks
  @tasks
end

Instance Method Details



59
60
61
62
63
64
65
66
67
68
69
70
# File 'rake_modules/taskgen.rb', line 59

def print_wmf_style_violations(problems, other = nil, format = '%{path}:%{line} %{message}')
  # Prints the wmf style violations
  other ||= {}
  events = problems.select do |p|
    other.select { |x| x[:message] == p[:message] && x[:path] == p[:path] }.empty?
  end
  events.each do |p|
    p[:KIND] = p[:kind].to_s.upcase
    puts format(format, p).red
  end
  puts "Nothing found".green if events.length.zero?
end

#setup_wmf_lint_checkObject



48
49
50
51
52
53
54
55
56
57
# File 'rake_modules/taskgen.rb', line 48

def setup_wmf_lint_check
  # Sets up puppet-lint to only check for the wmf style guide
  PuppetLint.configuration.checks.each do |check|
    if check == :wmf_styleguide
      PuppetLint.configuration.send('enable_wmf_styleguide')
    else
      PuppetLint.configuration.send("disable_#{check}")
    end
  end
end