Skip to content

Commit

Permalink
[Fix #12310] Drop base64 gem from runtime dependency
Browse files Browse the repository at this point in the history
Fixes #12310.

This PR drops `base64` gem from runtime dependency.

RuboCop only uses `Base64.encode64` from the `base64` gem. Therefore, there's no need to depend on
the entire `base64` gem. The implementation of `Base64.encode64` is quite simple:
https://github.com/ruby/base64/blob/v0.1.1/lib/base64.rb#L27-L40

This change is a better approach that has also been adopted by rack/rack#2110.
  • Loading branch information
koic authored and bbatsov committed Oct 26, 2023
1 parent 36f62b6 commit b2b29da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/fix_drop_base64_gem_from_runtime_dependency.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#12310](https://github.com/rubocop/rubocop/issues/12310): Drop `base64` gem from runtime dependency. ([@koic][])
6 changes: 4 additions & 2 deletions lib/rubocop/formatter/html_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'base64'
require 'cgi'
require 'erb'
require 'ostruct'
Expand Down Expand Up @@ -124,7 +123,10 @@ def escape(string)

def base64_encoded_logo_image
image = File.read(LOGO_IMAGE_PATH, binmode: true)
Base64.encode64(image)

# `Base64.encode64` compatible:
# https://github.com/ruby/base64/blob/v0.1.1/lib/base64.rb#L27-L40
[image].pack('m')
end
end
end
Expand Down
1 change: 0 additions & 1 deletion rubocop.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Gem::Specification.new do |s|
'rubygems_mfa_required' => 'true'
}

s.add_runtime_dependency('base64', '~> 0.1.1')
s.add_runtime_dependency('json', '~> 2.3')
s.add_runtime_dependency('language_server-protocol', '>= 3.17.0')
s.add_runtime_dependency('parallel', '~> 1.10')
Expand Down

0 comments on commit b2b29da

Please sign in to comment.