Class: Danger::DangerTypos
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerTypos
- Defined in:
- lib/typos/plugin.rb
Overview
[Danger](danger.systems/ruby/) plugin for [typos](github.com/crate-ci/typos).
Instance Attribute Summary collapse
-
#binary_path ⇒ String
typos path.
Instance Method Summary collapse
-
#run(options = {}) ⇒ void
Execute typos.
Instance Attribute Details
#binary_path ⇒ String
typos path
20 21 22 |
# File 'lib/typos/plugin.rb', line 20 def binary_path @binary_path end |
Instance Method Details
#run(options = {}) ⇒ void
This method returns an undefined value.
Execute typos
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/typos/plugin.rb', line 24 def run( = {}) return if target_files.empty? args = [ "--force-exclude", "--format", "json" ] args.push("--config", [:config_path]) if [:config_path] args += target_files stdout, = Open3.capture3(cmd_path, *args) stdout.split("\n").each do |result| data = JSON.parse(result) next if data["type"] != "typo" warn( "`#{data['typo']}` should be `#{data['corrections'].first}`", file: data["path"], line: data["line_num"] ) end end |