Sha256: 43ee81e18e6adc9cf99395541947c319ef7a932d286314ebef7d6c1b9c882d97

Contents?: true

Size: 732 Bytes

Versions: 15

Compression:

Stored size: 732 Bytes

Contents

module Skeptic
  module Rules
    class NoSemicolons
      DESCRIPTION = 'Do not allow semicolons as statement separators'

      def initialize(enabled = false)
        @enabled = enabled
      end

      def apply_to(code, tokens, sexp)
        @locations = tokens.
          select { |location, type, token| token == ';' and type == :on_semicolon }.
          map { |location, type, token| location }
        self
      end

      def violations
        @locations.map do |line, column|
          "You have a semicolon at line #{line}, column #{column}"
        end
      end

      def name
        'No semicolons as expression separators'
      end

      def semicolon_locations
        @locations
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
skeptic-0.0.16 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.15 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.14 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.12 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.11 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.10 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.9 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.8 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.7 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.6 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.5 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.4 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.3 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.2 lib/skeptic/rules/no_semicolons.rb
skeptic-0.0.1 lib/skeptic/rules/no_semicolons.rb