Class: Pluginscan::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/pluginscan/reports/issues_report/issue_checks/check.rb

Overview

Responsible for checking a string against set of rexgexps and returning all matches

Direct Known Subclasses

FunctionCheck, VariableCheck

Defined Under Namespace

Classes: IgnoreThing

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(check_hash) ⇒ Check

Returns a new instance of Check.



6
7
8
9
10
11
12
13
# File 'lib/pluginscan/reports/issues_report/issue_checks/check.rb', line 6

def initialize(check_hash)
  @name     = check_hash[:name]
  @message  = check_hash[:message]
  @patterns = Array(check_hash[:patterns])
  @ignores  = Array(check_hash[:ignores]).map do |ignore_thing|
    IgnoreThing.new(ignore_thing)
  end
end

Instance Attribute Details

#ignoresObject (readonly)

Returns the value of attribute ignores.



4
5
6
# File 'lib/pluginscan/reports/issues_report/issue_checks/check.rb', line 4

def ignores
  @ignores
end

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/pluginscan/reports/issues_report/issue_checks/check.rb', line 4

def message
  @message
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/pluginscan/reports/issues_report/issue_checks/check.rb', line 4

def name
  @name
end

#patternsObject (readonly)

Returns the value of attribute patterns.



4
5
6
# File 'lib/pluginscan/reports/issues_report/issue_checks/check.rb', line 4

def patterns
  @patterns
end

Instance Method Details

#ignore?(_match, content) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
# File 'lib/pluginscan/reports/issues_report/issue_checks/check.rb', line 19

def ignore?(_match, content)
  # `match` is not used in the default case, but is included
  # so that classes inheriting from this one can use it when deciding
  # whether or not to ignore content by overriding this function
  ignores.any? { |ignore_thing| ignore_thing.ignore?(content) }
end

#run(content) ⇒ Object



15
16
17
# File 'lib/pluginscan/reports/issues_report/issue_checks/check.rb', line 15

def run(content)
  pattern_matches(content).map{ |matchdata| match(matchdata) }
end