Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.

Commit 700cdc5

Browse files
committed
Freeze mutable objects assigned to constants
1 parent 1064595 commit 700cdc5

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ require 'bundler'
22
Bundler::GemHelper.install_tasks
33

44
task :erd do
5-
FORMAT = 'svg'
5+
FORMAT = 'svg'.freeze
66
`bundle exec ruby ./etc/erd.rb > ./etc/erd.dot`
77
`dot -T #{FORMAT} ./etc/erd.dot -o ./etc/erd.#{FORMAT}`
88
end

etc/erd.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
require 'twitter'
22

3-
COLON = ':'
4-
UNDERSCORE = '_'
5-
TAB = "\t"
6-
NAMESPACE = 'Twitter::'
3+
COLON = ':'.freeze
4+
UNDERSCORE = '_'.freeze
5+
TAB = "\t".freeze
6+
NAMESPACE = 'Twitter::'.freeze
77

88
# Colons are invalid characters in DOT nodes.
99
# Replace them with underscores.

lib/twitter/error.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ class Error < StandardError
6868
502 => Twitter::Error::BadGateway,
6969
503 => Twitter::Error::ServiceUnavailable,
7070
504 => Twitter::Error::GatewayTimeout,
71-
}
71+
}.freeze
7272

7373
FORBIDDEN_MESSAGES = {
7474
'Status is a duplicate.' => Twitter::Error::DuplicateStatus,
7575
'You have already favorited this status.' => Twitter::Error::AlreadyFavorited,
7676
'sharing is not permissible for this status (Share validations failed)' => Twitter::Error::AlreadyRetweeted,
77-
}
77+
}.freeze
7878

7979
# If error code is missing see https://dev.twitter.com/overview/api/response-codes
8080
module Code

lib/twitter/rest/request.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Twitter
1212
module REST
1313
class Request
1414
include Twitter::Utils
15-
BASE_URL = 'https://api.twitter.com'
15+
BASE_URL = 'https://api.twitter.com'.freeze
1616
attr_accessor :client, :headers, :options, :path, :rate_limit,
1717
:request_method, :uri
1818
alias verb request_method
@@ -45,7 +45,7 @@ def set_multipart_options!(request_method, options)
4545
if request_method == :multipart_post
4646
key = options.delete(:key)
4747
file = options.delete(:file)
48-
options.merge!(key => HTTP::FormData::File.new(file, filename: File.basename(file), mime_type: mime_type(File.basename(file))))
48+
options[key] = HTTP::FormData::File.new(file, filename: File.basename(file), mime_type: mime_type(File.basename(file)))
4949
@request_method = :post
5050
@headers = Twitter::Headers.new(@client, @request_method, @uri).request_headers
5151
else

lib/twitter/streaming/event.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ class Event
55
:list_created, :list_destroyed, :list_updated, :list_member_added,
66
:list_member_added, :list_member_removed, :list_user_subscribed,
77
:list_user_subscribed, :list_user_unsubscribed, :list_user_unsubscribed
8-
]
8+
].freeze
99

1010
TWEET_EVENTS = [
1111
:favorite, :unfavorite
12-
]
12+
].freeze
1313

1414
attr_reader :name, :source, :target, :target_object
1515

0 commit comments

Comments
 (0)