diff --git a/.rubocop.yml b/.rubocop.yml index 9f2254dd3a6..9d2e219e3c7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -120,4 +120,4 @@ Style/SingleLineMethods: Style/Semicolon: Enabled: true - AllowAsExpressionSeparator: true \ No newline at end of file + AllowAsExpressionSeparator: true diff --git a/Gemfile.lock b/Gemfile.lock index daefc70c4e7..78de3e32186 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -270,7 +270,7 @@ GEM redis ruby-openid parallel (1.12.1) - parser (2.5.1.0) + parser (2.5.3.0) ast (~> 2.4.0) pg (1.1.3) powerpack (0.1.2) @@ -357,17 +357,17 @@ GEM rspec-support (~> 3.7.0) rspec-support (3.7.1) rtlit (0.0.5) - rubocop (0.57.2) + rubocop (0.60.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) - parser (>= 2.5) + parser (>= 2.5, != 2.5.1.1) powerpack (~> 0.1) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) + unicode-display_width (~> 1.4.0) ruby-openid (2.7.0) ruby-prof (0.17.0) - ruby-progressbar (1.9.0) + ruby-progressbar (1.10.0) ruby-readability (0.7.0) guess_html_encoding (>= 0.0.4) nokogiri (>= 1.6.0) diff --git a/app/controllers/queued_posts_controller.rb b/app/controllers/queued_posts_controller.rb index 6b31c14d5ae..6b9dadb7cc7 100644 --- a/app/controllers/queued_posts_controller.rb +++ b/app/controllers/queued_posts_controller.rb @@ -54,8 +54,8 @@ class QueuedPostsController < ApplicationController def user_deletion_opts base = { - context: I18n.t('queue.delete_reason', performed_by: current_user.username), - delete_posts: true, + context: I18n.t('queue.delete_reason', performed_by: current_user.username), + delete_posts: true, delete_as_spammer: true } diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 42d1ffe984e..c2f4f3a19c1 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -40,7 +40,7 @@ class SiteController < ApplicationController logo_url: UrlHelper.absolute(SiteSetting.site_logo_url), logo_small_url: UrlHelper.absolute(SiteSetting.site_logo_small_url), apple_touch_icon_url: UrlHelper.absolute(SiteSetting.site_apple_touch_icon_url), - favicon_url: UrlHelper.absolute(SiteSetting.site_favicon_url), + favicon_url: UrlHelper.absolute(SiteSetting.site_favicon_url), title: SiteSetting.title, description: SiteSetting.site_description, header_primary_color: ColorScheme.hex_for_name('header_primary') || '333333', diff --git a/app/jobs/regular/export_csv_file.rb b/app/jobs/regular/export_csv_file.rb index d32e2b822cd..4026dc7304c 100644 --- a/app/jobs/regular/export_csv_file.rb +++ b/app/jobs/regular/export_csv_file.rb @@ -10,16 +10,16 @@ module Jobs sidekiq_options retry: false HEADER_ATTRS_FOR ||= HashWithIndifferentAccess.new( - user_archive: ['topic_title', 'category', 'sub_category', 'is_pm', 'post', 'like_count', 'reply_count', 'url', 'created_at'], - user_list: ['id', 'name', 'username', 'email', 'title', 'created_at', 'last_seen_at', 'last_posted_at', 'last_emailed_at', 'trust_level', 'approved', 'suspended_at', 'suspended_till', 'silenced_till', 'active', 'admin', 'moderator', 'ip_address', 'staged'], - user_stats: ['topics_entered', 'posts_read_count', 'time_read', 'topic_count', 'post_count', 'likes_given', 'likes_received'], - user_profile: ['location', 'website', 'views'], - user_sso: ['external_id', 'external_email', 'external_username', 'external_name', 'external_avatar_url'], - staff_action: ['staff_user', 'action', 'subject', 'created_at', 'details', 'context'], + user_archive: ['topic_title', 'category', 'sub_category', 'is_pm', 'post', 'like_count', 'reply_count', 'url', 'created_at'], + user_list: ['id', 'name', 'username', 'email', 'title', 'created_at', 'last_seen_at', 'last_posted_at', 'last_emailed_at', 'trust_level', 'approved', 'suspended_at', 'suspended_till', 'silenced_till', 'active', 'admin', 'moderator', 'ip_address', 'staged'], + user_stats: ['topics_entered', 'posts_read_count', 'time_read', 'topic_count', 'post_count', 'likes_given', 'likes_received'], + user_profile: ['location', 'website', 'views'], + user_sso: ['external_id', 'external_email', 'external_username', 'external_name', 'external_avatar_url'], + staff_action: ['staff_user', 'action', 'subject', 'created_at', 'details', 'context'], screened_email: ['email', 'action', 'match_count', 'last_match_at', 'created_at', 'ip_address'], - screened_ip: ['ip_address', 'action', 'match_count', 'last_match_at', 'created_at'], - screened_url: ['domain', 'action', 'match_count', 'last_match_at', 'created_at'], - report: ['date', 'value'] + screened_ip: ['ip_address', 'action', 'match_count', 'last_match_at', 'created_at'], + screened_url: ['domain', 'action', 'match_count', 'last_match_at', 'created_at'], + report: ['date', 'value'] ) def execute(args) diff --git a/app/models/category_user.rb b/app/models/category_user.rb index bccd7cbef43..5a87b68fe0e 100644 --- a/app/models/category_user.rb +++ b/app/models/category_user.rb @@ -97,7 +97,7 @@ class CategoryUser < ActiveRecord::Base builder.exec( tracking: notification_levels[:tracking], regular: notification_levels[:regular], - auto_track_category: TopicUser.notification_reasons[:auto_track_category] + auto_track_category: TopicUser.notification_reasons[:auto_track_category] ) end @@ -157,7 +157,7 @@ class CategoryUser < ActiveRecord::Base watching: notification_levels[:watching], tracking: notification_levels[:tracking], regular: notification_levels[:regular], - auto_watch_category: TopicUser.notification_reasons[:auto_watch_category] + auto_watch_category: TopicUser.notification_reasons[:auto_watch_category] ) end diff --git a/app/models/color_scheme.rb b/app/models/color_scheme.rb index 434765bef00..526b2a0aaf7 100644 --- a/app/models/color_scheme.rb +++ b/app/models/color_scheme.rb @@ -4,6 +4,8 @@ require_dependency 'distributed_cache' class ColorScheme < ActiveRecord::Base + # rubocop:disable Layout/AlignHash + CUSTOM_SCHEMES = { 'Dark': { "primary" => 'dddddd', @@ -97,8 +99,11 @@ class ColorScheme < ActiveRecord::Base } } + # rubocop:enable Layout/AlignHash + def self.base_color_scheme_colors base_with_hash = {} + base_colors.each do |name, color| base_with_hash[name] = "#{color}" end @@ -110,6 +115,7 @@ class ColorScheme < ActiveRecord::Base CUSTOM_SCHEMES.each do |k, v| list.push(id: k.to_s, colors: v) end + list end @@ -208,6 +214,7 @@ class ColorScheme < ActiveRecord::Base def colors_by_name @colors_by_name ||= self.colors.inject({}) { |sum, c| sum[c.name] = c; sum; } end + def clear_colors_cache @colors_by_name = nil end diff --git a/app/models/post_action.rb b/app/models/post_action.rb index 8442b196b4f..8efa750b536 100644 --- a/app/models/post_action.rb +++ b/app/models/post_action.rb @@ -435,12 +435,12 @@ class PostAction < ActiveRecord::Base before_create do post_action_type_ids = is_flag? ? PostActionType.notify_flag_types.values : post_action_type_id raise AlreadyActed if PostAction.where(user_id: user_id) - .where(post_id: post_id) - .where(post_action_type_id: post_action_type_ids) - .where(deleted_at: nil) - .where(disagreed_at: nil) - .where(targets_topic: targets_topic) - .exists? + .where(post_id: post_id) + .where(post_action_type_id: post_action_type_ids) + .where(deleted_at: nil) + .where(disagreed_at: nil) + .where(targets_topic: targets_topic) + .exists? end # Returns the flag counts for a post, taking into account that some users diff --git a/app/models/tag_user.rb b/app/models/tag_user.rb index bee895bfe0e..b0697fa30d8 100644 --- a/app/models/tag_user.rb +++ b/app/models/tag_user.rb @@ -113,12 +113,11 @@ class TagUser < ActiveRecord::Base builder.exec(watching: notification_levels[:watching], tracking: notification_levels[:tracking], regular: notification_levels[:regular], - auto_watch_tag: TopicUser.notification_reasons[:auto_watch_tag]) + auto_watch_tag: TopicUser.notification_reasons[:auto_watch_tag]) end def self.auto_track(opts) - builder = DB.build <<~SQL UPDATE topic_users SET notification_level = :tracking, notifications_reason_id = :auto_track_tag @@ -147,7 +146,7 @@ class TagUser < ActiveRecord::Base builder.exec(tracking: notification_levels[:tracking], regular: notification_levels[:regular], - auto_track_tag: TopicUser.notification_reasons[:auto_track_tag]) + auto_track_tag: TopicUser.notification_reasons[:auto_track_tag]) end end diff --git a/app/models/user.rb b/app/models/user.rb index 96908e4755a..464740d4b47 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -478,7 +478,7 @@ class User < ActiveRecord::Base DB.query_single(sql, user_id: id, seen_notification_id: seen_notification_id, - pm: Notification.types[:private_message], + pm: Notification.types[:private_message], limit: User.max_unread_notifications )[0].to_i end diff --git a/app/services/push_notification_pusher.rb b/app/services/push_notification_pusher.rb index 2e39eb9cac9..d397e13039e 100644 --- a/app/services/push_notification_pusher.rb +++ b/app/services/push_notification_pusher.rb @@ -49,7 +49,7 @@ class PushNotificationPusher title: I18n.t("discourse_push_notifications.popup.confirm_title", site_title: SiteSetting.title), body: I18n.t("discourse_push_notifications.popup.confirm_body"), - icon: ActionController::Base.helpers.image_url("push-notifications/check.png"), + icon: ActionController::Base.helpers.image_url("push-notifications/check.png"), badge: get_badge, tag: "#{Discourse.current_hostname}-subscription" } diff --git a/config/boot.rb b/config/boot.rb index ba9f61acee3..97806eac15a 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -19,12 +19,12 @@ if ENV['RAILS_ENV'] != 'production' && ENV['RAILS_ENV'] != 'profile' if defined? Bootsnap Bootsnap.setup( - cache_dir: 'tmp/cache', # Path to your cache - load_path_cache: true, # Should we optimize the LOAD_PATH with a cache? - autoload_paths_cache: true, # Should we optimize ActiveSupport autoloads with cache? - disable_trace: false, # Sets `RubyVM::InstructionSequence.compile_option = { trace_instruction: false }` - compile_cache_iseq: true, # Should compile Ruby code into ISeq cache? - compile_cache_yaml: false # Skip YAML cache for now, cause we were seeing issues with it + cache_dir: 'tmp/cache', # Path to your cache + load_path_cache: true, # Should we optimize the LOAD_PATH with a cache? + autoload_paths_cache: true, # Should we optimize ActiveSupport autoloads with cache? + disable_trace: false, # Sets `RubyVM::InstructionSequence.compile_option = { trace_instruction: false }` + compile_cache_iseq: true, # Should compile Ruby code into ISeq cache? + compile_cache_yaml: false # Skip YAML cache for now, cause we were seeing issues with it ) end end diff --git a/config/environments/production.rb b/config/environments/production.rb index c6b0d6eb84b..c12ed4eaa85 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -24,12 +24,12 @@ Discourse::Application.configure do if GlobalSetting.smtp_address settings = { - address: GlobalSetting.smtp_address, - port: GlobalSetting.smtp_port, - domain: GlobalSetting.smtp_domain, - user_name: GlobalSetting.smtp_user_name, - password: GlobalSetting.smtp_password, - authentication: GlobalSetting.smtp_authentication, + address: GlobalSetting.smtp_address, + port: GlobalSetting.smtp_port, + domain: GlobalSetting.smtp_domain, + user_name: GlobalSetting.smtp_user_name, + password: GlobalSetting.smtp_password, + authentication: GlobalSetting.smtp_authentication, enable_starttls_auto: GlobalSetting.smtp_enable_start_tls } diff --git a/lib/html_prettify.rb b/lib/html_prettify.rb index df91d767d32..0b940664172 100644 --- a/lib/html_prettify.rb +++ b/lib/html_prettify.rb @@ -366,17 +366,17 @@ class HtmlPrettify < String def default_entities { - single_left_quote: "‘", - double_left_quote: "“", - single_right_quote: "’", - double_right_quote: "”", - em_dash: "—", - en_dash: "–", - ellipsis: "…", - html_quote: """, - frac12: "½", - frac14: "¼", - frac34: "¾", + single_left_quote: "‘", + double_left_quote: "“", + single_right_quote: "’", + double_right_quote: "”", + em_dash: "—", + en_dash: "–", + ellipsis: "…", + html_quote: """, + frac12: "½", + frac14: "¼", + frac34: "¾", } end diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake index 617f473c9b6..e80e9015377 100644 --- a/lib/tasks/auto_annotate_models.rake +++ b/lib/tasks/auto_annotate_models.rake @@ -5,30 +5,32 @@ if (Rails.env.development? || Rails.env.test?) task :set_annotation_options do # You can override any of these by setting an environment variable of the # same name. - Annotate.set_defaults('position_in_routes' => "before", - 'position_in_class' => "after", - 'position_in_test' => "before", - 'position_in_fixture' => "before", - 'position_in_factory' => "before", - 'show_indexes' => "true", - 'simple_indexes' => "false", - 'model_dir' => "app/models", - 'include_version' => "false", - 'require' => "", - 'exclude_tests' => "true", - 'exclude_fixtures' => "true", - 'exclude_helpers' => "true", - 'exclude_factories' => "true", - 'exclude_serializers' => "true", - 'exclude_controllers' => "true", - 'ignore_model_sub_dir' => "false", - 'skip_on_db_migrate' => "true", - 'format_bare' => "true", - 'format_rdoc' => "false", - 'format_markdown' => "false", - 'sort' => "false", - 'force' => "false", - 'trace' => "false") + Annotate.set_defaults( + 'position_in_routes' => "before", + 'position_in_class' => "after", + 'position_in_test' => "before", + 'position_in_fixture' => "before", + 'position_in_factory' => "before", + 'show_indexes' => "true", + 'simple_indexes' => "false", + 'model_dir' => "app/models", + 'include_version' => "false", + 'require' => "", + 'exclude_tests' => "true", + 'exclude_fixtures' => "true", + 'exclude_helpers' => "true", + 'exclude_factories' => "true", + 'exclude_serializers' => "true", + 'exclude_controllers' => "true", + 'ignore_model_sub_dir' => "false", + 'skip_on_db_migrate' => "true", + 'format_bare' => "true", + 'format_rdoc' => "false", + 'format_markdown' => "false", + 'sort' => "false", + 'force' => "false", + 'trace' => "false" + ) end end diff --git a/plugins/poll/spec/db/post_migrate/migrate_polls_data_spec.rb b/plugins/poll/spec/db/post_migrate/migrate_polls_data_spec.rb index 829b0489364..3d4bbc5a6e7 100644 --- a/plugins/poll/spec/db/post_migrate/migrate_polls_data_spec.rb +++ b/plugins/poll/spec/db/post_migrate/migrate_polls_data_spec.rb @@ -219,7 +219,7 @@ RSpec.describe MigratePollsData do "type" => "regular" }, "poll" => { - "options" => [ + "options" => [ { "id" => "edeee5dae4802ab24185d41039efb545", "html" => "Yes", diff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rb index 9401fc16fd5..5fa8e964ca5 100644 --- a/script/bulk_import/base.rb +++ b/script/bulk_import/base.rb @@ -14,6 +14,8 @@ class BulkImport::Base NOW ||= "now()".freeze PRIVATE_OFFSET ||= 2**30 + # rubocop:disable Layout/AlignHash + CHARSET_MAP = { "armscii8" => nil, "ascii" => Encoding::US_ASCII, @@ -53,6 +55,8 @@ class BulkImport::Base "utf8" => Encoding::UTF_8, } + # rubocop:enable Layout/AlignHash + def initialize charset = ENV["DB_CHARSET"] || "utf8" db = ActiveRecord::Base.connection_config diff --git a/script/import_scripts/askbot.rb b/script/import_scripts/askbot.rb index 5620f0aa294..90638d889d6 100644 --- a/script/import_scripts/askbot.rb +++ b/script/import_scripts/askbot.rb @@ -114,15 +114,15 @@ class ImportScripts::MyAskBot < ImportScripts::Base create_users(users, total: total_count, offset: offset) do |user| { - id: user["id"], - username: user["username"], - email: user["email"] || (SecureRandom.hex << "@domain.com"), - admin: user["is_staff"], - created_at: Time.zone.at(@td.decode(user["date_joined"])), + id: user["id"], + username: user["username"], + email: user["email"] || (SecureRandom.hex << "@domain.com"), + admin: user["is_staff"], + created_at: Time.zone.at(@td.decode(user["date_joined"])), last_seen_at: Time.zone.at(@td.decode(user["last_seen"])), - name: user["real_name"], - website: user["website"], - location: user["location"], + name: user["real_name"], + website: user["website"], + location: user["location"], } end end diff --git a/script/import_scripts/lithium.rb b/script/import_scripts/lithium.rb index 2296d71a1fa..9398a6e8c71 100644 --- a/script/import_scripts/lithium.rb +++ b/script/import_scripts/lithium.rb @@ -322,7 +322,7 @@ class ImportScripts::Lithium < ImportScripts::Base create_categories(parent_categories) do |category| { id: category["node_id"], - name: category["name"], + name: category["name"], position: category["position"], post_create_action: lambda do |record| after_category_create(record, category) diff --git a/script/import_scripts/nabble.rb b/script/import_scripts/nabble.rb index 8f371da4e80..3d0445c85a3 100644 --- a/script/import_scripts/nabble.rb +++ b/script/import_scripts/nabble.rb @@ -77,10 +77,10 @@ class ImportScripts::Nabble < ImportScripts::Base create_users(users, total: total_count, offset: offset) do |row| { - id: row["user_id"], - email: row["email"] || (SecureRandom.hex << "@domain.com"), - created_at: Time.zone.at(@td.decode(row["joined"])), - name: row["name"], + id: row["user_id"], + email: row["email"] || (SecureRandom.hex << "@domain.com"), + created_at: Time.zone.at(@td.decode(row["joined"])), + name: row["name"], post_create_action: proc do |user| import_avatar(user, row["user_id"]) end @@ -151,13 +151,15 @@ class ImportScripts::Nabble < ImportScripts::Base raw = process_content(raw) raw = process_attachments(raw, t['node_id']) - { id: t['node_id'], + { + id: t['node_id'], title: t['subject'], user_id: user_id_from_imported_user_id(t["owner_id"]) || Discourse::SYSTEM_USER_ID, created_at: Time.zone.at(@td.decode(t["when_created"])), category: CATEGORY_ID, raw: raw, - cook_method: Post.cook_methods[:regular] } + cook_method: Post.cook_methods[:regular] + } end end end diff --git a/script/test_email_settings.rb b/script/test_email_settings.rb index 102f5afe7e9..3a8e0f6b5f2 100755 --- a/script/test_email_settings.rb +++ b/script/test_email_settings.rb @@ -20,10 +20,11 @@ MAILTO = YOUR_EMAIL ### You shouldn't need to change anything below here $delivery_options = { user_name: @DISCOURSE_SMTP_USER_NAME || nil, - password: @DISCOURSE_SMTP_PASSWORD || nil, - address: DISCOURSE_SMTP_ADDRESS, - port: @DISCOURSE_SMTP_PORT || nil, - openssl_verify_mode: @DISCOURSE_SMTP_OPENSSL_VERIFY_MODE || nil } + password: @DISCOURSE_SMTP_PASSWORD || nil, + address: DISCOURSE_SMTP_ADDRESS, + port: @DISCOURSE_SMTP_PORT || nil, + openssl_verify_mode: @DISCOURSE_SMTP_OPENSSL_VERIFY_MODE || nil +} class EmailTestMailer < ActionMailer::Base def email_test(mailfrom, mailto) diff --git a/spec/components/js_locale_helper_spec.rb b/spec/components/js_locale_helper_spec.rb index 430a372504c..91dae20e50a 100644 --- a/spec/components/js_locale_helper_spec.rb +++ b/spec/components/js_locale_helper_spec.rb @@ -121,42 +121,42 @@ describe JsLocaleHelper do end it 'performs fallbacks to english if a translation is not available' do - JsLocaleHelper.set_translations('en', "en" => { + JsLocaleHelper.set_translations('en', "en" => { "js" => { - "only_english" => "1-en", - "english_and_site" => "3-en", - "english_and_user" => "5-en", - "all_three" => "7-en", + "only_english" => "1-en", + "english_and_site" => "3-en", + "english_and_user" => "5-en", + "all_three" => "7-en", } }) - JsLocaleHelper.set_translations('ru', "ru" => { + JsLocaleHelper.set_translations('ru', "ru" => { "js" => { - "only_site" => "2-ru", - "english_and_site" => "3-ru", - "site_and_user" => "6-ru", - "all_three" => "7-ru", + "only_site" => "2-ru", + "english_and_site" => "3-ru", + "site_and_user" => "6-ru", + "all_three" => "7-ru", } }) - JsLocaleHelper.set_translations('uk', "uk" => { + JsLocaleHelper.set_translations('uk', "uk" => { "js" => { - "only_user" => "4-uk", - "english_and_user" => "5-uk", - "site_and_user" => "6-uk", - "all_three" => "7-uk", + "only_user" => "4-uk", + "english_and_user" => "5-uk", + "site_and_user" => "6-uk", + "all_three" => "7-uk", } }) expected = { - "none" => "[uk.js.none]", - "only_english" => "1-en", - "only_site" => "2-ru", - "english_and_site" => "3-ru", - "only_user" => "4-uk", - "english_and_user" => "5-uk", - "site_and_user" => "6-uk", - "all_three" => "7-uk", + "none" => "[uk.js.none]", + "only_english" => "1-en", + "only_site" => "2-ru", + "english_and_site" => "3-ru", + "only_user" => "4-uk", + "english_and_user" => "5-uk", + "site_and_user" => "6-uk", + "all_three" => "7-uk", } SiteSetting.default_locale = 'ru' diff --git a/spec/requests/webhooks_controller_spec.rb b/spec/requests/webhooks_controller_spec.rb index ec94b939423..0162b0a849b 100644 --- a/spec/requests/webhooks_controller_spec.rb +++ b/spec/requests/webhooks_controller_spec.rb @@ -43,10 +43,10 @@ describe WebhooksController do post "/webhooks/sendgrid.json", params: { "_json" => [ { - "email" => email, + "email" => email, "smtp-id" => "<12345@il.com>", - "event" => "bounce", - "status" => "5.0.0" + "event" => "bounce", + "status" => "5.0.0" } ] } @@ -66,9 +66,9 @@ describe WebhooksController do post "/webhooks/mailjet.json", params: { "event" => "bounce", - "email" => email, + "email" => email, "hard_bounce" => true, - "CustomID" => message_id + "CustomID" => message_id } expect(response.status).to eq(200)