Class: RemLint::Rules::DanglingContinuation

Inherits:
RemLint::Rule show all
Defined in:
lib/remlint/rules/dangling_continuation.rb

Overview

Backslashes that look like line continuations and are not.

Remind continues a line only when the backslash is the final character of it (src/files.c: if (l && (DBufValue(&buf)[l-1] == '\\'))). One invisible space after the backslash and the continuation silently stops being one -- the command is cut in half, the first half usually still parses as something, and the error surfaces somewhere else entirely.

Both halves of that are worth reporting:

backslash then whitespace  the join you meant did not happen
backslash at end of file   the command you opened never closed

Constant Summary collapse

SWALLOWED =
/\\[ \t]+\z/
SWALLOWED_MESSAGE =
"Backslash followed by whitespace does not continue the line; " \
"the backslash must be the last character"
UNTERMINATED_MESSAGE =
"File ends inside a line continuation"

Constants inherited from RemLint::Rule

RemLint::Rule::REGISTRY

Instance Attribute Summary

Attributes inherited from RemLint::Rule

#config, #document, #offenses

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RemLint::Rule

all, enabled_by_default?, find, inherited, #initialize, rule_name, #rule_name, #run

Constructor Details

This class inherits a constructor from RemLint::Rule

Class Method Details

.default_severityObject



28
29
30
# File 'lib/remlint/rules/dangling_continuation.rb', line 28

def self.default_severity
  "error"
end

.descriptionObject



32
33
34
# File 'lib/remlint/rules/dangling_continuation.rb', line 32

def self.description
  "A backslash that looks like a line continuation but is not one."
end

Instance Method Details

#checkObject



36
37
38
39
# File 'lib/remlint/rules/dangling_continuation.rb', line 36

def check
  check_swallowed
  check_unterminated
end