Class: Appium::Lint::H2Invalid

Inherits:
Base
  • Object
show all
Defined in:
lib/appium_doc_lint/lint/h2_invalid.rb

Overview

h2 must use the ‘##` syntax and not the `—` underline syntax. check for three - to reduce false positives

Constant Summary collapse

FAIL =
'h2 must not use --- underline syntax. Use ## instead'

Instance Attribute Summary

Attributes inherited from Base

#input, #warnings

Instance Method Summary collapse

Methods inherited from Base

#initialize, #warn

Constructor Details

This class inherits a constructor from Appium::Lint::Base

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/appium_doc_lint/lint/h2_invalid.rb', line 7

def call
  previous_line = ''

  input.lines.each_with_index do |line, index|
    # If the previous line is empty then --- triggers a line break
    previous_line_not_empty = !previous_line.match(/^\s*$/)
    h2_invalid              = previous_line_not_empty && line.match(/^---+\s*$/)
    warn index if h2_invalid

    previous_line = line
  end

  warnings
end

#failObject



24
25
26
# File 'lib/appium_doc_lint/lint/h2_invalid.rb', line 24

def fail
  FAIL
end