From 8315dc52ad352b570080b8f152d047e6dcdb9180 Mon Sep 17 00:00:00 2001 From: Josh Nichols Date: Fri, 16 Jun 2023 13:29:16 -0400 Subject: [PATCH 1/2] Use 'rubocop -A --only Style/FrozenStringLiteralComment,Layout/EmptyLineAfterMagicComment' to add frozen string literals --- lib/webmock.rb | 2 ++ lib/webmock/api.rb | 2 ++ lib/webmock/assertion_failure.rb | 2 ++ lib/webmock/callback_registry.rb | 2 ++ lib/webmock/config.rb | 2 ++ lib/webmock/cucumber.rb | 2 ++ lib/webmock/deprecation.rb | 2 ++ lib/webmock/errors.rb | 2 ++ lib/webmock/http_lib_adapters/async_http_client_adapter.rb | 2 ++ lib/webmock/http_lib_adapters/curb_adapter.rb | 2 ++ lib/webmock/http_lib_adapters/em_http_request_adapter.rb | 2 ++ lib/webmock/http_lib_adapters/excon_adapter.rb | 2 ++ lib/webmock/http_lib_adapters/http_lib_adapter.rb | 2 ++ lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb | 2 ++ lib/webmock/http_lib_adapters/http_rb/client.rb | 2 ++ lib/webmock/http_lib_adapters/http_rb/request.rb | 2 ++ lib/webmock/http_lib_adapters/http_rb/response.rb | 2 ++ lib/webmock/http_lib_adapters/http_rb/streamer.rb | 2 ++ lib/webmock/http_lib_adapters/http_rb/webmock.rb | 2 ++ lib/webmock/http_lib_adapters/http_rb_adapter.rb | 2 ++ lib/webmock/http_lib_adapters/httpclient_adapter.rb | 2 ++ lib/webmock/http_lib_adapters/manticore_adapter.rb | 2 ++ lib/webmock/http_lib_adapters/net_http.rb | 2 ++ lib/webmock/http_lib_adapters/net_http_response.rb | 2 ++ lib/webmock/http_lib_adapters/patron_adapter.rb | 2 ++ lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb | 2 ++ lib/webmock/matchers/any_arg_matcher.rb | 2 ++ lib/webmock/matchers/hash_argument_matcher.rb | 2 ++ lib/webmock/matchers/hash_excluding_matcher.rb | 2 ++ lib/webmock/matchers/hash_including_matcher.rb | 2 ++ lib/webmock/minitest.rb | 2 ++ lib/webmock/rack_response.rb | 2 ++ lib/webmock/request_body_diff.rb | 2 ++ lib/webmock/request_execution_verifier.rb | 2 ++ lib/webmock/request_pattern.rb | 2 ++ lib/webmock/request_registry.rb | 2 ++ lib/webmock/request_signature.rb | 2 ++ lib/webmock/request_signature_snippet.rb | 2 ++ lib/webmock/request_stub.rb | 2 ++ lib/webmock/response.rb | 2 ++ lib/webmock/responses_sequence.rb | 2 ++ lib/webmock/rspec.rb | 2 ++ lib/webmock/rspec/matchers.rb | 2 ++ lib/webmock/rspec/matchers/request_pattern_matcher.rb | 2 ++ lib/webmock/rspec/matchers/webmock_matcher.rb | 2 ++ lib/webmock/stub_registry.rb | 2 ++ lib/webmock/stub_request_snippet.rb | 2 ++ lib/webmock/test_unit.rb | 2 ++ lib/webmock/util/hash_counter.rb | 2 ++ lib/webmock/util/hash_keys_stringifier.rb | 2 ++ lib/webmock/util/hash_validator.rb | 2 ++ lib/webmock/util/headers.rb | 2 ++ lib/webmock/util/json.rb | 2 ++ lib/webmock/util/query_mapper.rb | 2 ++ lib/webmock/util/uri.rb | 2 ++ lib/webmock/util/values_stringifier.rb | 2 ++ lib/webmock/util/version_checker.rb | 2 ++ lib/webmock/version.rb | 2 ++ lib/webmock/webmock.rb | 2 ++ 59 files changed, 118 insertions(+) diff --git a/lib/webmock.rb b/lib/webmock.rb index d69d09bd5..d9ffdc050 100644 --- a/lib/webmock.rb +++ b/lib/webmock.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'singleton' require 'addressable/uri' diff --git a/lib/webmock/api.rb b/lib/webmock/api.rb index 86277f511..4110c095d 100644 --- a/lib/webmock/api.rb +++ b/lib/webmock/api.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock module API extend self diff --git a/lib/webmock/assertion_failure.rb b/lib/webmock/assertion_failure.rb index 86397c5e9..e2af6c94e 100644 --- a/lib/webmock/assertion_failure.rb +++ b/lib/webmock/assertion_failure.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class AssertionFailure @error_class = RuntimeError diff --git a/lib/webmock/callback_registry.rb b/lib/webmock/callback_registry.rb index 90ac653db..5b9c126a5 100644 --- a/lib/webmock/callback_registry.rb +++ b/lib/webmock/callback_registry.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class CallbackRegistry @@callbacks = [] diff --git a/lib/webmock/config.rb b/lib/webmock/config.rb index 88e051e43..965546ce8 100644 --- a/lib/webmock/config.rb +++ b/lib/webmock/config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class Config include Singleton diff --git a/lib/webmock/cucumber.rb b/lib/webmock/cucumber.rb index a655f39b1..73ec9c8f9 100644 --- a/lib/webmock/cucumber.rb +++ b/lib/webmock/cucumber.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'webmock' require 'webmock/rspec/matchers' diff --git a/lib/webmock/deprecation.rb b/lib/webmock/deprecation.rb index cd3b793cc..2b1ebaeaf 100644 --- a/lib/webmock/deprecation.rb +++ b/lib/webmock/deprecation.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class Deprecation class << self diff --git a/lib/webmock/errors.rb b/lib/webmock/errors.rb index 593e3acea..36b095a26 100644 --- a/lib/webmock/errors.rb +++ b/lib/webmock/errors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class NetConnectNotAllowedError < Exception diff --git a/lib/webmock/http_lib_adapters/async_http_client_adapter.rb b/lib/webmock/http_lib_adapters/async_http_client_adapter.rb index 10828a531..db30ab938 100644 --- a/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +++ b/lib/webmock/http_lib_adapters/async_http_client_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'async' require 'async/http' diff --git a/lib/webmock/http_lib_adapters/curb_adapter.rb b/lib/webmock/http_lib_adapters/curb_adapter.rb index 1d7575609..8da5c9768 100644 --- a/lib/webmock/http_lib_adapters/curb_adapter.rb +++ b/lib/webmock/http_lib_adapters/curb_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'curb' rescue LoadError diff --git a/lib/webmock/http_lib_adapters/em_http_request_adapter.rb b/lib/webmock/http_lib_adapters/em_http_request_adapter.rb index fc410e09f..0362526b3 100644 --- a/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +++ b/lib/webmock/http_lib_adapters/em_http_request_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'em-http-request' rescue LoadError diff --git a/lib/webmock/http_lib_adapters/excon_adapter.rb b/lib/webmock/http_lib_adapters/excon_adapter.rb index ad6840938..82734c7c9 100644 --- a/lib/webmock/http_lib_adapters/excon_adapter.rb +++ b/lib/webmock/http_lib_adapters/excon_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'excon' rescue LoadError diff --git a/lib/webmock/http_lib_adapters/http_lib_adapter.rb b/lib/webmock/http_lib_adapters/http_lib_adapter.rb index 2f91229e4..cc85b8463 100644 --- a/lib/webmock/http_lib_adapters/http_lib_adapter.rb +++ b/lib/webmock/http_lib_adapters/http_lib_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class HttpLibAdapter def self.adapter_for(lib) diff --git a/lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb b/lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb index 4f88a70fa..eba352fb9 100644 --- a/lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb +++ b/lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class HttpLibAdapterRegistry include Singleton diff --git a/lib/webmock/http_lib_adapters/http_rb/client.rb b/lib/webmock/http_lib_adapters/http_rb/client.rb index 2ef024611..ffa940479 100644 --- a/lib/webmock/http_lib_adapters/http_rb/client.rb +++ b/lib/webmock/http_lib_adapters/http_rb/client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module HTTP class Client alias_method :__perform__, :perform diff --git a/lib/webmock/http_lib_adapters/http_rb/request.rb b/lib/webmock/http_lib_adapters/http_rb/request.rb index b6f5e2254..d8fc1bda8 100644 --- a/lib/webmock/http_lib_adapters/http_rb/request.rb +++ b/lib/webmock/http_lib_adapters/http_rb/request.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module HTTP class Request def webmock_signature diff --git a/lib/webmock/http_lib_adapters/http_rb/response.rb b/lib/webmock/http_lib_adapters/http_rb/response.rb index 9e962c24b..91661eb5b 100644 --- a/lib/webmock/http_lib_adapters/http_rb/response.rb +++ b/lib/webmock/http_lib_adapters/http_rb/response.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module HTTP class Response def to_webmock diff --git a/lib/webmock/http_lib_adapters/http_rb/streamer.rb b/lib/webmock/http_lib_adapters/http_rb/streamer.rb index 6f218e8bc..3a70c443e 100644 --- a/lib/webmock/http_lib_adapters/http_rb/streamer.rb +++ b/lib/webmock/http_lib_adapters/http_rb/streamer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module HTTP class Response class Streamer diff --git a/lib/webmock/http_lib_adapters/http_rb/webmock.rb b/lib/webmock/http_lib_adapters/http_rb/webmock.rb index 096e3a75c..56207f90e 100644 --- a/lib/webmock/http_lib_adapters/http_rb/webmock.rb +++ b/lib/webmock/http_lib_adapters/http_rb/webmock.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module HTTP class WebMockPerform def initialize(request, options, &perform) diff --git a/lib/webmock/http_lib_adapters/http_rb_adapter.rb b/lib/webmock/http_lib_adapters/http_rb_adapter.rb index 1229f7d8d..ec3b4258b 100644 --- a/lib/webmock/http_lib_adapters/http_rb_adapter.rb +++ b/lib/webmock/http_lib_adapters/http_rb_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require "http" rescue LoadError diff --git a/lib/webmock/http_lib_adapters/httpclient_adapter.rb b/lib/webmock/http_lib_adapters/httpclient_adapter.rb index bacbf5dad..4286831f9 100644 --- a/lib/webmock/http_lib_adapters/httpclient_adapter.rb +++ b/lib/webmock/http_lib_adapters/httpclient_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'httpclient' require 'jsonclient' # defined in 'httpclient' gem as well diff --git a/lib/webmock/http_lib_adapters/manticore_adapter.rb b/lib/webmock/http_lib_adapters/manticore_adapter.rb index 6a2750aea..bfedcbb96 100644 --- a/lib/webmock/http_lib_adapters/manticore_adapter.rb +++ b/lib/webmock/http_lib_adapters/manticore_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'manticore' rescue LoadError diff --git a/lib/webmock/http_lib_adapters/net_http.rb b/lib/webmock/http_lib_adapters/net_http.rb index 7b66de8d2..023596677 100644 --- a/lib/webmock/http_lib_adapters/net_http.rb +++ b/lib/webmock/http_lib_adapters/net_http.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'net/http' require 'net/https' require 'stringio' diff --git a/lib/webmock/http_lib_adapters/net_http_response.rb b/lib/webmock/http_lib_adapters/net_http_response.rb index 6898d322b..c9139a7a3 100644 --- a/lib/webmock/http_lib_adapters/net_http_response.rb +++ b/lib/webmock/http_lib_adapters/net_http_response.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This code is entierly copied from VCR (http://github.com/myronmarston/vcr) by courtesy of Myron Marston # A Net::HTTP response that has already been read raises an IOError when #read_body diff --git a/lib/webmock/http_lib_adapters/patron_adapter.rb b/lib/webmock/http_lib_adapters/patron_adapter.rb index bb406dbc0..e5e227fb8 100644 --- a/lib/webmock/http_lib_adapters/patron_adapter.rb +++ b/lib/webmock/http_lib_adapters/patron_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'patron' rescue LoadError diff --git a/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb b/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb index 9c9b5ca72..352a762d5 100644 --- a/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +++ b/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'typhoeus' rescue LoadError diff --git a/lib/webmock/matchers/any_arg_matcher.rb b/lib/webmock/matchers/any_arg_matcher.rb index e38ff413e..db015235f 100644 --- a/lib/webmock/matchers/any_arg_matcher.rb +++ b/lib/webmock/matchers/any_arg_matcher.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock module Matchers # this is a based on RSpec::Mocks::ArgumentMatchers::AnyArgMatcher diff --git a/lib/webmock/matchers/hash_argument_matcher.rb b/lib/webmock/matchers/hash_argument_matcher.rb index 3456457bd..b2dc22ceb 100644 --- a/lib/webmock/matchers/hash_argument_matcher.rb +++ b/lib/webmock/matchers/hash_argument_matcher.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock module Matchers # Base class for Hash matchers diff --git a/lib/webmock/matchers/hash_excluding_matcher.rb b/lib/webmock/matchers/hash_excluding_matcher.rb index 877d84f98..f5028cc8d 100644 --- a/lib/webmock/matchers/hash_excluding_matcher.rb +++ b/lib/webmock/matchers/hash_excluding_matcher.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock module Matchers # this is a based on RSpec::Mocks::ArgumentMatchers::HashExcludingMatcher diff --git a/lib/webmock/matchers/hash_including_matcher.rb b/lib/webmock/matchers/hash_including_matcher.rb index 5adb593d8..09daad6f6 100644 --- a/lib/webmock/matchers/hash_including_matcher.rb +++ b/lib/webmock/matchers/hash_including_matcher.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock module Matchers # this is a based on RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher diff --git a/lib/webmock/minitest.rb b/lib/webmock/minitest.rb index 9a2cde259..7722bea33 100644 --- a/lib/webmock/minitest.rb +++ b/lib/webmock/minitest.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'minitest/test' test_class = Minitest::Test diff --git a/lib/webmock/rack_response.rb b/lib/webmock/rack_response.rb index aa80e5dd2..1122154a6 100644 --- a/lib/webmock/rack_response.rb +++ b/lib/webmock/rack_response.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class RackResponse < Response def initialize(app) diff --git a/lib/webmock/request_body_diff.rb b/lib/webmock/request_body_diff.rb index 40c98a9cb..3932f62eb 100644 --- a/lib/webmock/request_body_diff.rb +++ b/lib/webmock/request_body_diff.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "hashdiff" require "json" diff --git a/lib/webmock/request_execution_verifier.rb b/lib/webmock/request_execution_verifier.rb index d0fbfc6ea..97b4872ee 100644 --- a/lib/webmock/request_execution_verifier.rb +++ b/lib/webmock/request_execution_verifier.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class RequestExecutionVerifier diff --git a/lib/webmock/request_pattern.rb b/lib/webmock/request_pattern.rb index 8fb84e832..abc980cd1 100644 --- a/lib/webmock/request_pattern.rb +++ b/lib/webmock/request_pattern.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock module RSpecMatcherDetector diff --git a/lib/webmock/request_registry.rb b/lib/webmock/request_registry.rb index 187ce579f..e4618d3ea 100644 --- a/lib/webmock/request_registry.rb +++ b/lib/webmock/request_registry.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class RequestRegistry diff --git a/lib/webmock/request_signature.rb b/lib/webmock/request_signature.rb index 949b874a0..27e62e97f 100644 --- a/lib/webmock/request_signature.rb +++ b/lib/webmock/request_signature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class RequestSignature diff --git a/lib/webmock/request_signature_snippet.rb b/lib/webmock/request_signature_snippet.rb index 4f8bdfbc0..535578011 100644 --- a/lib/webmock/request_signature_snippet.rb +++ b/lib/webmock/request_signature_snippet.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "pp" module WebMock diff --git a/lib/webmock/request_stub.rb b/lib/webmock/request_stub.rb index 8c831c5cd..9ae4987ff 100644 --- a/lib/webmock/request_stub.rb +++ b/lib/webmock/request_stub.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class RequestStub diff --git a/lib/webmock/response.rb b/lib/webmock/response.rb index 791952d45..e09eb6080 100644 --- a/lib/webmock/response.rb +++ b/lib/webmock/response.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "pathname" module WebMock diff --git a/lib/webmock/responses_sequence.rb b/lib/webmock/responses_sequence.rb index 7c5f13394..a49fbe820 100644 --- a/lib/webmock/responses_sequence.rb +++ b/lib/webmock/responses_sequence.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class ResponsesSequence diff --git a/lib/webmock/rspec.rb b/lib/webmock/rspec.rb index 6ec8cd56c..fc5d327e8 100644 --- a/lib/webmock/rspec.rb +++ b/lib/webmock/rspec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'webmock' # RSpec 1.x and 2.x compatibility diff --git a/lib/webmock/rspec/matchers.rb b/lib/webmock/rspec/matchers.rb index 74a2c5505..e069405a8 100644 --- a/lib/webmock/rspec/matchers.rb +++ b/lib/webmock/rspec/matchers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'webmock' require 'webmock/rspec/matchers/request_pattern_matcher' require 'webmock/rspec/matchers/webmock_matcher' diff --git a/lib/webmock/rspec/matchers/request_pattern_matcher.rb b/lib/webmock/rspec/matchers/request_pattern_matcher.rb index a282bc522..9d0fd3946 100644 --- a/lib/webmock/rspec/matchers/request_pattern_matcher.rb +++ b/lib/webmock/rspec/matchers/request_pattern_matcher.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class RequestPatternMatcher diff --git a/lib/webmock/rspec/matchers/webmock_matcher.rb b/lib/webmock/rspec/matchers/webmock_matcher.rb index 706cc5aeb..5a57885e8 100644 --- a/lib/webmock/rspec/matchers/webmock_matcher.rb +++ b/lib/webmock/rspec/matchers/webmock_matcher.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class WebMockMatcher diff --git a/lib/webmock/stub_registry.rb b/lib/webmock/stub_registry.rb index 35e7822fb..56a0db6d0 100644 --- a/lib/webmock/stub_registry.rb +++ b/lib/webmock/stub_registry.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class StubRegistry diff --git a/lib/webmock/stub_request_snippet.rb b/lib/webmock/stub_request_snippet.rb index 6ab08f866..87485f6e0 100644 --- a/lib/webmock/stub_request_snippet.rb +++ b/lib/webmock/stub_request_snippet.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class StubRequestSnippet def initialize(request_stub) diff --git a/lib/webmock/test_unit.rb b/lib/webmock/test_unit.rb index 781d7dc6a..eb6556b33 100644 --- a/lib/webmock/test_unit.rb +++ b/lib/webmock/test_unit.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'test/unit' require 'webmock' diff --git a/lib/webmock/util/hash_counter.rb b/lib/webmock/util/hash_counter.rb index 77f48db34..ce7c059cf 100644 --- a/lib/webmock/util/hash_counter.rb +++ b/lib/webmock/util/hash_counter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'thread' module WebMock diff --git a/lib/webmock/util/hash_keys_stringifier.rb b/lib/webmock/util/hash_keys_stringifier.rb index 1f2635a95..4ab4c80c4 100644 --- a/lib/webmock/util/hash_keys_stringifier.rb +++ b/lib/webmock/util/hash_keys_stringifier.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock module Util class HashKeysStringifier diff --git a/lib/webmock/util/hash_validator.rb b/lib/webmock/util/hash_validator.rb index 0fc93715e..45087d7bc 100644 --- a/lib/webmock/util/hash_validator.rb +++ b/lib/webmock/util/hash_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock class HashValidator def initialize(hash) diff --git a/lib/webmock/util/headers.rb b/lib/webmock/util/headers.rb index c803ff9e0..cd1dd0c3f 100644 --- a/lib/webmock/util/headers.rb +++ b/lib/webmock/util/headers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'base64' module WebMock diff --git a/lib/webmock/util/json.rb b/lib/webmock/util/json.rb index a0309036e..0ad3d0acb 100644 --- a/lib/webmock/util/json.rb +++ b/lib/webmock/util/json.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This is a copy of https://github.com/jnunemaker/crack/blob/master/lib/crack/json.rb # with date parsing removed # Copyright (c) 2004-2008 David Heinemeier Hansson diff --git a/lib/webmock/util/query_mapper.rb b/lib/webmock/util/query_mapper.rb index 50031ae42..c36684082 100644 --- a/lib/webmock/util/query_mapper.rb +++ b/lib/webmock/util/query_mapper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock::Util class QueryMapper class << self diff --git a/lib/webmock/util/uri.rb b/lib/webmock/util/uri.rb index c5274f109..7e060955e 100644 --- a/lib/webmock/util/uri.rb +++ b/lib/webmock/util/uri.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock module Util diff --git a/lib/webmock/util/values_stringifier.rb b/lib/webmock/util/values_stringifier.rb index 4562a4a87..54959dc4f 100644 --- a/lib/webmock/util/values_stringifier.rb +++ b/lib/webmock/util/values_stringifier.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class WebMock::Util::ValuesStringifier def self.stringify_values(value) case value diff --git a/lib/webmock/util/version_checker.rb b/lib/webmock/util/version_checker.rb index d9830b1a2..b2c91d040 100644 --- a/lib/webmock/util/version_checker.rb +++ b/lib/webmock/util/version_checker.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This code was created based on https://github.com/myronmarston/vcr/blob/master/lib/vcr/util/version_checker.rb # Thanks to @myronmarston diff --git a/lib/webmock/version.rb b/lib/webmock/version.rb index 03fefa8d0..cb735ef21 100644 --- a/lib/webmock/version.rb +++ b/lib/webmock/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock VERSION = '3.18.1' unless defined?(::WebMock::VERSION) end diff --git a/lib/webmock/webmock.rb b/lib/webmock/webmock.rb index a6a9e610c..24555a154 100644 --- a/lib/webmock/webmock.rb +++ b/lib/webmock/webmock.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module WebMock def self.included(clazz) From d028c494026b441559f1805ecfdb0629559d51e5 Mon Sep 17 00:00:00 2001 From: Josh Nichols Date: Fri, 16 Jun 2023 13:57:36 -0400 Subject: [PATCH 2/2] Use frozen string literals --- lib/webmock/http_lib_adapters/http_rb/request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/webmock/http_lib_adapters/http_rb/request.rb b/lib/webmock/http_lib_adapters/http_rb/request.rb index d8fc1bda8..078be3181 100644 --- a/lib/webmock/http_lib_adapters/http_rb/request.rb +++ b/lib/webmock/http_lib_adapters/http_rb/request.rb @@ -4,7 +4,7 @@ module HTTP class Request def webmock_signature request_body = if defined?(HTTP::Request::Body) - ''.tap { |string| body.each { |part| string << part } } + String.new.tap { |string| body.each { |part| string << part } } else body end