Skip to content

Commit

Permalink
Improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
dukaev committed Mar 8, 2020
1 parent 8bbbe08 commit fd1ff9e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/fasterer/file_traverser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def initialize(path)
@parse_error_paths = []
@config = Config.new
@offenses_total_count = 0
@explanation = {}
end

def traverse
Expand Down Expand Up @@ -84,9 +85,7 @@ def output(analyzer)
offenses_grouped_by_type(analyzer).each do |error_group_name, error_occurences|
error_occurences.map(&:line_number).each do |line|
file_and_line = "#{analyzer.file_path}:#{line}"
message = Fasterer::Explanation.new(error_group_name).call

print "#{file_and_line.colorize(:red)} #{message}\n"
print "#{file_and_line.colorize(:red)} #{explanation(error_group_name)}\n"
end
end

Expand Down Expand Up @@ -129,6 +128,10 @@ def ignored_files
def nil_config_file
config.nil_file
end

def explanation(offense_name)
@explanations[offense_name] ||= Fasterer::Explanation.new(offense_name).call
end
end

ErrorData = Struct.new(:file_path, :error_class, :error_message) do
Expand Down

0 comments on commit fd1ff9e

Please sign in to comment.