fix: be explicit about frozen string literals to quash warnings

This commit is contained in:
Mike Dalessio 2024-03-24 09:15:25 -04:00
parent cffe3247ef
commit 22ea7af086
No known key found for this signature in database
GPG key ID: FCF96ED17542E12F
5 changed files with 11 additions and 7 deletions

View file

@ -1,4 +1,5 @@
# :markup: markdown
# frozen_string_literal: true
require 'http/cookie/version'
require 'http/cookie/uri_parser'
require 'time'
@ -425,7 +426,7 @@ class HTTP::Cookie
# Returns the domain, with a dot prefixed only if the domain flag is
# on.
def dot_domain
@for_domain ? '.' << @domain : @domain
@for_domain ? (+'.') << @domain : @domain
end
# Returns the domain attribute value as a DomainName object.
@ -595,7 +596,7 @@ class HTTP::Cookie
# Returns a string for use in the Cookie header, i.e. `name=value`
# or `name="value"`.
def cookie_value
"#{@name}=#{Scanner.quote(@value)}"
+"#{@name}=#{Scanner.quote(@value)}"
end
alias to_s cookie_value

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'http/cookie'
require 'strscan'
require 'time'
@ -23,7 +24,7 @@ class HTTP::Cookie::Scanner < StringScanner
class << self
def quote(s)
return s unless s.match(RE_BAD_CHAR)
'"' << s.gsub(/([\\"])/, "\\\\\\1") << '"'
(+'"') << s.gsub(/([\\"])/, "\\\\\\1") << '"'
end
end
@ -32,7 +33,7 @@ class HTTP::Cookie::Scanner < StringScanner
end
def scan_dquoted
''.tap { |s|
(+'').tap { |s|
case
when skip(/"/)
break
@ -51,7 +52,7 @@ class HTTP::Cookie::Scanner < StringScanner
end
def scan_value(comma_as_separator = false)
''.tap { |s|
(+'').tap { |s|
case
when scan(/[^,;"]+/)
s << matched

View file

@ -7,7 +7,7 @@ module Test
module Unit
module Assertions
def assert_warn(pattern, message = nil, &block)
class << (output = "")
class << (output = +"")
alias write <<
end
stderr, $stderr = $stderr, output

View file

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# frozen_string_literal: false
require File.expand_path('helper', File.dirname(__FILE__))
require 'psych' if !defined?(YAML) && RUBY_VERSION == "1.9.2"
require 'yaml'
@ -757,7 +758,7 @@ class TestHTTPCookie < Test::Unit::TestCase
assert_equal 12, cookie.max_age
cookie.max_age = -3
assert_equal -3, cookie.max_age
assert_equal(-3, cookie.max_age)
end
def test_session

View file

@ -1,3 +1,4 @@
# frozen_string_literal: false
require File.expand_path('helper', File.dirname(__FILE__))
require 'tmpdir'