Class: Lois::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/lois/cli.rb

Instance Method Summary collapse

Instance Method Details

#brakemanObject



109
110
111
112
113
114
115
116
117
# File 'lib/lois/cli.rb', line 109

def brakeman
  puts 'Checking brakeman'
  configure(options)
  if system('brakeman -o lois/brakeman.html -o /dev/stdout')
    Lois.config.github.success('brakeman', 'No rails vulnerabilities found.')
  else
    Lois.config.github.failure('brakeman', 'Rails vulnerabilities found.')
  end
end

#bundler_auditObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/lois/cli.rb', line 60

def bundler_audit
  puts 'Checking bundler-audit'
  configure(options)

  ignore = " --ignore #{options[:ignore]}"
  command = 'bundle-audit check --verbose --update'
  command += ignore if options[:ignore]
  output = `#{command}`
  result = $CHILD_STATUS
  File.write('lois/bundler-audit.log', output)
  puts output

  if result.success?
    Lois.config.github.success('bundler-audit', 'No gem vulnerabilities found.')
  else
    Lois.config.github.failure('bundler-audit', 'Gem vulnerabilities detected!')
  end
end

#i18n_tasksObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/lois/cli.rb', line 18

def i18n_tasks
  puts 'Checking i18n-tasks'
  configure(options)
  locale_param = (" -l #{options[:locale]}" if options[:locale].to_s.length.positive?)
  if system("i18n-tasks health#{locale_param}")
    Lois.config.github.success('i18n-tasks', 'The translation files are healthy.')
  else
    Lois.config.github.failure('i18n-tasks', 'The translation files are not healthy')
  end
end

#reekObject



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/lois/cli.rb', line 88

def reek
  puts 'Checking reek'
  configure(options)

  system('reek -f html > lois/reek.html')
  if system('reek -n --sort-by smelliness')
    Lois.config.github.success('reek', 'No code smells.')
  else
    Lois.config.github.failure('reek', 'Code smells found.')
  end
end

#rubocopObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/lois/cli.rb', line 38

def rubocop
  puts 'Checking Rubocop'
  configure(options)

  if system('rubocop -f html -o lois/rubocop.html -f p')
    Lois.config.github.success('rubocop', 'Rubocop passed')
  else
    Lois.config.github.failure('rubocop', 'Rubocop failed')
  end
end

#simplecovObject



134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/lois/cli.rb', line 134

def simplecov
  puts 'Checking simplecov'
  configure(options)

  actual = options[:actual].to_f
  actual_formatted = format('%.2f%%', actual)

  if actual >= options[:minimum].to_f
    Lois.config.github.success('simplecov', "#{actual_formatted} coverage.")
  else
    Lois.config.github.failure('simplecov', "#{actual_formatted} is too low.")
  end
end