Class: Danger::PluginLint

Inherits:
CLAide::Command::Plugins
  • Object
show all
Defined in:
lib/danger/commands/plugins/plugin_lint.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ PluginLint

Returns a new instance of PluginLint.



12
13
14
15
16
17
18
# File 'lib/danger/commands/plugins/plugin_lint.rb', line 12

def initialize(argv)
  @warnings_as_errors = argv.flag?("warnings-as-errors", false)
  @refs = argv.arguments! unless argv.arguments.empty?
  @cork = Cork::Board.new(silent: argv.option("silent", false),
                          verbose: argv.option("verbose", false))
  super
end

Instance Attribute Details

#corkObject

Returns the value of attribute cork.



10
11
12
# File 'lib/danger/commands/plugins/plugin_lint.rb', line 10

def cork
  @cork
end

Class Method Details

.optionsObject



32
33
34
35
36
# File 'lib/danger/commands/plugins/plugin_lint.rb', line 32

def self.options
  [
    ["--warnings-as-errors", "Ensure strict linting."]
  ].concat(super)
end

Instance Method Details

#runObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/danger/commands/plugins/plugin_lint.rb', line 38

def run
  file_resolver = PluginFileResolver.new(@refs)
  data = file_resolver.resolve

  parser = PluginParser.new(data[:paths], verbose: true)
  parser.parse
  json = parser.to_json

  linter = PluginLinter.new(json)
  linter.lint
  linter.print_summary(cork)

  abort("Failing due to errors\n".red) if linter.failed?
  abort("Failing due to warnings as errors\n".red) if @warnings_as_errors && !linter.warnings.empty?
end