Skip to content

Commit

Permalink
Merge pull request #46596 from code-dot-org/revert-46289-rubocop-1.28…
Browse files Browse the repository at this point in the history
…-fix-rails

Revert "auto-correct rubocop Rails violations"
  • Loading branch information
Hamms committed May 31, 2022
2 parents 49af967 + afee9e7 commit ce04eaa
Show file tree
Hide file tree
Showing 123 changed files with 342 additions and 231 deletions.
123 changes: 115 additions & 8 deletions .rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 0`
# on 2022-05-10 22:36:19 UTC using RuboCop version 1.28.0.
# on 2022-05-10 21:50:31 UTC using RuboCop version 1.28.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -41,7 +41,7 @@ Layout/HashAlignment:
Layout/LineEndStringConcatenationIndentation:
Enabled: false

# Offense count: 464
# Offense count: 465
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Expand Down Expand Up @@ -70,7 +70,7 @@ Layout/SpaceAroundEqualsInParameterDefault:
Layout/SpaceInsideBlockBraces:
Enabled: false

# Offense count: 97
# Offense count: 116
# Configuration parameters: IgnoredMethods.
Lint/AmbiguousBlockAssociation:
Enabled: false
Expand Down Expand Up @@ -211,6 +211,18 @@ Lint/UselessAssignment:
Lint/UselessMethodDefinition:
Enabled: false

# Offense count: 2
# This cop supports safe auto-correction (--auto-correct).
Migration/DepartmentName:
Enabled: false

# Offense count: 9
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: lowercase, uppercase
Naming/HeredocDelimiterCase:
Enabled: false

# Offense count: 41
# Configuration parameters: ForbiddenDelimiters.
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
Expand Down Expand Up @@ -242,6 +254,11 @@ Naming/RescuedExceptionsVariableName:
Naming/VariableNumber:
Enabled: false

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
Performance/BlockGivenWithExplicitBlock:
Enabled: false

# Offense count: 20
# This cop supports unsafe auto-correction (--auto-correct-all).
Performance/Casecmp:
Expand All @@ -252,6 +269,16 @@ Performance/Casecmp:
Performance/CollectionLiteralInLoop:
Enabled: false

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
Performance/ConcurrentMonotonicTime:
Enabled: false

# Offense count: 8
# This cop supports safe auto-correction (--auto-correct).
Performance/ConstantRegexp:
Enabled: false

# Offense count: 5
# This cop supports safe auto-correction (--auto-correct).
Performance/Count:
Expand All @@ -276,11 +303,31 @@ Performance/MethodObjectAsBlock:
Performance/RedundantEqualityComparisonBlock:
Enabled: false

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
Performance/RedundantStringChars:
Enabled: false

# Offense count: 56
# This cop supports safe auto-correction (--auto-correct).
Performance/RegexpMatch:
Enabled: false

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
Performance/ReverseEach:
Enabled: false

# Offense count: 5
# This cop supports safe auto-correction (--auto-correct).
Performance/Squeeze:
Enabled: false

# Offense count: 5
# This cop supports safe auto-correction (--auto-correct).
Performance/StringIdentifierArgument:
Enabled: false

# Offense count: 31
# This cop supports safe auto-correction (--auto-correct).
Performance/StringInclude:
Expand Down Expand Up @@ -317,7 +364,19 @@ Rails/ApplicationMailer:
Rails/ApplicationRecord:
Enabled: false

# Offense count: 86
# Offense count: 22
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: Include.
# Include: **/test/**/*
Rails/AssertNot:
Enabled: false

# Offense count: 11
# This cop supports safe auto-correction (--auto-correct).
Rails/BelongsTo:
Enabled: false

# Offense count: 85
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent.
Rails/Blank:
Expand All @@ -333,6 +392,11 @@ Rails/Date:
Rails/DeprecatedActiveModelErrorsMethods:
Enabled: false

# Offense count: 11
# This cop supports safe auto-correction (--auto-correct).
Rails/DurationArithmetic:
Enabled: false

# Offense count: 520
# This cop supports unsafe auto-correction (--auto-correct-all).
# Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers.
Expand All @@ -348,10 +412,32 @@ Rails/DynamicFindBy:
Rails/FilePath:
Enabled: false

# Offense count: 3
# This cop supports safe auto-correction (--auto-correct).
Rails/FindById:
Enabled: false

# Offense count: 30
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: numeric, symbolic
Rails/HttpStatus:
Enabled: false

# Offense count: 90
Rails/I18nLocaleTexts:
Enabled: false

# Offense count: 3
# This cop supports safe auto-correction (--auto-correct).
Rails/IndexBy:
Enabled: false

# Offense count: 17
# This cop supports safe auto-correction (--auto-correct).
Rails/IndexWith:
Enabled: false

# Offense count: 37
# This cop supports unsafe auto-correction (--auto-correct-all).
Rails/NegateInclude:
Expand All @@ -373,13 +459,29 @@ Rails/OutputSafety:
Rails/Pick:
Enabled: false

# Offense count: 59
# This cop supports safe auto-correction (--auto-correct).
Rails/Pluck:
Enabled: false

# Offense count: 44
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank.
Rails/Present:
Enabled: false

# Offense count: 85
# This cop supports unsafe auto-correction (--auto-correct-all).
# Configuration parameters: Include.
# Include: **/Rakefile, **/*.rake
Rails/RakeEnvironment:
Enabled: false

# Offense count: 9
# This cop supports safe auto-correction (--auto-correct).
Rails/RedundantForeignKey:
Enabled: false

# Offense count: 16
# This cop supports safe auto-correction (--auto-correct).
Rails/RedundantPresenceValidationOnBelongsTo:
Expand Down Expand Up @@ -432,6 +534,11 @@ Rails/WhereEquals:
Rails/WhereExists:
Enabled: false

# Offense count: 8
# This cop supports safe auto-correction (--auto-correct).
Rails/WhereNot:
Enabled: false

# Offense count: 57
# This cop supports unsafe auto-correction (--auto-correct-all).
Security/IoMethods:
Expand Down Expand Up @@ -495,7 +602,7 @@ Style/ClassVars:
Style/CollectionCompact:
Enabled: false

# Offense count: 182
# Offense count: 184
# This cop supports unsafe auto-correction (--auto-correct-all).
# Configuration parameters: PreferredMethods, MethodsAcceptingSymbol.
# MethodsAcceptingSymbol: inject, reduce
Expand Down Expand Up @@ -590,7 +697,7 @@ Style/GlobalVars:
Style/HashAsLastArrayItem:
Enabled: false

# Offense count: 19
# Offense count: 23
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowSplatArgument.
Style/HashConversion:
Expand Down Expand Up @@ -624,7 +731,7 @@ Style/HashTransformValues:
Style/IfWithBooleanLiteralBranches:
Enabled: false

# Offense count: 23
# Offense count: 24
# This cop supports unsafe auto-correction (--auto-correct-all).
# Configuration parameters: InverseMethods, InverseBlocks.
Style/InverseMethods:
Expand Down Expand Up @@ -722,7 +829,7 @@ Style/RedundantFileExtensionInRequire:
Style/RedundantInitialize:
Enabled: false

# Offense count: 58
# Offense count: 61
# This cop supports safe auto-correction (--auto-correct).
Style/RedundantParentheses:
Enabled: false
Expand Down
2 changes: 1 addition & 1 deletion bin/cron/create_rollup_tables
Expand Up @@ -113,7 +113,7 @@ def main
end
end

contained_levels.pluck(:contained_level_id).each do |contained_level_id|
contained_levels.map {|row| row[:contained_level_id]}.each do |contained_level_id|
LevelSource.
where(level_id: contained_level_id).
find_each do |level_source|
Expand Down
12 changes: 6 additions & 6 deletions bin/cron/mysql-metrics
Expand Up @@ -60,9 +60,9 @@ const_keys = %w(
Threads_running
)

constants = const_keys.index_with do |key|
status[key]
end
constants = const_keys.map do |key|
[key, status[key]]
end.to_h

counter = 'Uptime_since_flush_status'
exit 0 unless status[counter] && old_status[counter]
Expand Down Expand Up @@ -319,9 +319,9 @@ interval_keys = %w(
Tc_log_page_waits
)

intervals = interval_keys.index_with do |key|
(status[key].to_i - old_status[key].to_i)
end
intervals = interval_keys.map do |key|
[key, (status[key].to_i - old_status[key].to_i)]
end.to_h

innodb_status = PEGASUS_DB.fetch('SHOW ENGINE INNODB STATUS').first[:Status]

Expand Down
4 changes: 3 additions & 1 deletion bin/i18n/sync-in.rb
Expand Up @@ -412,7 +412,9 @@ def select_redactable(i18n_strings)
contained_levels = i18n_strings["contained levels"].map do |contained_level|
select_redactable(contained_level)
end
contained_levels.select!(&:present?)
contained_levels.select! do |result|
!result.blank?
end
redactable["contained levels"] = contained_levels unless contained_levels.empty?
end

Expand Down
2 changes: 1 addition & 1 deletion bin/i18n/sync-out.rb
Expand Up @@ -276,7 +276,7 @@ def serialize_i18n_strings(level, strings)

if strings.key? "contained levels"
contained_strings = strings.delete("contained levels")
if contained_strings.present?
unless contained_strings.blank?
level.contained_levels.zip(contained_strings).each do |contained_level, contained_string|
result.deep_merge! serialize_i18n_strings(contained_level, contained_string)
end
Expand Down
2 changes: 1 addition & 1 deletion bin/i18n/translation_status/translation_status_service.rb
Expand Up @@ -25,7 +25,7 @@ def initialize
# @param [TranslationService] translation_service Get information about translations.
def update_translation_status(
day_count = 7,
locales = Languages.get_locale.pluck(:locale_s),
locales = Languages.get_locale.map {|lang| lang[:locale_s]},
current_time = Time.now.utc.strftime("%Y-%m-%d %H:%M:%S"),
redshift_client = RedshiftClient.instance,
translation_service = TranslationService.new
Expand Down
2 changes: 1 addition & 1 deletion bin/oneoff/data_fix/assign_missing_names
Expand Up @@ -56,7 +56,7 @@ nameless_ids.each do |user_id|
print "#{user_id}: "
user = User.find(user_id)

if user.name.present?
unless user.name.blank?
puts "skipping - name not blank"
next
end
Expand Down
2 changes: 1 addition & 1 deletion bin/oneoff/normalize_gender
Expand Up @@ -22,6 +22,6 @@ end_index = ARGV[1].to_i

User.with_deleted.
where(id: start_index..end_index).
where.not(gender: nil).
where('gender IS NOT NULL').
where('gender != "-" AND gender != "f" AND gender != "m"').
update_all(gender: nil)
2 changes: 1 addition & 1 deletion bin/oneoff/wipe_data/poste_deliveries_and_contacts_emails
Expand Up @@ -13,7 +13,7 @@ puts 'Populating hashed_email_to_birthday...'
hashed_email_to_birthday = {}
DASHBOARD_DB[:users].
where(user_type: 'student').
where.not(hashed_email: nil).
where('hashed_email IS NOT NULL').
paged_each(rows_per_fetch: 10_000) do |user|
hashed_email_to_birthday[user[:hashed_email]] = user[:birthday].strftime('%F')
end
Expand Down
2 changes: 1 addition & 1 deletion bin/oneoff/wipe_data/young_emails
Expand Up @@ -54,7 +54,7 @@ def wipe_emails_from_poste_deliveries(contact_ids)
PEGASUS_DB.transaction do
contact_ids_slice.each do |contact_id|
PEGASUS_DB[:poste_deliveries].where(contact_id: contact_id).
where.not(sent_at: nil).
where('sent_at IS NOT NULL').
update(contact_email: '')
end
end
Expand Down
6 changes: 3 additions & 3 deletions cookbooks/cdo-varnish/libraries/http_cache.rb
Expand Up @@ -50,10 +50,10 @@ class HttpCache
hello-world-retro-2021
hello-world-emoji-2021
outbreak
).index_with do |script_name|
).map do |script_name|
# Most scripts use the default route pattern.
"/s/#{script_name}/lessons/*"
end.merge(
[script_name, "/s/#{script_name}/lessons/*"]
end.to_h.merge(
# Add the "special case" routes here.
'hourofcode' => '/hoc/*',
'flappy' => '/flappy/*'
Expand Down
4 changes: 2 additions & 2 deletions dashboard/app/controllers/activities_controller.rb
Expand Up @@ -44,7 +44,7 @@ def milestone
# - post_milestone is true, AND (we post on failed runs, or this was successful), or
# - this is the final level in the script - we always post on final level
unless (post_milestone && (post_failed_run_milestone || solved)) || final_level
head :service_unavailable
head 503
return
end

Expand Down Expand Up @@ -98,7 +98,7 @@ def milestone
nonsubmitted_lockable = user_level.nil? && @script_level.end_of_lesson?
# we have a lockable lesson, and user_level is locked. disallow milestone requests
if nonsubmitted_lockable || user_level.try(:show_as_locked?, @script_level.lesson) || user_level.try(:readonly_answers?)
return head :forbidden
return head 403
end
end

Expand Down
4 changes: 2 additions & 2 deletions dashboard/app/controllers/admin_reports_controller.rb
Expand Up @@ -128,7 +128,7 @@ def pd_progress
render(
layout: 'application',
html: "Script #{script_id_or_name} not found.",
status: :not_found
status: 404
) && return
end

Expand All @@ -143,7 +143,7 @@ def pd_progress
render(
layout: 'application',
html: "PD progress data not found for #{sanitized_script_name}.",
status: :not_found
status: 404
)
end
end
Expand Down

0 comments on commit ce04eaa

Please sign in to comment.