Skip to content

Commit 4ee3f02

Browse files
authored
Merge pull request #682 from splitrb/fix-string-literals
Enforce double quotes
2 parents c49f156 + 9c2f237 commit 4ee3f02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1046
-1062
lines changed

.rubocop.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
inherit_from: .rubocop_todo.yml
2-
31
AllCops:
42
TargetRubyVersion: 2.5
53
DisabledByDefault: true
4+
SuggestExtensions: false
65
Exclude:
76
- 'gemfiles/**/*'
87

@@ -112,7 +111,7 @@ Layout/SpaceInsideParens:
112111
Enabled: true
113112

114113
Style/StringLiterals:
115-
Enabled: false
114+
Enabled: true
116115
EnforcedStyle: double_quotes
117116

118117
Layout/IndentationStyle:

.rubocop_todo.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ source "https://rubygems.org"
44

55
gemspec
66

7-
gem 'rubocop', require: false
7+
gem "rubocop", require: false
88
gem "matrix"
99
gem "codeclimate-test-reporter"

Rakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env rake
22
# frozen_string_literal: true
33

4-
require 'bundler/gem_tasks'
5-
require 'rspec/core/rake_task'
4+
require "bundler/gem_tasks"
5+
require "rspec/core/rake_task"
66

7-
RSpec::Core::RakeTask.new('spec')
7+
RSpec::Core::RakeTask.new("spec")
88

99
task default: :spec

lib/split.rb

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
# frozen_string_literal: true
22

3-
require 'redis'
3+
require "redis"
44

5-
require 'split/algorithms'
6-
require 'split/algorithms/block_randomization'
7-
require 'split/algorithms/weighted_sample'
8-
require 'split/algorithms/whiplash'
9-
require 'split/alternative'
10-
require 'split/cache'
11-
require 'split/configuration'
12-
require 'split/encapsulated_helper'
13-
require 'split/exceptions'
14-
require 'split/experiment'
15-
require 'split/experiment_catalog'
16-
require 'split/extensions/string'
17-
require 'split/goals_collection'
18-
require 'split/helper'
19-
require 'split/combined_experiments_helper'
20-
require 'split/metric'
21-
require 'split/persistence'
22-
require 'split/redis_interface'
23-
require 'split/trial'
24-
require 'split/user'
25-
require 'split/version'
26-
require 'split/zscore'
27-
require 'split/engine' if defined?(Rails)
5+
require "split/algorithms"
6+
require "split/algorithms/block_randomization"
7+
require "split/algorithms/weighted_sample"
8+
require "split/algorithms/whiplash"
9+
require "split/alternative"
10+
require "split/cache"
11+
require "split/configuration"
12+
require "split/encapsulated_helper"
13+
require "split/exceptions"
14+
require "split/experiment"
15+
require "split/experiment_catalog"
16+
require "split/extensions/string"
17+
require "split/goals_collection"
18+
require "split/helper"
19+
require "split/combined_experiments_helper"
20+
require "split/metric"
21+
require "split/persistence"
22+
require "split/redis_interface"
23+
require "split/trial"
24+
require "split/user"
25+
require "split/version"
26+
require "split/zscore"
27+
require "split/engine" if defined?(Rails)
2828

2929
module Split
3030
extend self

lib/split/algorithms.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
end
1010
end
1111

12-
require 'rubystats'
12+
require "rubystats"
1313

1414
module Split
1515
module Algorithms

lib/split/alternative.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ def set_p_winner(prob, goal = nil)
3838
end
3939

4040
def participant_count
41-
Split.redis.hget(key, 'participant_count').to_i
41+
Split.redis.hget(key, "participant_count").to_i
4242
end
4343

4444
def participant_count=(count)
45-
Split.redis.hset(key, 'participant_count', count.to_i)
45+
Split.redis.hset(key, "participant_count", count.to_i)
4646
end
4747

4848
def completed_count(goal = nil)
@@ -82,7 +82,7 @@ def set_completed_count(count, goal = nil)
8282
end
8383

8484
def increment_participation
85-
Split.redis.hincrby key, 'participant_count', 1
85+
Split.redis.hincrby key, "participant_count", 1
8686
end
8787

8888
def increment_completion(goal = nil)
@@ -112,7 +112,7 @@ def z_score(goal = nil)
112112
control = experiment.control
113113
alternative = self
114114

115-
return 'N/A' if control.name == alternative.name
115+
return "N/A" if control.name == alternative.name
116116

117117
p_a = alternative.conversion_rate(goal)
118118
p_c = control.conversion_rate(goal)
@@ -121,13 +121,13 @@ def z_score(goal = nil)
121121
n_c = control.participant_count
122122

123123
# can't calculate zscore for P(x) > 1
124-
return 'N/A' if p_a > 1 || p_c > 1
124+
return "N/A" if p_a > 1 || p_c > 1
125125

126126
Split::Zscore.calculate(p_a, n_a, p_c, n_c)
127127
end
128128

129129
def extra_info
130-
data = Split.redis.hget(key, 'recorded_info')
130+
data = Split.redis.hget(key, "recorded_info")
131131
if data && data.length > 1
132132
begin
133133
JSON.parse(data)
@@ -149,24 +149,24 @@ def record_extra_info(k, value = 1)
149149
@recorded_info[k] = value
150150
end
151151

152-
Split.redis.hset key, 'recorded_info', (@recorded_info || {}).to_json
152+
Split.redis.hset key, "recorded_info", (@recorded_info || {}).to_json
153153
end
154154

155155
def save
156-
Split.redis.hsetnx key, 'participant_count', 0
157-
Split.redis.hsetnx key, 'completed_count', 0
158-
Split.redis.hsetnx key, 'p_winner', p_winner
159-
Split.redis.hsetnx key, 'recorded_info', (@recorded_info || {}).to_json
156+
Split.redis.hsetnx key, "participant_count", 0
157+
Split.redis.hsetnx key, "completed_count", 0
158+
Split.redis.hsetnx key, "p_winner", p_winner
159+
Split.redis.hsetnx key, "recorded_info", (@recorded_info || {}).to_json
160160
end
161161

162162
def validate!
163163
unless String === @name || hash_with_correct_values?(@name)
164-
raise ArgumentError, 'Alternative must be a string'
164+
raise ArgumentError, "Alternative must be a string"
165165
end
166166
end
167167

168168
def reset
169-
Split.redis.hmset key, 'participant_count', 0, 'completed_count', 0, 'recorded_info', nil
169+
Split.redis.hmset key, "participant_count", 0, "completed_count", 0, "recorded_info", nil
170170
unless goals.empty?
171171
goals.each do |g|
172172
field = "completed_count:#{g}"

lib/split/combined_experiments_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def ab_combined_test(metric_descriptor, control = nil, *alternatives)
2929
end
3030

3131
def find_combined_experiment(metric_descriptor)
32-
raise(Split::InvalidExperimentsFormatError, 'Invalid descriptor class (String or Symbol required)') unless metric_descriptor.class == String || metric_descriptor.class == Symbol
33-
raise(Split::InvalidExperimentsFormatError, 'Enable configuration') unless Split.configuration.enabled
34-
raise(Split::InvalidExperimentsFormatError, 'Enable `allow_multiple_experiments`') unless Split.configuration.allow_multiple_experiments
32+
raise(Split::InvalidExperimentsFormatError, "Invalid descriptor class (String or Symbol required)") unless metric_descriptor.class == String || metric_descriptor.class == Symbol
33+
raise(Split::InvalidExperimentsFormatError, "Enable configuration") unless Split.configuration.enabled
34+
raise(Split::InvalidExperimentsFormatError, "Enable `allow_multiple_experiments`") unless Split.configuration.allow_multiple_experiments
3535
Split.configuration.experiments[metric_descriptor.to_sym]
3636
end
3737
end

lib/split/configuration.rb

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -39,83 +39,83 @@ class Configuration
3939
def bots
4040
@bots ||= {
4141
# Indexers
42-
'AdsBot-Google' => 'Google Adwords',
43-
'Baidu' => 'Chinese search engine',
44-
'Baiduspider' => 'Chinese search engine',
45-
'bingbot' => 'Microsoft bing bot',
46-
'Butterfly' => 'Topsy Labs',
47-
'Gigabot' => 'Gigabot spider',
48-
'Googlebot' => 'Google spider',
49-
'MJ12bot' => 'Majestic-12 spider',
50-
'msnbot' => 'Microsoft bot',
51-
'rogerbot' => 'SeoMoz spider',
52-
'PaperLiBot' => 'PaperLi is another content curation service',
53-
'Slurp' => 'Yahoo spider',
54-
'Sogou' => 'Chinese search engine',
55-
'spider' => 'generic web spider',
56-
'UnwindFetchor' => 'Gnip crawler',
57-
'WordPress' => 'WordPress spider',
58-
'YandexAccessibilityBot' => 'Yandex accessibility spider',
59-
'YandexBot' => 'Yandex spider',
60-
'YandexMobileBot' => 'Yandex mobile spider',
61-
'ZIBB' => 'ZIBB spider',
42+
"AdsBot-Google" => "Google Adwords",
43+
"Baidu" => "Chinese search engine",
44+
"Baiduspider" => "Chinese search engine",
45+
"bingbot" => "Microsoft bing bot",
46+
"Butterfly" => "Topsy Labs",
47+
"Gigabot" => "Gigabot spider",
48+
"Googlebot" => "Google spider",
49+
"MJ12bot" => "Majestic-12 spider",
50+
"msnbot" => "Microsoft bot",
51+
"rogerbot" => "SeoMoz spider",
52+
"PaperLiBot" => "PaperLi is another content curation service",
53+
"Slurp" => "Yahoo spider",
54+
"Sogou" => "Chinese search engine",
55+
"spider" => "generic web spider",
56+
"UnwindFetchor" => "Gnip crawler",
57+
"WordPress" => "WordPress spider",
58+
"YandexAccessibilityBot" => "Yandex accessibility spider",
59+
"YandexBot" => "Yandex spider",
60+
"YandexMobileBot" => "Yandex mobile spider",
61+
"ZIBB" => "ZIBB spider",
6262

6363
# HTTP libraries
64-
'Apache-HttpClient' => 'Java http library',
65-
'AppEngine-Google' => 'Google App Engine',
66-
'curl' => 'curl unix CLI http client',
67-
'ColdFusion' => 'ColdFusion http library',
68-
'EventMachine HttpClient' => 'Ruby http library',
69-
'Go http package' => 'Go http library',
70-
'Go-http-client' => 'Go http library',
71-
'Java' => 'Generic Java http library',
72-
'libwww-perl' => 'Perl client-server library loved by script kids',
73-
'lwp-trivial' => 'Another Perl library loved by script kids',
74-
'Python-urllib' => 'Python http library',
75-
'PycURL' => 'Python http library',
76-
'Test Certificate Info' => 'C http library?',
77-
'Typhoeus' => 'Ruby http library',
78-
'Wget' => 'wget unix CLI http client',
64+
"Apache-HttpClient" => "Java http library",
65+
"AppEngine-Google" => "Google App Engine",
66+
"curl" => "curl unix CLI http client",
67+
"ColdFusion" => "ColdFusion http library",
68+
"EventMachine HttpClient" => "Ruby http library",
69+
"Go http package" => "Go http library",
70+
"Go-http-client" => "Go http library",
71+
"Java" => "Generic Java http library",
72+
"libwww-perl" => "Perl client-server library loved by script kids",
73+
"lwp-trivial" => "Another Perl library loved by script kids",
74+
"Python-urllib" => "Python http library",
75+
"PycURL" => "Python http library",
76+
"Test Certificate Info" => "C http library?",
77+
"Typhoeus" => "Ruby http library",
78+
"Wget" => "wget unix CLI http client",
7979

8080
# URL expanders / previewers
81-
'awe.sm' => 'Awe.sm URL expander',
82-
'bitlybot' => 'bit.ly bot',
83-
'bot@linkfluence.net' => 'Linkfluence bot',
84-
'facebookexternalhit' => 'facebook bot',
85-
'Facebot' => 'Facebook crawler',
86-
'Feedfetcher-Google' => 'Google Feedfetcher',
87-
'https://developers.google.com/+/web/snippet' => 'Google+ Snippet Fetcher',
88-
'LinkedInBot' => 'LinkedIn bot',
89-
'LongURL' => 'URL expander service',
90-
'NING' => 'NING - Yet Another Twitter Swarmer',
91-
'Pinterestbot' => 'Pinterest Bot',
92-
'redditbot' => 'Reddit Bot',
93-
'ShortLinkTranslate' => 'Link shortener',
94-
'Slackbot' => 'Slackbot link expander',
95-
'TweetmemeBot' => 'TweetMeMe Crawler',
96-
'Twitterbot' => 'Twitter URL expander',
97-
'UnwindFetch' => 'Gnip URL expander',
98-
'vkShare' => 'VKontake Sharer',
81+
"awe.sm" => "Awe.sm URL expander",
82+
"bitlybot" => "bit.ly bot",
83+
"bot@linkfluence.net" => "Linkfluence bot",
84+
"facebookexternalhit" => "facebook bot",
85+
"Facebot" => "Facebook crawler",
86+
"Feedfetcher-Google" => "Google Feedfetcher",
87+
"https://developers.google.com/+/web/snippet" => "Google+ Snippet Fetcher",
88+
"LinkedInBot" => "LinkedIn bot",
89+
"LongURL" => "URL expander service",
90+
"NING" => "NING - Yet Another Twitter Swarmer",
91+
"Pinterestbot" => "Pinterest Bot",
92+
"redditbot" => "Reddit Bot",
93+
"ShortLinkTranslate" => "Link shortener",
94+
"Slackbot" => "Slackbot link expander",
95+
"TweetmemeBot" => "TweetMeMe Crawler",
96+
"Twitterbot" => "Twitter URL expander",
97+
"UnwindFetch" => "Gnip URL expander",
98+
"vkShare" => "VKontake Sharer",
9999

100100
# Uptime monitoring
101-
'check_http' => 'Nagios monitor',
102-
'GoogleStackdriverMonitoring' => 'Google Cloud monitor',
103-
'NewRelicPinger' => 'NewRelic monitor',
104-
'Panopta' => 'Monitoring service',
105-
'Pingdom' => 'Pingdom monitoring',
106-
'SiteUptime' => 'Site monitoring services',
107-
'UptimeRobot' => 'Monitoring service',
101+
"check_http" => "Nagios monitor",
102+
"GoogleStackdriverMonitoring" => "Google Cloud monitor",
103+
"NewRelicPinger" => "NewRelic monitor",
104+
"Panopta" => "Monitoring service",
105+
"Pingdom" => "Pingdom monitoring",
106+
"SiteUptime" => "Site monitoring services",
107+
"UptimeRobot" => "Monitoring service",
108108

109109
# ???
110-
'DigitalPersona Fingerprint Software' => 'HP Fingerprint scanner',
111-
'ShowyouBot' => 'Showyou iOS app spider',
112-
'ZyBorg' => 'Zyborg? Hmmm....',
113-
'ELB-HealthChecker' => 'ELB Health Check'
110+
"DigitalPersona Fingerprint Software" => "HP Fingerprint scanner",
111+
"ShowyouBot" => "Showyou iOS app spider",
112+
"ZyBorg" => "Zyborg? Hmmm....",
113+
"ELB-HealthChecker" => "ELB Health Check"
114114
}
115115
end
116116

117117
def experiments=(experiments)
118-
raise InvalidExperimentsFormatError.new('Experiments must be a Hash') unless experiments.respond_to?(:keys)
118+
raise InvalidExperimentsFormatError.new("Experiments must be a Hash") unless experiments.respond_to?(:keys)
119119
@experiments = experiments
120120
end
121121

@@ -232,7 +232,7 @@ def initialize
232232
@include_rails_helper = true
233233
@beta_probability_simulations = 10000
234234
@winning_alternative_recalculation_interval = 60 * 60 * 24 # 1 day
235-
@redis = ENV.fetch(ENV.fetch('REDIS_PROVIDER', 'REDIS_URL'), 'redis://localhost:6379')
235+
@redis = ENV.fetch(ENV.fetch("REDIS_PROVIDER", "REDIS_URL"), "redis://localhost:6379")
236236
@dashboard_pagination_default_per_page = 10
237237
end
238238

0 commit comments

Comments
 (0)