Class: AxR::Scanner
- Inherits:
-
Object
- Object
- AxR::Scanner
- Defined in:
- lib/axr/scanner.rb,
lib/axr/scanner/warning.rb,
lib/axr/scanner/detection.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#dependecies ⇒ Object
readonly
Returns the value of attribute dependecies.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#initialize(source: []) ⇒ Scanner
constructor
A new instance of Scanner.
-
#scan ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity.
Constructor Details
#initialize(source: []) ⇒ Scanner
Returns a new instance of Scanner.
10 11 12 13 14 15 |
# File 'lib/axr/scanner.rb', line 10 def initialize(source: []) @source = source @dependecies = [] @warnings = [] @context = nil end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
8 9 10 |
# File 'lib/axr/scanner.rb', line 8 def context @context end |
#dependecies ⇒ Object (readonly)
Returns the value of attribute dependecies.
8 9 10 |
# File 'lib/axr/scanner.rb', line 8 def dependecies @dependecies end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
8 9 10 |
# File 'lib/axr/scanner.rb', line 8 def source @source end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
8 9 10 |
# File 'lib/axr/scanner.rb', line 8 def warnings @warnings end |
Instance Method Details
#scan ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/axr/scanner.rb', line 20 def scan source.each.with_index do |line, index| loc_num = index + 1 line_detection = AxR.app.layer_names.detect { |layer| line.include?(layer) } line_detection = check_space_before(line, line_detection) line_detection = nil if context && module_definition?(line, line_detection) line_detection = nil if commented?(line, line_detection) context_detection = AxR.app.layer_names.detect { |layer| module_definition?(line, layer) } next unless context_detection || line_detection detect_context(context_detection, line, loc_num) if context_detection && !context detect_dependency(line_detection, line, loc_num) detect_warning(line_detection, line, loc_num) if context && line_detection end self end |