class Danger::DangerWCC
Constants
- DEFAULT_COMMIT_LINT_OPTIONS
- DEFAULT_OPTIONS
Public Instance Methods
all(options = {})
click to toggle source
Runs all the included checks in the plugin
# File lib/wcc/plugin.rb, line 31 def all(options = {}) options = DEFAULT_OPTIONS.merge(options) to_run = options.keys.reject { |check_name| options[check_name] == false } raise ArgumentError, 'No Enabled Checks' if to_run.empty? to_run.each do |check_name| check_options = options.fetch(check_name, {}) public_send(check_name, check_options == true ? {} : check_options) end end
brakeman(options = {})
click to toggle source
# File lib/wcc/plugin.rb, line 66 def brakeman(options = {}) logger.info "brakeman: #{options}" diff = run_and_diff('bundle exec brakeman -f tabs 2>/dev/null '\ '| sed s@`pwd`/@@ | sed -E "s/([0-9]+)//g"') diff = GitDiff.from_string(diff) brakeman_lines = run 'bundle exec brakeman -f tabs 2>/dev/null '\ '| sed s@`pwd`/@@' brakeman_lines = brakeman_lines.lines each_addition_in_diff(diff) do |line| fields = brakeman_lines[line.line_number.right - 1].split("\t") add_brakeman_error(fields, fields[0]) end end
commit_lint(options = {})
click to toggle source
Lints the commit messages
# File lib/wcc/plugin.rb, line 56 def commit_lint(options = {}) logger.info "commit_lint: #{options}" CommitLint.new(self, DEFAULT_COMMIT_LINT_OPTIONS.merge(options)).perform end
dependencies(options = {})
click to toggle source
# File lib/wcc/plugin.rb, line 103 def dependencies(options = {}) logger.info "dependencies: #{options}" Dependencies.new(self, options).perform end
flay(options = {})
click to toggle source
# File lib/wcc/plugin.rb, line 83 def flay(options = {}) logger.info "flay: #{options}" flay_results = parse_flay_results each_addition_in_diff do |add, _h, file| search = "#{file.b_path}:#{add.line_number.right}" flay_results.each do |warning, lines| other = lines.reject { |l| l == search } next unless other.length < lines.length add_flay_warning(warning, other, file, add) end end end
jshint(options = {})
click to toggle source
# File lib/wcc/plugin.rb, line 98 def jshint(options = {}) logger.info "jshint: #{options}" Jshint.new(self, options).perform end
reek(options = {})
click to toggle source
# File lib/wcc/plugin.rb, line 61 def reek(options = {}) logger.info "reek: #{options}" Reek.new(self, options).perform end
rubocop_exceptions(options = {})
click to toggle source
Checks for if Rubocop was disabled in the source
# File lib/wcc/plugin.rb, line 50 def rubocop_exceptions(options = {}) logger.info "rubocop_exceptions: #{options}" RubocopExceptions.new(self, options).perform end
todos(options = {})
click to toggle source
Checks for added TODOs
# File lib/wcc/plugin.rb, line 44 def todos(options = {}) logger.info "TODOs: #{options}" Todos.new(self, options).perform end
yarn_deduplicate(options = {})
click to toggle source
# File lib/wcc/plugin.rb, line 108 def yarn_deduplicate(options = {}) logger.info "yarn_deduplicate: #{options}" YarnDeduplicate.new(self, options).perform end
Private Instance Methods
add_brakeman_error(fields, file)
click to toggle source
# File lib/wcc/plugin.rb, line 130 def add_brakeman_error(fields, file) message = "#{fields[2]} #{fields[3]} #{fields[4]} confidence: #{fields[5]}" fail(message, file: file, line: fields[1].to_i) end
add_flay_warning(warning, other, file, line)
click to toggle source
# File lib/wcc/plugin.rb, line 135 def add_flay_warning(warning, other, file, line) other = other.map { |l| github.html_link(l.gsub(/\:/, '#L')) } message = "#{warning} at:\n " + other.join("\n ") warn(message, file: file.b_path, line: line.line_number.right) end
parse_flay_results()
click to toggle source
# File lib/wcc/plugin.rb, line 115 def parse_flay_results flay = run('bundle exec flay app/**/*.rb lib/**/*.rb') flay_results = {} current = nil flay.lines.each do |flay_line| if m = flay_line.match(/^\d+\)\s+(.+)$/i) current = [] flay_results[m.captures[0]] = current elsif current && flay_line =~ /^\s+.+\:\d+\s*$/i current << flay_line.strip! end end flay_results end