diff --git a/.rubocop.yml b/.rubocop.yml index e28a0876aa1..9f2254dd3a6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -114,3 +114,10 @@ Layout/AlignHash: Bundler/OrderedGems: Enabled: false + +Style/SingleLineMethods: + Enabled: true + +Style/Semicolon: + Enabled: true + AllowAsExpressionSeparator: true \ No newline at end of file diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index fec948e8be0..2d353702258 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -575,7 +575,7 @@ class UserNotifications < ActionMailer::Base if SiteSetting.private_email? message = I18n.t('system_messages.contents_hidden') else - message = email_post_markdown(post) + (reached_limit ? "\n\n#{I18n.t "user_notifications.reached_limit", count: SiteSetting.max_emails_per_day_per_user}" : ""); + message = email_post_markdown(post) + (reached_limit ? "\n\n#{I18n.t "user_notifications.reached_limit", count: SiteSetting.max_emails_per_day_per_user}" : "") end first_footer_classes = "hilight" diff --git a/app/models/backup_location_site_setting.rb b/app/models/backup_location_site_setting.rb index aef3c89fec3..4763c3be047 100644 --- a/app/models/backup_location_site_setting.rb +++ b/app/models/backup_location_site_setting.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_dependency 'enum_site_setting'; +require_dependency 'enum_site_setting' class BackupLocationSiteSetting < EnumSiteSetting LOCAL ||= "local" diff --git a/app/models/queued_post.rb b/app/models/queued_post.rb index a4067f8c57a..92cc688fa96 100644 --- a/app/models/queued_post.rb +++ b/app/models/queued_post.rb @@ -1,6 +1,6 @@ class QueuedPost < ActiveRecord::Base - class InvalidStateTransition < StandardError; end; + class InvalidStateTransition < StandardError; end belongs_to :user belongs_to :topic diff --git a/db/migrate/20150818190757_create_embeddable_hosts.rb b/db/migrate/20150818190757_create_embeddable_hosts.rb index c5ae2ac36a8..fc52e7bb8c8 100644 --- a/db/migrate/20150818190757_create_embeddable_hosts.rb +++ b/db/migrate/20150818190757_create_embeddable_hosts.rb @@ -6,7 +6,7 @@ class CreateEmbeddableHosts < ActiveRecord::Migration[4.2] t.timestamps null: false end - category_id = 0; + category_id = 0 category_row = execute("SELECT c.id FROM categories AS c INNER JOIN site_settings AS s ON s.value = c.name WHERE s.name = 'embed_category'") diff --git a/lib/autospec/qunit_runner.rb b/lib/autospec/qunit_runner.rb index 6598207c74a..91e3d3983cb 100644 --- a/lib/autospec/qunit_runner.rb +++ b/lib/autospec/qunit_runner.rb @@ -5,8 +5,12 @@ module Autospec class QunitRunner < BaseRunner WATCHERS = {} - def self.watch(pattern, &blk); WATCHERS[pattern] = blk; end - def watchers; WATCHERS; end + def self.watch(pattern, &blk) + WATCHERS[pattern] = blk + end + def watchers + WATCHERS + end # Discourse specific watch(%r{^app/assets/javascripts/discourse/(.+)\.js.es6$}) { |m| "test/javascripts/#{m[1]}-test.js.es6" } @@ -14,8 +18,12 @@ module Autospec watch(%r{^test/javascripts/.+\.js.es6$}) RELOADERS = Set.new - def self.reload(pattern); RELOADERS << pattern; end - def reloaders; RELOADERS; end + def self.reload(pattern) + RELOADERS << pattern + end + def reloaders + RELOADERS + end # Discourse specific reload(%r{^test/javascripts/fixtures/.+_fixtures\.js(\.es6)?$}) diff --git a/lib/autospec/rspec_runner.rb b/lib/autospec/rspec_runner.rb index e8848c6937a..64cb0302080 100644 --- a/lib/autospec/rspec_runner.rb +++ b/lib/autospec/rspec_runner.rb @@ -3,8 +3,12 @@ module Autospec class RspecRunner < BaseRunner WATCHERS = {} - def self.watch(pattern, &blk); WATCHERS[pattern] = blk; end - def watchers; WATCHERS; end + def self.watch(pattern, &blk) + WATCHERS[pattern] = blk + end + def watchers + WATCHERS + end # Discourse specific watch(%r{^lib/(.+)\.rb$}) { |m| "spec/components/#{m[1]}_spec.rb" } @@ -30,8 +34,12 @@ module Autospec watch(%r{^(plugins/.*)/lib/(.*)\.rb}) { |m| "#{m[1]}/spec/lib/#{m[2]}_spec.rb" } RELOADERS = Set.new - def self.reload(pattern); RELOADERS << pattern; end - def reloaders; RELOADERS; end + def self.reload(pattern) + RELOADERS << pattern + end + def reloaders + RELOADERS + end # we are using a simple runner at the moment, whole idea of using a reloader is no longer needed watch("spec/rails_helper.rb") diff --git a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb index 10802feaac9..f45884fb8b5 100644 --- a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb +++ b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb @@ -28,7 +28,7 @@ module Tilt ctx = MiniRacer::Context.new(timeout: 15000) ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}") ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js'))) - ctx.eval("module = {}; exports = {};"); + ctx.eval("module = {}; exports = {};") ctx.attach("rails.logger.info", proc { |err| Rails.logger.info(err.to_s) }) ctx.attach("rails.logger.error", proc { |err| Rails.logger.error(err.to_s) }) ctx.eval < e if e.cause.is_a?(Discourse::InvalidMigration) - def e.cause; nil; end + def e.cause + nil + end def e.backtrace super.reject do |frame| frame =~ /safe_migrate\.rb/ || frame =~ /schema_migration_details\.rb/ diff --git a/lib/stylesheet/compiler.rb b/lib/stylesheet/compiler.rb index 5aff8dfdba4..8cba8e677bc 100644 --- a/lib/stylesheet/compiler.rb +++ b/lib/stylesheet/compiler.rb @@ -32,7 +32,7 @@ module Stylesheet end def self.compile(stylesheet, filename, options = {}) - source_map_file = options[:source_map_file] || "#{filename.sub(".scss", "")}.css.map"; + source_map_file = options[:source_map_file] || "#{filename.sub(".scss", "")}.css.map" engine = SassC::Engine.new(stylesheet, importer: Importer, diff --git a/lib/validators/allow_user_locale_enabled_validator.rb b/lib/validators/allow_user_locale_enabled_validator.rb index 73d3cb5c51b..09a283212c4 100644 --- a/lib/validators/allow_user_locale_enabled_validator.rb +++ b/lib/validators/allow_user_locale_enabled_validator.rb @@ -12,7 +12,7 @@ class AllowUserLocaleEnabledValidator end def error_message - I18n.t("site_settings.errors.user_locale_not_enabled"); + I18n.t("site_settings.errors.user_locale_not_enabled") end end diff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rb index 0ac869d96ef..9401fc16fd5 100644 --- a/script/bulk_import/base.rb +++ b/script/bulk_import/base.rb @@ -183,14 +183,28 @@ class BulkImport::Base @raw_connection.exec("SELECT setval('#{PostAction.sequence_name}', #{@last_post_action_id})") if @last_post_action_id > 0 end - def group_id_from_imported_id(id); @groups[id.to_s]; end - def user_id_from_imported_id(id); @users[id.to_s]; end - def category_id_from_imported_id(id); @categories[id.to_s]; end - def topic_id_from_imported_id(id); @topics[id.to_s]; end - def post_id_from_imported_id(id); @posts[id.to_s]; end + def group_id_from_imported_id(id) + @groups[id.to_s] + end + def user_id_from_imported_id(id) + @users[id.to_s] + end + def category_id_from_imported_id(id) + @categories[id.to_s] + end + def topic_id_from_imported_id(id) + @topics[id.to_s] + end + def post_id_from_imported_id(id) + @posts[id.to_s] + end - def post_number_from_imported_id(id); @post_number_by_post_id[post_id_from_imported_id(id)]; end - def topic_id_from_imported_post_id(id); @topic_id_by_post_id[post_id_from_imported_id(id)]; end + def post_number_from_imported_id(id) + @post_number_by_post_id[post_id_from_imported_id(id)] + end + def topic_id_from_imported_post_id(id) + @topic_id_by_post_id[post_id_from_imported_id(id)] + end GROUP_COLUMNS ||= %i{ id name title bio_raw bio_cooked created_at updated_at @@ -250,7 +264,9 @@ class BulkImport::Base topic_id tag_id created_at updated_at } - def create_groups(rows, &block); create_records(rows, "group", GROUP_COLUMNS, &block); end + def create_groups(rows, &block) + create_records(rows, "group", GROUP_COLUMNS, &block) + end def create_users(rows, &block) @imported_usernames = {} @@ -273,16 +289,36 @@ class BulkImport::Base end end - def create_user_emails(rows, &block) create_records(rows, "user_email", USER_EMAIL_COLUMNS, &block); end - def create_user_stats(rows, &block) create_records(rows, "user_stat", USER_STAT_COLUMNS, &block); end - def create_user_profiles(rows, &block); create_records(rows, "user_profile", USER_PROFILE_COLUMNS, &block); end - def create_group_users(rows, &block); create_records(rows, "group_user", GROUP_USER_COLUMNS, &block); end - def create_categories(rows, &block); create_records(rows, "category", CATEGORY_COLUMNS, &block); end - def create_topics(rows, &block); create_records(rows, "topic", TOPIC_COLUMNS, &block); end - def create_posts(rows, &block); create_records(rows, "post", POST_COLUMNS, &block); end - def create_post_actions(rows, &block); create_records(rows, "post_action", POST_ACTION_COLUMNS, &block); end - def create_topic_allowed_users(rows, &block); create_records(rows, "topic_allowed_user", TOPIC_ALLOWED_USER_COLUMNS, &block); end - def create_topic_tags(rows, &block); create_records(rows, "topic_tag", TOPIC_TAG_COLUMNS, &block); end + def create_user_emails(rows, &block) + create_records(rows, "user_email", USER_EMAIL_COLUMNS, &block) + end + def create_user_stats(rows, &block) + create_records(rows, "user_stat", USER_STAT_COLUMNS, &block) + end + def create_user_profiles(rows, &block) + create_records(rows, "user_profile", USER_PROFILE_COLUMNS, &block) + end + def create_group_users(rows, &block) + create_records(rows, "group_user", GROUP_USER_COLUMNS, &block) + end + def create_categories(rows, &block) + create_records(rows, "category", CATEGORY_COLUMNS, &block) + end + def create_topics(rows, &block) + create_records(rows, "topic", TOPIC_COLUMNS, &block) + end + def create_posts(rows, &block) + create_records(rows, "post", POST_COLUMNS, &block) + end + def create_post_actions(rows, &block) + create_records(rows, "post_action", POST_ACTION_COLUMNS, &block) + end + def create_topic_allowed_users(rows, &block) + create_records(rows, "topic_allowed_user", TOPIC_ALLOWED_USER_COLUMNS, &block) + end + def create_topic_tags(rows, &block) + create_records(rows, "topic_tag", TOPIC_TAG_COLUMNS, &block) + end def process_group(group) @groups[group[:imported_id].to_s] = group[:id] = @last_group_id += 1 @@ -339,7 +375,7 @@ class BulkImport::Base end def process_user_email(user_email) - user_email[:id] = @last_user_email_id += 1; + user_email[:id] = @last_user_email_id += 1 user_email[:user_id] = @users[user_email[:imported_user_id].to_s] user_email[:primary] = true user_email[:created_at] ||= NOW diff --git a/script/compile_hbs.rb b/script/compile_hbs.rb index 785aae6b38e..21d2b22713e 100644 --- a/script/compile_hbs.rb +++ b/script/compile_hbs.rb @@ -1,7 +1,7 @@ ctx = MiniRacer::Context.new(timeout: 15000) ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}") ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js'))) -ctx.eval("module = {}; exports = {};"); +ctx.eval("module = {}; exports = {};") ctx.attach("rails.logger.info", proc { |err| puts(">> #{err.to_s}") }) ctx.attach("rails.logger.error", proc { |err| puts(">> #{err.to_s}") }) ctx.eval </, '[quote="\1"]' txt.gsub! /\<\/quote\>/, '[/quote]' txt.gsub!(/\(.*?)\<\/raw\>/m) do |match| - c = Regexp.last_match[1].indent(4); + c = Regexp.last_match[1].indent(4) "\n#{c}\n" end diff --git a/script/import_scripts/phpbb3/database/database.rb b/script/import_scripts/phpbb3/database/database.rb index fa88352349f..3cc3bd9e439 100644 --- a/script/import_scripts/phpbb3/database/database.rb +++ b/script/import_scripts/phpbb3/database/database.rb @@ -53,6 +53,6 @@ module ImportScripts::PhpBB3 end end - class UnsupportedVersionError < RuntimeError; + class UnsupportedVersionError < RuntimeError end end diff --git a/script/test_hbs_compiler.rb b/script/test_hbs_compiler.rb index 0045b942545..e5dec469ad4 100644 --- a/script/test_hbs_compiler.rb +++ b/script/test_hbs_compiler.rb @@ -19,7 +19,7 @@ HBS ctx = MiniRacer::Context.new(timeout: 15000) ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}") ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js'))) -ctx.eval("module = {}; exports = {};"); +ctx.eval("module = {}; exports = {};") ctx.attach("rails.logger.info", proc { |err| puts(err.to_s) }) ctx.attach("rails.logger.error", proc { |err| puts(err.to_s) }) ctx.eval <