Class: Danger::DangerIblinter
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerIblinter
- Defined in:
- lib/iblinter/plugin.rb
Overview
Lint Interface Builder files inside your projects. This is done using the [IBLinter](github.com/IBDecodable/IBLinter) tool.
Instance Attribute Summary collapse
-
#binary_path ⇒ void
The path to IBLinter“s execution.
Instance Method Summary collapse
-
#iblinter ⇒ IBLinterRunner
Instantiate iblinter.
-
#lint(path = Dir.pwd, fail_on_warning: false, inline_mode: true, options: {}) ⇒ void
Lints IB files.
Instance Attribute Details
#binary_path ⇒ void
This method returns an undefined value.
The path to IBLinter“s execution
20 21 22 |
# File 'lib/iblinter/plugin.rb', line 20 def binary_path @binary_path end |
Instance Method Details
#iblinter ⇒ IBLinterRunner
Instantiate iblinter
53 54 55 |
# File 'lib/iblinter/plugin.rb', line 53 def iblinter IBLinterRunner.new(@binary_path) end |
#lint(path = Dir.pwd, fail_on_warning: false, inline_mode: true, options: {}) ⇒ void
This method returns an undefined value.
Lints IB files. Will fail if ‘iblinter` cannot be installed correctly.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/iblinter/plugin.rb', line 25 def lint(path = Dir.pwd, fail_on_warning: false, inline_mode: true, options: {}) raise "iblinter is not installed" unless iblinter_installed? issues = iblinter.lint(path, ) return if issues.empty? errors = issues.select { |v| v["level"] == "error" } warnings = issues.select { |v| v["level"] == "warning" } if inline_mode send_inline_comment(warnings, fail_on_warning ? :fail : :warn) send_inline_comment(errors, :fail) else = "### IBLinter found issues\n\n" << markdown_issues(errors, "Errors", ":rotating_light:") unless errors.empty? << markdown_issues(warnings, "Warnings", ":warning:") unless warnings.empty? markdown end if errors.count.positive? fail "Failed due to IBLinter errors" elsif fail_on_warning && warnings.count.positive? fail "Failed due to IBLinter warnings" end end |