Class: RemLint::Rules::ShellMaxlen

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

Overview

shell() given a maximum length that returns nothing.

shell(cmd) reads up to 511 characters of the command's output; shell(cmd, n) reads up to n. A zero returns the empty string, and a command that produced no output returns the empty string too -- so shell(cmd, 0) is indistinguishable from a command that did not work, and debugging starts in the wrong place entirely.

A negative n is the documented sentinel for "no limit", so only zero is reported.

Constant Summary collapse

SHELL =
"shell"

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



20
21
22
# File 'lib/remlint/rules/shell_maxlen.rb', line 20

def self.default_severity
  "warning"
end

.descriptionObject



24
25
26
# File 'lib/remlint/rules/shell_maxlen.rb', line 24

def self.description
  "shell() given a maximum length of zero, which always returns nothing."
end

Instance Method Details

#checkObject



28
29
30
31
32
33
34
# File 'lib/remlint/rules/shell_maxlen.rb', line 28

def check
  document.logical_lines.each_with_index do |logical_line, index|
    if document.commands[index].code?
      check_line(logical_line)
    end
  end
end