lib/fasterer/file_traverser.rb in fasterer-0.1.12 vs lib/fasterer/file_traverser.rb in fasterer-0.2.0

- old
+ new

@@ -9,10 +9,11 @@ CONFIG_FILE_NAME = Config::FILE_NAME SPEEDUPS_KEY = Config::SPEEDUPS_KEY EXCLUDE_PATHS_KEY = Config::EXCLUDE_PATHS_KEY attr_reader :config + attr_reader :parse_error_paths def initialize(path) @path = Pathname(path) @parse_error_paths = [] @config = Config.new @@ -35,18 +36,17 @@ !!offenses_found end private - attr_reader :parse_error_paths attr_accessor :offenses_found def scan_file(path) analyzer = Analyzer.new(path) analyzer.scan - rescue RubyParser::SyntaxError, Racc::ParseError, Timeout::Error - parse_error_paths.push(path) + rescue RubyParser::SyntaxError, Racc::ParseError, Timeout::Error => e + parse_error_paths.push(ErrorData.new(path, e.class, e.message).to_s) else if offenses_grouped_by_type(analyzer).any? output(analyzer) self.offenses_found = true end @@ -83,11 +83,10 @@ puts 'Fasterer was unable to process some files because the' puts 'internal parser is not able to read some characters or' puts 'has timed out. Unprocessable files were:' puts '-----------------------------------------------------' puts parse_error_paths - puts end def ignored_speedups config.ignored_speedups end @@ -96,8 +95,14 @@ config.ignored_files end def nil_config_file config.nil_file + end + end + + ErrorData = Struct.new(:file_path, :error_class, :error_message) do + def to_s + "#{file_path} - #{error_class} - #{error_message}" end end end