Skip to content

Commit

Permalink
Cache classname_attribute_value in junit formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima authored and bbatsov committed Mar 6, 2023
1 parent 0499a58 commit f23e487
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rubocop/formatter/junit_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def add_testcase_element_to_testsuite_element(file, target_offenses, cop)
end

def classname_attribute_value(file)
file.gsub(/\.rb\Z/, '').gsub("#{Dir.pwd}/", '').tr('/', '.')
@classname_attribute_value_cache ||= Hash.new do |hash, key|
hash[key] = key.gsub(/\.rb\Z/, '').gsub("#{Dir.pwd}/", '').tr('/', '.')
end
@classname_attribute_value_cache[file]
end

def finished(_inspected_files)
Expand Down

0 comments on commit f23e487

Please sign in to comment.