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.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#initialize(file_path:) ⇒ Scanner
constructor
A new instance of Scanner.
-
#scan ⇒ Object
rubocop:disable Metrics/AbcSize.
Constructor Details
#initialize(file_path:) ⇒ Scanner
Returns a new instance of Scanner.
10 11 12 13 14 15 |
# File 'lib/axr/scanner.rb', line 10 def initialize(file_path:) @file_path = file_path @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 |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
8 9 10 |
# File 'lib/axr/scanner.rb', line 8 def file_path @file_path 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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/axr/scanner.rb', line 18 def scan File.open(file_path).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) context_detection = AxR.app.layer_names.detect { |layer| line.include?("module #{layer}") } next unless line_detection || context_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 end self end |