class Fasterer::Github::Scanner
Constants
- CONFIG_FILE_NAME
- EXCLUDE_PATHS_KEY
- SPEEDUPS_KEY
Attributes
owner[R]
path[R]
repo[R]
Public Class Methods
new(owner, repo, path)
click to toggle source
# File lib/fasterer/github/scanner.rb, line 13 def initialize(owner, repo, path) @owner = owner @repo = repo @path = path end
Public Instance Methods
results()
click to toggle source
# File lib/fasterer/github/scanner.rb, line 24 def results output_composer.result end
run()
click to toggle source
# File lib/fasterer/github/scanner.rb, line 19 def run data = traverse_and_collect_data data.each { |d| analyze_code(d) } end
Private Instance Methods
analyze_code(data)
click to toggle source
# File lib/fasterer/github/scanner.rb, line 46 def analyze_code(data) analyzer = Fasterer::Github::AnalyzerExtension.new(data[:content64]) analyzer.scan rescue RubyParser::SyntaxError, Racc::ParseError, Timeout::Error, RuntimeError output_composer.add_errors(data[:path]) else output_composer.add_offences(analyzer.offences, data[:path]) end
empty_config_hash()
click to toggle source
# File lib/fasterer/github/scanner.rb, line 76 def empty_config_hash { SPEEDUPS_KEY => {}, EXCLUDE_PATHS_KEY => [] } end
ignored_offences()
click to toggle source
# File lib/fasterer/github/scanner.rb, line 55 def ignored_offences loaded_config_file[SPEEDUPS_KEY].select { |_, v| v == false }.keys.map(&:to_sym) end
ignored_paths()
click to toggle source
# File lib/fasterer/github/scanner.rb, line 59 def ignored_paths loaded_config_file[EXCLUDE_PATHS_KEY] end
load_config_file()
click to toggle source
# File lib/fasterer/github/scanner.rb, line 67 def load_config_file path_to_config = File.join(Dir.pwd, CONFIG_FILE_NAME) if File.exist?(path_to_config) empty_config_hash.merge!(YAML.load_file(path_to_config)) else empty_config_hash end end
loaded_config_file()
click to toggle source
# File lib/fasterer/github/scanner.rb, line 63 def loaded_config_file @loaded_config_file ||= load_config_file end
output_composer()
click to toggle source
# File lib/fasterer/github/scanner.rb, line 36 def output_composer @output_composer ||= Fasterer::Github::OutputComposer.new(owner, repo, ignored_offences) end
traverse_and_collect_data()
click to toggle source
# File lib/fasterer/github/scanner.rb, line 40 def traverse_and_collect_data traverser.traverse output_composer.add_api_errors(traverser.api_errors) if traverser.api_errors.any? traverser.collected_data end
traverser()
click to toggle source
# File lib/fasterer/github/scanner.rb, line 32 def traverser @traverser ||= Fasterer::Github::GhTraverser.new(owner, repo, path, ignored_paths) end