lib/rubocop/cop/cop.rb in rubocop-0.2.1 vs lib/rubocop/cop/cop.rb in rubocop-0.3.0
- old
+ new
@@ -33,41 +33,31 @@
class Cop
attr_accessor :offences
attr_writer :correlations
@all = []
- @enabled = []
@config = {}
class << self
attr_accessor :all
- attr_accessor :enabled
attr_accessor :config
end
def self.inherited(subclass)
all << subclass
end
- def self.enabled
- all.select(&:enabled?)
- end
-
- def self.enabled?
- true
- end
-
def initialize
@offences = []
end
def has_report?
!@offences.empty?
end
- def add_offence(file, line_number, message)
- @offences << Offence.new(file, line_number, message)
+ def add_offence(severity, line_number, message)
+ @offences << Offence.new(severity, line_number, message)
end
private
def each_parent_of(sym, sexp)
@@ -93,9 +83,14 @@
end
end
def whitespace?(token)
[:on_sp, :on_ignored_nl, :on_nl].include?(token.type)
+ end
+
+ def all_positions(sexp)
+ return [sexp[2]] if sexp[0] =~ /^@/
+ sexp.grep(Array).inject([]) { |memo, s| memo + all_positions(s) }
end
end
end
end