Skip to content

Commit 09df6c6

Browse files
committed
Code style for the rest of app
1 parent e007cd7 commit 09df6c6

25 files changed

+87
-41
lines changed

app/background_tasks/background_course_refresher_task.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'background_course_refresher'
24

35
class BackgroundCourseRefresherTask

app/background_tasks/submission_reprocessor_task.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'submission_processor'
24

35
class SubmissionReprocessorTask

app/helpers/application_helper.rb

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'tailoring'
24

35
module ApplicationHelper
@@ -18,7 +20,7 @@ def active_on_current_path_link_to(name, path, options = {})
1820
classes += ' active'
1921
options[:class] = classes
2022
end
21-
return link_to(name, path, options)
23+
link_to(name, path, options)
2224
end
2325

2426
def labeled(label, tags = nil, options = {}, &block)
@@ -36,9 +38,9 @@ def labeled(label, tags = nil, options = {}, &block)
3638
tags = tags.html_safe
3739

3840
if tags =~ /id\s*=\s*"([^"]+)"/
39-
target = ' for="' + $1 + '"'
41+
target = ' for="' + Regexp.last_match(1) + '"'
4042
else
41-
fail 'Cannot label a tag without an id'
43+
raise 'Cannot label a tag without an id'
4244
end
4345

4446
cls = []
@@ -56,7 +58,7 @@ def labeled(label, tags = nil, options = {}, &block)
5658
when :label_last
5759
label_start + tags + label_text + label_end
5860
else
59-
fail 'invalid :order option for labeled()'
61+
raise 'invalid :order option for labeled()'
6062
end
6163
end
6264

@@ -79,7 +81,7 @@ def bs_labeled_field(label, field, options = {})
7981
str << '</label>'
8082
else
8183
label = label_tag label, nil, class: 'control-label'
82-
str += raw("<div class=\"form-group\">" + raw(label) + raw(field) + '</div>')
84+
str += raw('<div class="form-group">' + raw(label) + raw(field) + '</div>')
8385
end
8486
raw(str)
8587
end
@@ -89,14 +91,14 @@ def use_datatables(table_selector, options = {})
8991
bJQueryUI: true,
9092
bSort: false
9193
}.merge options
92-
script = <<EOS
93-
<script type="text/javascript">
94-
<!--
95-
$(document).ready(function() {
96-
$('#{escape_javascript table_selector}').dataTable(#{options.to_json});
97-
});
98-
//-->
99-
</script>
94+
script = <<~EOS
95+
<script type="text/javascript">
96+
<!--
97+
$(document).ready(function() {
98+
$('#{escape_javascript table_selector}').dataTable(#{options.to_json});
99+
});
100+
//-->
101+
</script>
100102
EOS
101103
raw(script)
102104
end

app/helpers/authorize_collection_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module AuthorizeCollectionHelper
24
# This method allows to authorize collections of items
35
# TODO: Has to be tested with empty collections and other edge cases

app/helpers/bad_utf8_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
# frozen_string_literal: true
3+
24
module BadUtf8Helper
35
def force_utf8_violently(str)
46
if str.encoding == Encoding.find('UTF-8') && str.valid_encoding?

app/helpers/bootstrap_flash_helper.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
# frozen_string_literal: true
2+
13
module BootstrapFlashHelper
2-
ALERT_TYPES = [:error, :info, :success, :danger]
4+
ALERT_TYPES = %i[error info success danger].freeze
35

46
def bootstrap_flash
57
flash_messages = []
@@ -8,7 +10,7 @@ def bootstrap_flash
810
next if message.blank?
911

1012
type = :success if type.to_sym == :notice
11-
type = :danger if type.to_sym == :alert
13+
type = :danger if type.to_sym == :alert
1214

1315
next unless ALERT_TYPES.include?(type.to_sym)
1416

app/helpers/comet_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'site_setting'
24

35
module CometHelper

app/helpers/course_timings_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module CourseTimingsHelper
24
def parse_percentage_from_unlock_condition(condition)
35
if condition =~ /^(\d+)[%]\s+(?:in|of|from)\s+(\S+)$/

app/helpers/courses_helper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
# frozen_string_literal: true
2+
13
module CoursesHelper
24
def response_body_for(body)
35
return "You wrote:\n\n#{body}\n\n---\n\n"
4-
"#{body}"
6+
body.to_s
57
end
68
end

app/helpers/embeddable_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module EmbeddableHelper
24
def remove_x_frame_options_header_when_bare_layout
35
response.headers.except! 'X-Frame-Options' if @bare_layout

0 commit comments

Comments
 (0)