Class: RemLint::Rules::KeywordCase

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

Overview

Command keywords written in a case the file does not otherwise use.

Remind's keywords are case-insensitive -- remind.vim opens with syn case ignore for exactly this reason -- so this is a consistency rule and nothing more. It is off by default: examples/alignment.rem deliberately mixes MSG and msg to show the two are the same, and a linter that shouts at the shipped examples for their own subject matter is a linter people switch off.

EnforcedStyle: upper (the default when the rule is on) matches every example Remind ships and the manual's own prose. lower is the mirror image. consistent picks whichever style the file already uses more and reports the rest, which is the setting for adopting the rule on a file you did not write.

Constant Summary collapse

STYLES =
%w[upper lower consistent].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, default_severity, find, inherited, #initialize, rule_name, #rule_name, #run

Constructor Details

This class inherits a constructor from RemLint::Rule

Class Method Details

.descriptionObject



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

def self.description
  "Command keywords in a case other than the file's own."
end

.enabled_by_default?Boolean

Returns:

  • (Boolean)


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

def self.enabled_by_default?
  false
end

Instance Method Details

#checkObject



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

def check
  style = resolve_style

  keyword_commands.each do |command|
    if !conforms?(command.word, style)
      offend(
        command.line,
        "Write `#{cased(command.word, style)}` rather than `#{command.word}`",
        column: command.keyword_column,
      )
    end
  end
end