Skip to content

Commit

Permalink
fix: be explicit about frozen string literals to quash warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Mar 24, 2024
1 parent cffe324 commit d0676f4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/http/cookie.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# :markup: markdown
# frozen_string_literal: true
require 'http/cookie/version'
require 'http/cookie/uri_parser'
require 'time'
Expand Down Expand Up @@ -425,7 +426,7 @@ def domain= domain
# 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.
Expand Down
7 changes: 4 additions & 3 deletions lib/http/cookie/scanner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'http/cookie'
require 'strscan'
require 'time'
Expand All @@ -23,7 +24,7 @@ def initialize(string, logger = nil)
class << self
def quote(s)
return s unless s.match(RE_BAD_CHAR)
'"' << s.gsub(/([\\"])/, "\\\\\\1") << '"'
(+'"') << s.gsub(/([\\"])/, "\\\\\\1") << '"'
end
end

Expand All @@ -32,7 +33,7 @@ def skip_wsp
end

def scan_dquoted
''.tap { |s|
(+'').tap { |s|
case
when skip(/"/)
break
Expand All @@ -51,7 +52,7 @@ def scan_name
end

def scan_value(comma_as_separator = false)
''.tap { |s|
(+'').tap { |s|
case
when scan(/[^,;"]+/)
s << matched
Expand Down
2 changes: 1 addition & 1 deletion test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/test_http_cookie.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -757,7 +758,7 @@ def test_max_age=
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
Expand Down
1 change: 1 addition & 0 deletions test/test_http_cookie_jar.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: false
require File.expand_path('helper', File.dirname(__FILE__))
require 'tmpdir'

Expand Down

0 comments on commit d0676f4

Please sign in to comment.