diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b3abd34480..bf0418fdc84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ * [#8642](https://github.com/rubocop-hq/rubocop/issues/8642): Fix a false negative for `Style/SpaceInsideHashLiteralBraces` when a correct empty hash precedes the incorrect hash. ([@dvandersluis][]) * [#8683](https://github.com/rubocop-hq/rubocop/issues/8683): Make naming cops work with non-ascii characters. ([@tejasbubane][]) * [#8626](https://github.com/rubocop-hq/rubocop/issues/8626): Fix false negatives for `Lint/UselessMethodDefinition`. ([@marcandre][]) +* [#8698](https://github.com/rubocop-hq/rubocop/pull/8698): Fix cache to avoid encoding exception. ([@marcandre][]) ### Changes diff --git a/lib/rubocop/result_cache.rb b/lib/rubocop/result_cache.rb index 1f85d9b59cd..643906996df 100644 --- a/lib/rubocop/result_cache.rb +++ b/lib/rubocop/result_cache.rb @@ -176,7 +176,10 @@ def rubocop_checksum rubocop_extra_features .select { |path| File.file?(path) } .sort! - .each { |path| digest << Zlib.crc32(IO.read(path)).to_s } # mtime not reliable + .each do |path| + content = File.open(path, 'rb', &:read) + digest << Zlib.crc32(content).to_s # mtime not reliable + end digest << RuboCop::Version::STRING << RuboCop::AST::Version::STRING digest.hexdigest end