Class: Danger::DangerWCC
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerWCC
- Defined in:
- lib/wcc/plugin.rb,
lib/wcc/rubocop_exceptions.rb,
lib/wcc/yarn_deduplicate.rb,
lib/wcc/dependencies.rb,
lib/wcc/commit_lint.rb,
lib/wcc/jshint.rb,
lib/wcc/todos.rb,
lib/wcc/reek.rb
Overview
rubocop:disable Metrics/ClassLength
Defined Under Namespace
Classes: CommitLint, Dependencies, Jshint, Reek, RubocopExceptions, Todos, YarnDeduplicate
Constant Summary collapse
- DEFAULT_OPTIONS =
{ rubocop_exceptions: true, todos: true, brakeman: true, dependencies: true, yarn_deduplicate: true, commit_lint: false, reek: false, jshint: false, flay: false }.freeze
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Runs all the included checks in the plugin.
- #brakeman(options = {}) ⇒ Object
-
#commit_lint(options = {}) ⇒ Object
Lints the commit messages.
- #dependencies(options = {}) ⇒ Object
- #flay(options = {}) ⇒ Object
- #jshint(options = {}) ⇒ Object
- #reek(options = {}) ⇒ Object
-
#rubocop_exceptions(options = {}) ⇒ Object
Checks for if Rubocop was disabled in the source.
-
#todos(options = {}) ⇒ Object
Checks for added TODOs.
- #yarn_deduplicate(options = {}) ⇒ Object
Methods included from Github
#add_labels, #labels, #pr_number, #repo_name
Methods included from Utils
#diff_strings, #each_addition_in_diff, #each_file_in_diff, #each_line_in_diff, #find_file_in_diff, #find_in_diff, #format_links_as_markdown, #issue, #logger, #parsed_diffs, #plugin, #run, #run_and_diff, #with_revision
Instance Method Details
#all(options = {}) ⇒ Object
Runs all the included checks in the plugin
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wcc/plugin.rb', line 31 def all( = {}) = DEFAULT_OPTIONS.merge() to_run = .keys.reject { |check_name| [check_name] == false } raise ArgumentError, 'No Enabled Checks' if to_run.empty? to_run.each do |check_name| = .fetch(check_name, {}) public_send(check_name, == true ? {} : ) end end |
#brakeman(options = {}) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/wcc/plugin.rb', line 66 def brakeman( = {}) 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 = {}) ⇒ Object
Lints the commit messages
56 57 58 59 |
# File 'lib/wcc/plugin.rb', line 56 def commit_lint( = {}) logger.info "commit_lint: #{options}" CommitLint.new(self, DEFAULT_COMMIT_LINT_OPTIONS.merge()).perform end |
#dependencies(options = {}) ⇒ Object
103 104 105 106 |
# File 'lib/wcc/plugin.rb', line 103 def dependencies( = {}) logger.info "dependencies: #{options}" Dependencies.new(self, ).perform end |
#flay(options = {}) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/wcc/plugin.rb', line 83 def flay( = {}) 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 = {}) ⇒ Object
98 99 100 101 |
# File 'lib/wcc/plugin.rb', line 98 def jshint( = {}) logger.info "jshint: #{options}" Jshint.new(self, ).perform end |
#reek(options = {}) ⇒ Object
61 62 63 64 |
# File 'lib/wcc/plugin.rb', line 61 def reek( = {}) logger.info "reek: #{options}" Reek.new(self, ).perform end |
#rubocop_exceptions(options = {}) ⇒ Object
Checks for if Rubocop was disabled in the source
50 51 52 53 |
# File 'lib/wcc/plugin.rb', line 50 def rubocop_exceptions( = {}) logger.info "rubocop_exceptions: #{options}" RubocopExceptions.new(self, ).perform end |
#todos(options = {}) ⇒ Object
Checks for added TODOs
44 45 46 47 |
# File 'lib/wcc/plugin.rb', line 44 def todos( = {}) logger.info "TODOs: #{options}" Todos.new(self, ).perform end |
#yarn_deduplicate(options = {}) ⇒ Object
108 109 110 111 |
# File 'lib/wcc/plugin.rb', line 108 def yarn_deduplicate( = {}) logger.info "yarn_deduplicate: #{options}" YarnDeduplicate.new(self, ).perform end |