Skip to content

Commit 56c756b

Browse files
authored
Fixed a few codeclimate warnings (#458)
* Fixed a few codeclimate warnings * Fixed eslint validation warning
1 parent 370994e commit 56c756b

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

lib/split/dashboard/public/dashboard-filtering.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ $(function() {
22
$('#filter').on('keyup', function() {
33
$input = $(this);
44

5-
if ($input.val() == '') {
5+
if ($input.val() === '') {
66
$('div.experiment').show();
77
return false;
88
}
@@ -21,7 +21,7 @@ $(function() {
2121

2222
$('#toggle-active').on('click', function() {
2323
$button = $(this);
24-
if ($button.val() == 'Hide active') {
24+
if ($button.val() === 'Hide active') {
2525
$button.val('Show active');
2626
} else {
2727
$button.val('Hide active');
@@ -32,7 +32,7 @@ $(function() {
3232

3333
$('#toggle-completed').on('click', function() {
3434
$button = $(this);
35-
if ($button.val() == 'Hide completed') {
35+
if ($button.val() === 'Hide completed') {
3636
$button.val('Show completed');
3737
} else {
3838
$button.val('Hide completed');

lib/split/experiment.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,9 @@ def alternatives=(alts)
135135
end
136136

137137
def winner
138-
if w = redis.hget(:experiment_winner, name)
139-
Split::Alternative.new(w, name)
138+
experiment_winner = redis.hget(:experiment_winner, name)
139+
if experiment_winner
140+
Split::Alternative.new(experiment_winner, name)
140141
else
141142
nil
142143
end
@@ -171,9 +172,9 @@ def start_time
171172
if t
172173
# Check if stored time is an integer
173174
if t =~ /^[-+]?[0-9]+$/
174-
t = Time.at(t.to_i)
175+
Time.at(t.to_i)
175176
else
176-
t = Time.parse(t)
177+
Time.parse(t)
177178
end
178179
end
179180
end
@@ -191,7 +192,7 @@ def random_alternative
191192
end
192193

193194
def version
194-
@version ||= (redis.get("#{name.to_s}:version").to_i || 0)
195+
@version ||= (redis.get("#{name}:version").to_i || 0)
195196
end
196197

197198
def increment_version
@@ -280,8 +281,6 @@ def calc_winning_alternatives
280281
end
281282

282283
def estimate_winning_alternative(goal = nil)
283-
# TODO - refactor out functionality to work with and without goals
284-
285284
# initialize a hash of beta distributions based on the alternatives' conversion rates
286285
beta_params = calc_beta_params(goal)
287286

@@ -401,7 +400,7 @@ def experiment_config_key
401400
end
402401

403402
def load_metadata_from_configuration
404-
metadata = Split.configuration.experiment_for(@name)[:metadata]
403+
Split.configuration.experiment_for(@name)[:metadata]
405404
end
406405

407406
def load_metadata_from_redis

0 commit comments

Comments
 (0)