Class: Skeptic::Rules::NoSemicolons
- Inherits:
-
Object
- Object
- Skeptic::Rules::NoSemicolons
- Defined in:
- lib/skeptic/rules/no_semicolons.rb
Constant Summary collapse
- DESCRIPTION =
'Do not allow semicolons as statement separators'
Instance Method Summary collapse
- #apply_to(code, tokens, sexp) ⇒ Object
-
#initialize(enabled = false) ⇒ NoSemicolons
constructor
A new instance of NoSemicolons.
- #name ⇒ Object
- #semicolon_locations ⇒ Object
- #violations ⇒ Object
Constructor Details
#initialize(enabled = false) ⇒ NoSemicolons
Returns a new instance of NoSemicolons.
6 7 8 |
# File 'lib/skeptic/rules/no_semicolons.rb', line 6 def initialize(enabled = false) @enabled = enabled end |
Instance Method Details
#apply_to(code, tokens, sexp) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/skeptic/rules/no_semicolons.rb', line 10 def apply_to(code, tokens, sexp) @locations = tokens. select { |location, type, token| token == ';' and type == :on_semicolon }. map { |location, type, token| location } self end |
#name ⇒ Object
23 24 25 |
# File 'lib/skeptic/rules/no_semicolons.rb', line 23 def name 'No semicolons as expression separators' end |
#semicolon_locations ⇒ Object
27 28 29 |
# File 'lib/skeptic/rules/no_semicolons.rb', line 27 def semicolon_locations @locations end |
#violations ⇒ Object
17 18 19 20 21 |
# File 'lib/skeptic/rules/no_semicolons.rb', line 17 def violations @locations.map do |line, column| "You have a semicolon at line #{line}, column #{column}" end end |