Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #12310] Drop base64 gem from runtime dependency #12313

Merged

Conversation

koic
Copy link
Member

@koic koic commented Oct 25, 2023

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.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

Fixes rubocop#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.
@koic koic force-pushed the drop_base64_gem_from_runtime_dependency branch from b540650 to 7399b2e Compare October 25, 2023 17:12
@bbatsov bbatsov merged commit b2b29da into rubocop:master Oct 26, 2023
10 checks passed
@bbatsov
Copy link
Collaborator

bbatsov commented Oct 26, 2023

Great change!

@koic koic deleted the drop_base64_gem_from_runtime_dependency branch October 26, 2023 06:28
koic added a commit to koic/rubocop that referenced this pull request Oct 26, 2023
Follow up rubocop#12313.

`base64` is not needed at runtime, but it was required as a test dependency.
So, this PR suppresses the following warning when using Ruby 3.3.0dev:

```consle
$ ruby -v
ruby 3.3.0dev (2023-10-23T08:04:27Z master e6fcf07a6f) [x86_64-darwin22]

$ cd path/to/rubocop
$ bundle exec rspec
/Users/koic/.rbenv/versions/3.3.0-dev/lib/ruby/gems/3.3.0+0/gems/webmock-3.19.1/lib/webmock/util/headers.rb:3:
warning: base64 which will no longer be part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile or gemspec.
```

https://app.circleci.com/pipelines/github/rubocop/rubocop/10108/workflows/20097132-bbe3-4fa4-ad7e-de7c30c86e69/jobs/291956?invite=true#step-104-0_163

The `base64` dependency can be removed from Gemfile when bblimke/webmock#1041 is merged and released.
It's a workaround until then.
bbatsov pushed a commit that referenced this pull request Oct 26, 2023
Follow up #12313.

`base64` is not needed at runtime, but it was required as a test dependency.
So, this PR suppresses the following warning when using Ruby 3.3.0dev:

```consle
$ ruby -v
ruby 3.3.0dev (2023-10-23T08:04:27Z master e6fcf07a6f) [x86_64-darwin22]

$ cd path/to/rubocop
$ bundle exec rspec
/Users/koic/.rbenv/versions/3.3.0-dev/lib/ruby/gems/3.3.0+0/gems/webmock-3.19.1/lib/webmock/util/headers.rb:3:
warning: base64 which will no longer be part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile or gemspec.
```

https://app.circleci.com/pipelines/github/rubocop/rubocop/10108/workflows/20097132-bbe3-4fa4-ad7e-de7c30c86e69/jobs/291956?invite=true#step-104-0_163

The `base64` dependency can be removed from Gemfile when bblimke/webmock#1041 is merged and released.
It's a workaround until then.
koic added a commit to koic/rubocop-ast that referenced this pull request Feb 25, 2024
This PR resolves the following CI error with RuboCop 1.35.0:

```console
  1) RuboCop Project requiring all of `lib` with verbose warnings enabled emits no warnings
     Failure/Error: expect(warnings).to eq []

       expected: []
            got: ["/home/runner/work/rubocop-ast/rubocop/lib/rubocop/formatter/html_formatter.rb:6:
warning: base64 wa...l no longer be part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile or gemspec.\n"]

       (compared using ==)

       Diff:
       @@ -1 +1,2 @@
       +/home/runner/work/rubocop-ast/rubocop/lib/rubocop/formatter/html_formatter.rb:6: warning:
base64 was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0.
Add base64 to your Gemfile or gemspec.\n

     # ./spec/project_spec.rb:284:in `block (3 levels) in <top (required)>'
```

https://github.com/rubocop/rubocop-ast/actions/runs/8033104014/job/21943241393

It updates RuboCop to 1.57.2, which was finally resolved by rubocop/rubocop#12313.
koic added a commit to rubocop/rubocop-ast that referenced this pull request Feb 25, 2024
This PR resolves the following CI error with RuboCop 1.35.0:

```console
  1) RuboCop Project requiring all of `lib` with verbose warnings enabled emits no warnings
     Failure/Error: expect(warnings).to eq []

       expected: []
            got: ["/home/runner/work/rubocop-ast/rubocop/lib/rubocop/formatter/html_formatter.rb:6:
warning: base64 wa...l no longer be part of the default gems since Ruby 3.4.0. Add base64 to your Gemfile or gemspec.\n"]

       (compared using ==)

       Diff:
       @@ -1 +1,2 @@
       +/home/runner/work/rubocop-ast/rubocop/lib/rubocop/formatter/html_formatter.rb:6: warning:
base64 was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0.
Add base64 to your Gemfile or gemspec.\n

     # ./spec/project_spec.rb:284:in `block (3 levels) in <top (required)>'
```

https://github.com/rubocop/rubocop-ast/actions/runs/8033104014/job/21943241393

It updates RuboCop to 1.57.2, which was finally resolved by rubocop/rubocop#12313.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bundler 1.17 issue
2 participants