DEV: enable frozen string literal on all files

This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
This commit is contained in:
Sam Saffron
2019-05-03 08:17:27 +10:00
committed by Guo Xiang Tan
parent 4e1f25197d
commit 30990006a9
2201 changed files with 4482 additions and 90 deletions

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'sassc'
module Stylesheet

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency 'stylesheet/common'
require_dependency 'stylesheet/importer'
require_dependency 'stylesheet/functions'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Stylesheet
module ScssFunctions
def asset_url(path)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency 'stylesheet/common'
require_dependency 'global_path'
@ -34,18 +36,17 @@ module Stylesheet
end
register_import "theme_colors" do
contents = ""
contents = +""
colors = (@theme_id && theme.color_scheme) ? theme.color_scheme.resolved_colors : ColorScheme.base_colors
colors.each do |n, hex|
contents << "$#{n}: ##{hex} !default;\n"
end
contents
Import.new("theme_colors.scss", source: contents)
end
register_import "theme_variables" do
contents = ""
contents = +""
theme&.all_theme_variables&.each do |field|
if field.type_id == ThemeField.types[:theme_upload_var]
@ -66,7 +67,7 @@ module Stylesheet
end
register_import "category_backgrounds" do
contents = ""
contents = +""
Category.where('uploaded_background_id IS NOT NULL').each do |c|
contents << category_css(c) if c.uploaded_background&.url.present?
end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency 'distributed_cache'
require_dependency 'stylesheet/compiler'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'listen'
module Stylesheet