Add rubocop to our build. (#5004)

This commit is contained in:
Guo Xiang Tan
2017-07-28 10:20:09 +09:00
committed by GitHub
parent ff4e295c4f
commit 5012d46cbd
871 changed files with 5480 additions and 6056 deletions

View File

@@ -30,7 +30,7 @@ ColumnDropper.drop(
table: 'categories',
after_migration: 'AddUploadsToCategories',
columns: ['logo_url', 'background_url'],
on_drop: ->(){
on_drop: ->() {
STDERR.puts 'Removing superflous categories columns!'
}
)

View File

@@ -9,7 +9,7 @@ ColumnDropper.drop(
table: 'groups',
after_migration: 'AddVisibleBackToGroups',
columns: %w[visible],
on_drop: ->(){
on_drop: ->() {
STDERR.puts 'Removing superflous visible group column!'
}
)

View File

@@ -142,9 +142,9 @@ Badge.seed do |b|
end
[
[Badge::Promoter,"Promoter",BadgeType::Bronze,1,0],
[Badge::Campaigner,"Campaigner",BadgeType::Silver,3,1],
[Badge::Champion,"Champion",BadgeType::Gold,5,2],
[Badge::Promoter, "Promoter", BadgeType::Bronze, 1, 0],
[Badge::Campaigner, "Campaigner", BadgeType::Silver, 3, 1],
[Badge::Champion, "Champion", BadgeType::Gold, 5, 2],
].each do |id, name, type, count, trust_level|
Badge.seed do |b|
b.id = id
@@ -154,7 +154,7 @@ end
b.multiple_grant = false
b.target_posts = false
b.show_posts = false
b.query = BadgeQueries.invite_badge(count,trust_level)
b.query = BadgeQueries.invite_badge(count, trust_level)
b.default_badge_grouping_id = BadgeGrouping::Community
# daily is good enough
b.trigger = Badge::Trigger::None
@@ -307,7 +307,6 @@ end
end
end
[
[Badge::ThankYou, "Thank You", BadgeType::Bronze, 20, 10],
[Badge::GivesBack, "Gives Back", BadgeType::Silver, 100, 100],

View File

@@ -33,7 +33,6 @@ UserOption.where(user_id: -1).update_all(
Group.user_trust_level_change!(-1, TrustLevel[4])
ColumnDropper.drop(
table: 'users',
after_migration: 'AddUserAuthTokens',
@@ -55,7 +54,7 @@ ColumnDropper.drop(
last_redirected_to_top_at
auth_token
auth_token_updated_at ],
on_drop: ->(){
on_drop: ->() {
STDERR.puts 'Removing superflous users columns!'
}
)

View File

@@ -17,7 +17,7 @@ unless Rails.env.test?
raise "Failed meta topic"
end
meta.set_permissions(:everyone => :full)
meta.set_permissions(everyone: :full)
meta.topic_id = post.topic.id
unless meta.save
puts meta.errors.full_messages

View File

@@ -1,6 +1,6 @@
unless Rails.env.test?
staff = Category.find_by(id: SiteSetting.staff_category_id)
if staff and !staff.group_ids.include?(Group[:staff].id)
if staff && !staff.group_ids.include?(Group[:staff].id)
# Add permissions and a description to the Staff category.

View File

@@ -7,13 +7,13 @@ if !Theme.exists?
dark_scheme ||= ColorScheme.create_from_base(name: name, via_wizard: true, base_scheme_id: "dark")
name = I18n.t('color_schemes.dark_theme_name')
_dark_theme = Theme.create(name: name, user_id: -1,
color_scheme_id: dark_scheme.id,
user_selectable: true)
_dark_theme = Theme.create(name: name, user_id: -1,
color_scheme_id: dark_scheme.id,
user_selectable: true)
name = I18n.t('color_schemes.default_theme_name')
default_theme = Theme.create(name: name, user_id: -1,
user_selectable: true)
default_theme = Theme.create(name: name, user_id: -1,
user_selectable: true)
default_theme.set_default!
end
@@ -22,7 +22,7 @@ ColumnDropper.drop(
table: 'theme_fields',
after_migration: 'AddUploadIdToThemeFields',
columns: ['target'],
on_drop: ->(){
on_drop: ->() {
STDERR.puts 'Removing superflous theme_fields target column!'
}
)

View File

@@ -6,7 +6,7 @@ TableMigrationHelper.delayed_drop(
old_name: 'topic_status_updates',
new_name: 'topic_timers',
after_migration: 'RenameTopicStatusUpdatesToTopicTimers',
on_drop: ->(){
on_drop: ->() {
STDERR.puts "Dropping topic_status_updates. It was moved to topic_timers."
}
)

View File

@@ -6,9 +6,9 @@ staff = Category.find_by(id: SiteSetting.staff_category_id)
seed_welcome_topics = (Topic.where('id NOT IN (SELECT topic_id from categories where topic_id is not null)').count == 0 && !Rails.env.test?)
unless Rails.env.test?
def create_static_page_topic(site_setting_key, title_key, body_key, body_override, category, description, params={})
def create_static_page_topic(site_setting_key, title_key, body_key, body_override, category, description, params = {})
unless SiteSetting.send(site_setting_key) > 0
creator = PostCreator.new( Discourse.system_user,
creator = PostCreator.new(Discourse.system_user,
title: I18n.t(title_key, default: I18n.t(title_key, locale: :en)),
raw: body_override.present? ? body_override : I18n.t(body_key, params.merge(default: I18n.t(body_key, params.merge(locale: :en)))),
skip_validations: true,
@@ -19,18 +19,16 @@ unless Rails.env.test?
SiteSetting.send("#{site_setting_key}=", post.topic_id)
_reply = PostCreator.create( Discourse.system_user,
_reply = PostCreator.create(Discourse.system_user,
raw: I18n.t('static_topic_first_reply', page_name: I18n.t(title_key, default: I18n.t(title_key, locale: :en))),
skip_validations: true,
topic_id: post.topic_id )
topic_id: post.topic_id)
end
end
create_static_page_topic('tos_topic_id', 'tos_topic.title', "tos_topic.body", nil, staff, "terms of service", {
company_domain: "company_domain",
company_full_name: "company_full_name",
company_name: "company_short_name"
})
create_static_page_topic('tos_topic_id', 'tos_topic.title', "tos_topic.body", nil, staff, "terms of service", company_domain: "company_domain",
company_full_name: "company_full_name",
company_name: "company_short_name")
create_static_page_topic('guidelines_topic_id', 'guidelines_topic.title', "guidelines_topic.body", nil, staff, "guidelines")
@@ -57,15 +55,13 @@ if seed_welcome_topics
end
welcome = File.read(filename)
PostCreator.create( Discourse.system_user,
PostCreator.create(Discourse.system_user,
raw: welcome,
title: DiscoursePluginRegistry.seed_data["admin_quick_start_title"] || "READ ME FIRST: Admin Quick Start Guide",
skip_validations: true,
category: staff ? staff.name : nil)
end
# run this later, cause we need to make sure new application controller resilience is in place first
ColumnDropper.drop(
@@ -74,7 +70,7 @@ ColumnDropper.drop(
columns: %w{
first_topic_unread_at
},
on_drop: ->(){
on_drop: ->() {
STDERR.puts "Removing superflous user stats columns!"
ActiveRecord::Base.exec_sql "DROP FUNCTION IF EXISTS first_unread_topic_for(int)"
}
@@ -91,7 +87,7 @@ ColumnDropper.drop(
notify_user_count
last_unread_at
},
on_drop: ->(){
on_drop: ->() {
STDERR.puts "Removing superflous topic columns!"
}
)
@@ -106,7 +102,7 @@ ColumnDropper.drop(
auto_close_based_on_last_post
auto_close_hours
},
on_drop: ->(){
on_drop: ->() {
STDERR.puts "Removing superflous topic columns!"
},
delay: 3600