Skip to content

Commit

Permalink
Upgrade Rubocop to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
harigopal committed Jan 23, 2020
1 parent 29afcf4 commit 02d6525
Show file tree
Hide file tree
Showing 20 changed files with 45 additions and 55 deletions.
18 changes: 10 additions & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Style/FormatStringToken:
Enabled: false
Style/DoubleNegation:
Enabled: false
Layout/AlignParameters:
Layout/ParameterAlignment:
EnforcedStyle: with_fixed_indentation
Layout/AlignArguments:
Layout/ArgumentAlignment:
EnforcedStyle: with_fixed_indentation
Layout/MultilineOperationIndentation:
EnforcedStyle: indented
Expand All @@ -40,6 +40,8 @@ Layout/CaseIndentation:
IndentOneStep: true
Layout/EndAlignment:
EnforcedStyleAlignWith: variable
Layout/LineLength:
Enabled: false
Naming/VariableNumber:
Enabled: false
Metrics/BlockLength:
Expand All @@ -48,8 +50,6 @@ Metrics/BlockLength:
- 'spec/**/*_spec.rb'
- 'config/**/*'
- 'spec/factories/*'
Metrics/LineLength:
Enabled: false
Lint/ShadowingOuterLocalVariable: # shadowing is a language feature - we should use it where appropriate.
Enabled: false

Expand All @@ -61,10 +61,6 @@ Bundler/OrderedGems:
Enabled: false # we have a ton of gems, grouped arbitrarily. Could be tackled later.
Style/FrozenStringLiteralComment:
Enabled: false # forces addition of frozen string literal directive to all files. WTF.
StringLiterals:
Enabled: false
Documentation:
Enabled: false
Metrics/MethodLength:
Max: 20 # default was 10.
Metrics/ClassLength:
Expand All @@ -75,3 +71,9 @@ Style/GuardClause:
Enabled: false # this thing is annoying, and can lead to not-as-readable code.
Style/YodaCondition:
Enabled: false # buggy - sometimes complains about fixed code, and autocorrect doesn't work.
Style/StringLiterals:
Enabled: false
Style/Documentation:
Enabled: false
Layout/RescueEnsureAlignment:
Enabled: false # buggy
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ group :development, :test do
gem 'coderay', '~> 1.1' # Pretty syntax highlighting on rspec failure snippets.
gem 'pry-rails', '~> 0.3.5' # Pry debugger.
gem 'webmock', '~> 3.5' # Mocking web requests.
gem 'rubocop', '~> 0.74', require: false # Ruby Style Guide.
gem 'rubocop-rails', '~> 2.3', require: false # A RuboCop extension focused on enforcing Rails best practices and coding conventions.
gem 'rubocop', '~> 0.79', require: false # Ruby Style Guide.
gem 'rubocop-rails', '~> 2.4', require: false # A RuboCop extension focused on enforcing Rails best practices and coding conventions.
gem 'bundler-audit', '~> 0.5', require: false # Audit gems in gemfile.lock for reported vulnerabilities
gem 'overcommit', '~> 0.38', require: false # A fully configurable and extendable Git hook manager
gem 'fuubar', '~> 2.5' # The instafailing RSpec progress bar formatter.
Expand Down
20 changes: 10 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ GEM
iniparse (1.4.4)
insensitive_hash (0.3.3)
intercom (3.8.0)
jaro_winkler (1.5.3)
jaro_winkler (1.5.4)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jmespath (1.4.0)
Expand Down Expand Up @@ -495,8 +495,8 @@ GEM
overcommit (0.49.1)
childprocess (>= 0.6.3, < 2.0)
iniparse (~> 1.4)
parallel (1.17.0)
parser (2.6.4.1)
parallel (1.19.1)
parser (2.7.0.2)
ast (~> 2.4.0)
pg (1.1.4)
polyamorous (2.3.0)
Expand All @@ -519,7 +519,7 @@ GEM
nio4r (~> 2.0)
pundit (2.1.0)
activesupport (>= 3.0.0)
rack (2.0.8)
rack (2.1.1)
rack-contrib (2.1.0)
rack (~> 2.0)
rack-cors (1.0.6)
Expand Down Expand Up @@ -675,14 +675,14 @@ GEM
rspec-retry (0.6.1)
rspec-core (> 3.3)
rspec-support (3.9.0)
rubocop (0.74.0)
rubocop (0.79.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.6)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-rails (2.3.2)
rubocop-rails (2.4.1)
rack (>= 1.1)
rubocop (>= 0.72.0)
ruby-progressbar (1.10.1)
Expand Down Expand Up @@ -758,7 +758,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
unicode-display_width (1.6.0)
unicode-display_width (1.6.1)
uniform_notifier (1.12.1)
url_mount (0.2.1)
rack
Expand Down Expand Up @@ -903,8 +903,8 @@ DEPENDENCIES
rspec-eventually (~> 0.2.2)
rspec-rails (~> 4.0.0.beta3)
rspec-retry (~> 0.5)
rubocop (~> 0.74)
rubocop-rails (~> 2.3)
rubocop (~> 0.79)
rubocop-rails (~> 2.4)
sass-rails (>= 6)
scarf (~> 0.2)
scout_apm (~> 2.6)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def oauth_callback
if oauth_origin.present?
if @email.blank?
redirect_to oauth_error_url(host: oauth_origin[:fqdn], error: email_blank_flash)
return
nil
else
sign_in_at_oauth_origin
end
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/pupil_first_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class PupilFirstMailer < ActionMailer::Base
class PupilFirstMailer < ActionMailer::Base # rubocop:disable Rails/ApplicationMailer
include Roadie::Rails::Mailer

default from: "PupilFirst <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/school_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# TODO: The SchoolMailer class should be renamed to ApplicationMailer.
class SchoolMailer < ActionMailer::Base
class SchoolMailer < ActionMailer::Base # rubocop:disable Rails/ApplicationMailer
include Roadie::Rails::Mailer

layout 'mail/school'
Expand Down
4 changes: 2 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class Application < Rails::Application
config.i18n.enforce_available_locales = true

# include nested directories inside locale
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.yml')]
config.i18n.load_path += Dir[Rails.root.join('config/locales/**/*.yml')]

Dir.glob('config/routes/*.rb').each do |file|
config.paths['config/routes.rb'] << Rails.root.join(file)
end

# Precompile fonts.
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
config.assets.paths << Rails.root.join('app/assets/fonts')

# Add some paths to autoload
%w[presenters services forms/concerns].each do |folder|
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
config.cache_store = :memory_store, { size: 64.megabytes }

# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true

config.public_file_server.headers = {
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/active_admin_extensions.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_relative '../../lib/active_admin/current_admin_user'

ActiveAdmin::BaseController.send(:include, ActiveAdmin::CurrentAdminUser)
ActiveAdmin::BaseController.include ActiveAdmin::CurrentAdminUser

# Customize <head> for all active admin pages.
ActiveAdmin::Views::Pages::Base.class_eval do
Expand Down
4 changes: 2 additions & 2 deletions lib/intercom/intercom_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def alter_and_delete(user)
rescued_call { intercom_client.users.delete(user) }
end

# rubocop:disable MethodLength, Metrics/PerceivedComplexity, Metrics/AbcSize
# rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/AbcSize
def strip_user_ids_from_segment(segment_name)
users = get_users_by_segment(segment_name)

Expand Down Expand Up @@ -205,7 +205,7 @@ def strip_user_ids_from_segment(segment_name)
end
end

# rubocop:enable MethodLength, Metrics/PerceivedComplexity, Metrics/AbcSize
# rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/AbcSize

def get_segment_id(segment_name)
segment_id = nil
Expand Down
12 changes: 0 additions & 12 deletions lib/tasks/bundler_audit.rake

This file was deleted.

2 changes: 1 addition & 1 deletion lib/tasks/lita.rake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace :lita do
# The leaderboard feature is disabled, for the time being.
# require_relative '../lita/handlers/leaderboard'

lita_config_path = File.expand_path(Rails.root.join('config', 'lita_config.rb'))
lita_config_path = File.expand_path(Rails.root.join('config/lita_config.rb'))
Lita.run(lita_config_path)
end
end
4 changes: 2 additions & 2 deletions spec/factories/content_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

trait :image do
block_type { ContentBlock::BLOCK_TYPE_IMAGE }
file { Rack::Test::UploadedFile.new(Rails.root.join('spec', 'support', 'uploads', 'resources', 'pdf-thumbnail.png'), 'image/png') }
file { Rack::Test::UploadedFile.new(Rails.root.join('spec/support/uploads/resources/pdf-thumbnail.png'), 'image/png') }
content { { caption: Faker::Lorem.sentence } }
end

trait :file do
block_type { ContentBlock::BLOCK_TYPE_FILE }
file { Rack::Test::UploadedFile.new(Rails.root.join('spec', 'support', 'uploads', 'resources', 'pdf-sample.pdf'), 'application/pdf') }
file { Rack::Test::UploadedFile.new(Rails.root.join('spec/support/uploads/resources/pdf-sample.pdf'), 'application/pdf') }
content { { title: Faker::Lorem.words(3).join(" ").titleize } }
end

Expand Down
2 changes: 1 addition & 1 deletion spec/factories/markdown_attachment.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :markdown_attachment do
file { Rack::Test::UploadedFile.new(Rails.root.join('spec', 'support', 'uploads', 'resources', 'pdf-sample.pdf')) }
file { Rack::Test::UploadedFile.new(Rails.root.join('spec/support/uploads/resources/pdf-sample.pdf')) }
token { SecureRandom.urlsafe_base64 }
user
end
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/resource.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FactoryBot.define do
factory :resource do
file { Rack::Test::UploadedFile.new(Rails.root.join('spec', 'support', 'uploads', 'resources', 'pdf-sample.pdf'), 'application/pdf') }
file { Rack::Test::UploadedFile.new(Rails.root.join('spec/support/uploads/resources/pdf-sample.pdf'), 'application/pdf') }
title { Faker::Lorem.words(6).join ' ' }
description { Faker::Lorem.words(12).join ' ' }
school

factory :resource_video_file do
file { Rack::Test::UploadedFile.new(Rails.root.join('spec', 'support', 'uploads', 'resources', 'video-sample.mp4')) }
file { Rack::Test::UploadedFile.new(Rails.root.join('spec/support/uploads/resources/video-sample.mp4')) }
end

factory :resource_video_embed do
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/timeline_event_file.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :timeline_event_file do
sequence(:title) { |i| [Faker::Lorem.word, i].join ' ' }
file { Rack::Test::UploadedFile.new(Rails.root.join('spec', 'support', 'uploads', 'resources', 'pdf-sample.pdf')) }
file { Rack::Test::UploadedFile.new(Rails.root.join('spec/support/uploads/resources/pdf-sample.pdf')) }
timeline_event
end
end
2 changes: 1 addition & 1 deletion spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

context 'when the user has an uploaded image' do
before do
avatar = File.open(Rails.root.join('spec', 'support', 'uploads', 'faculty', 'donald_duck.jpg'))
avatar = File.open(Rails.root.join('spec/support/uploads/faculty/donald_duck.jpg'))
user.avatar.attach(io: avatar, filename: 'donald_duck.jpg')
user.save!
end
Expand Down
6 changes: 3 additions & 3 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
Dir[Rails.root.join('spec/support/**/*.rb')].sort.each { |f| require f }

# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
Expand All @@ -55,7 +55,7 @@
service_bug_counter = 0

begin
ActiveStorage::Blob.service = ActiveStorage::Service.configure(:test, test: { service: 'Disk', root: Rails.root.join('tmp', 'storage') })
ActiveStorage::Blob.service = ActiveStorage::Service.configure(:test, test: { service: 'Disk', root: Rails.root.join('tmp/storage') })

if service_bug_counter.zero?
puts "[NOTICE] Workaround for ActiveStorage::Blob.service assignment wasn't triggered. Consider removing it."
Expand All @@ -70,7 +70,7 @@

RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = ::Rails.root.join('spec', 'fixtures')
config.fixture_path = ::Rails.root.join('spec/fixtures')

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
Expand Down
2 changes: 1 addition & 1 deletion spec/system/school/coaches_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

fill_in 'LinkedIn', with: 'https://www.linkedin.com/xyz'
fill_in 'Connect Link', with: 'https://www.connect.com/xyz'
attach_file 'faculty[image]', File.absolute_path(Rails.root.join('spec', 'support', 'uploads', 'faculty', 'human.png')), visible: false
attach_file 'faculty[image]', File.absolute_path(Rails.root.join('spec/support/uploads/faculty/human.png')), visible: false
fill_in 'Name', with: updated_coach_name
expect(page).not_to have_field('Email')
fill_in 'Title', with: updated_coach_title
Expand Down
4 changes: 2 additions & 2 deletions spec/system/targets/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
expect(page).to have_button('Submit')

find('a', text: 'Upload File').click
attach_file 'attachment_file', File.absolute_path(Rails.root.join('spec', 'support', 'uploads', 'faculty', 'human.png')), visible: false
attach_file 'attachment_file', File.absolute_path(Rails.root.join('spec/support/uploads/faculty/human.png')), visible: false
find('a', text: 'Add URL').click
fill_in 'attachment_url', with: 'https://example.com?q=2'
click_button 'Attach link'
Expand Down Expand Up @@ -616,7 +616,7 @@
expect(page).to have_button('Submit', disabled: true)

find('a', text: 'Upload File').click
attach_file 'attachment_file', File.absolute_path(Rails.root.join('spec', 'support', 'uploads', 'faculty', 'human.png')), visible: false
attach_file 'attachment_file', File.absolute_path(Rails.root.join('spec/support/uploads/faculty/human.png')), visible: false
find('a', text: 'Add URL').click
fill_in 'attachment_url', with: 'https://example.com?q=2'
click_button 'Attach link'
Expand Down

0 comments on commit 02d6525

Please sign in to comment.