Class: RemLint::Rules::DebugCommand

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

Overview

DEBUG flags that do nothing, and DEBUG flags left switched on.

DoDebug in src/main.c reads the argument character by character: + turns flags on, - turns them off, and thirteen letters name a flag. Anything else reaches a default: branch that warns -- but only at warning level 05.02.03, so a script that has not raised the level gets a debug session that quietly does nothing.

The other half matters more in a repository than at a terminal. Debug output is voluminous and goes to standard error, so a DEBUG +x that was never matched by a DEBUG -x turns every later run into a trace log -- including the one under cron, which mails it to somebody.

Constant Summary collapse

FLAGS =

The flag letters DoDebug switches on, case-insensitive.

%w[p e q s h x t v l f n u z].freeze
SIGNS =
%w[+ -].freeze

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



25
26
27
# File 'lib/remlint/rules/debug_command.rb', line 25

def self.default_severity
  "warning"
end

.descriptionObject



29
30
31
# File 'lib/remlint/rules/debug_command.rb', line 29

def self.description
  "A DEBUG flag Remind does not define, or one switched on and never off."
end

Instance Method Details

#checkObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/remlint/rules/debug_command.rb', line 33

def check
  left_on = {}

  document.code_commands.each do |command|
    if command.keyword?("DEBUG")
      scan(command, left_on)
    end
  end

  report_left_on(left_on)
end