9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/onceover/codequality/cli.rb', line 9
def self.command
@cmd ||= Cri::Command.define do
name 'codequality'
usage 'codequality [--no-syntax] [--no-lint] [--no-docs] [--html-docs] [--no-puppetfile]'
summary "Code Quality checking for onceover"
description " Check files in your Control Repository for Lint and Syntax errors\n DESCRIPTION\n \n option :no_lint, 'Do not check for lint errors', :argument => :optional\n option :no_puppetfile, 'Do not check Puppetfile for syntax errors', :argument => :optional\n option :no_syntax, 'Do not check for syntax errors', :argument => :optional\n option :no_docs, 'Do not generate documentation (puppet-strings) for local modules', :argument => :optional\n option :html_docs, 'Generate docs in HTML format instead of markdown', :argument => :optional\n\n run do |opts, args, cmd|\n no_lint = opts[:no_lint] || false\n no_syntax = opts[:no_syntax] || false\n no_docs = opts[:no_docs] || false\n no_puppetfile = opts[:no_puppetfile] || false\n html_docs = opts[:html_docs] || false\n status = true\n\n if ! no_syntax\n logger.info \"Checking syntax...\"\n if ! Onceover::CodeQuality::Syntax.puppet\n status = false\n logger.error \"Syntax test failed, see previous errors\"\n end\n end\n\n if ! no_lint\n logger.info \"Checking for lint...\"\n if ! Onceover::CodeQuality::Lint.puppet\n status = false\n logger.error \"Lint test failed, see previous errors\"\n end\n end\n\n if ! no_puppetfile\n logger.info \"Checking Puppetfile\"\n if ! Onceover::CodeQuality::Puppetfile.puppetfile\n status = false\n logger.error \"puppetfile syntax failed, see previous errors\"\n end\n end\n\n if ! no_docs\n logger.info \"Generating documentation...\"\n if ! Onceover::CodeQuality::Docs.puppet_strings(html_docs)\n status = false\n logger.error \"Documentation generation failed, see previous errors\"\n end\n end\n\n if status\n logger.info \"Code Quality tests passed, have a nice day\"\n else\n logger.error \"Code Quality tests failed, see previous error\"\n exit 1\n end\n end\n end\nend\n"
|