diff --git a/.codeclimate.yml b/.codeclimate.yml index c2c9d2c931d64..8f4d9228fb2ad 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -2,7 +2,7 @@ version: "2" plugins: rubocop: enabled: true - channel: rubocop-0-63 + channel: rubocop-0-67 brakeman: enabled: true eslint: diff --git a/.rubocop.yml b/.rubocop.yml index d83db83e44c0c..cc3e725b3a0bc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,8 @@ inherit_from: .rubocop_todo.yml -require: rubocop-rspec +require: + - rubocop-performance + - rubocop-rspec # our custom config # TODO: Uncomment it after fix rubocop-todo RSpec/MultipleExpectations @@ -12,7 +14,8 @@ RSpec/MultipleExpectations: RSpec/DescribeClass: Exclude: - spec/features/**/* - - spec/requests/* + - spec/requests/**/* + - spec/system/**/* RSpec/ExampleLength: Max: 10 diff --git a/Gemfile b/Gemfile index df71c79a7074e..9096f083c3e90 100644 --- a/Gemfile +++ b/Gemfile @@ -130,8 +130,9 @@ group :development, :test do gem "parallel_tests", "~> 2.27" gem "pry-byebug", "~> 3.7" gem "rspec-rails", "~> 3.8" - gem "rubocop", "~> 0.63", require: false - gem "rubocop-rspec", "~> 1.32" + gem "rubocop", "~> 0.67", require: false + gem "rubocop-performance", "~> 1.0", require: false + gem "rubocop-rspec", "~> 1.32", require: false gem "spring", "~> 2.0" gem "spring-commands-rspec", "~> 1.0" gem "vcr", "~> 4.0" diff --git a/Gemfile.lock b/Gemfile.lock index aebba37c11e0d..ddf0f2ee75be4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -674,13 +674,12 @@ GEM rack orm_adapter (0.5.0) os (1.0.0) - parallel (1.15.0) + parallel (1.17.0) parallel_tests (2.27.1) parallel parser (2.6.2.0) ast (~> 2.4.0) pg (1.1.4) - powerpack (0.1.2) pry (0.12.2) coderay (~> 1.1.0) method_source (~> 0.9.0) @@ -689,6 +688,7 @@ GEM pry (~> 0.10) pry-rails (0.3.9) pry (>= 0.10.4) + psych (3.1.0) public_suffix (3.0.3) puma (3.12.0) pundit (2.0.1) @@ -798,14 +798,16 @@ GEM rspec-retry (0.6.1) rspec-core (> 3.3) rspec-support (3.8.0) - rubocop (0.63.1) + rubocop (0.67.2) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.5, != 2.5.1.1) - powerpack (~> 0.1) + psych (>= 3.1.0) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.4.0) + unicode-display_width (>= 1.4.0, < 1.6) + rubocop-performance (1.0.0) + rubocop (>= 0.58.0) rubocop-rspec (1.32.0) rubocop (>= 0.60.0) ruby-prof (0.17.0) @@ -931,7 +933,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.5) - unicode-display_width (1.4.1) + unicode-display_width (1.5.0) uniform_notifier (1.12.1) validate_url (1.0.6) activemodel (>= 3.0.0) @@ -1071,7 +1073,8 @@ DEPENDENCIES rouge (~> 3.3) rspec-rails (~> 3.8) rspec-retry (~> 0.6) - rubocop (~> 0.63) + rubocop (~> 0.67) + rubocop-performance (~> 1.0) rubocop-rspec (~> 1.32) ruby-prof (~> 0.17) rubyzip (~> 1.2, >= 1.2.2) diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 9dac11ad4db2f..725d116031f81 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -43,11 +43,11 @@ def callback_for(provider) flash[:alert] = user_errors redirect_to new_user_registration_url end - rescue StandardError => error - logger.error "Log in error: #{error}" + rescue StandardError => e + logger.error "Log in error: #{e}" logger.error "Log in error: auth data hash - #{request.env['omniauth.auth']}" logger.error "Log in error: auth data hash - #{request.env['omniauth.error']&.inspect}" - flash[:alert] = "Log in error: #{error}" + flash[:alert] = "Log in error: #{e}" redirect_to new_user_registration_url end diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index d572175d3ef81..7039d2806bba7 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -55,7 +55,7 @@ def redirect_to_changed_username_profile def handle_possible_redirect potential_username = params[:username].tr("@", "").downcase @user = User.find_by("old_username = ? OR old_old_username = ?", potential_username, potential_username) - if @user&.articles&.find_by_slug(params[:slug]) + if @user&.articles&.find_by(slug: params[:slug]) redirect_to "/#{@user.username}/#{params[:slug]}" return elsif (@organization = @article.organization) diff --git a/app/labor/rate_limit_checker.rb b/app/labor/rate_limit_checker.rb index 5b01c12115f6f..0a46505568bd9 100644 --- a/app/labor/rate_limit_checker.rb +++ b/app/labor/rate_limit_checker.rb @@ -30,10 +30,10 @@ def ping_admins SlackBot.ping( "Rate limit exceeded. https://dev.to#{user.path}", - channel: "abuse-reports", - username: "rate_limit", - icon_emoji: ":hand:", - ) + channel: "abuse-reports", + username: "rate_limit", + icon_emoji: ":hand:", + ) end handle_asynchronously :ping_admins end diff --git a/config/routes.rb b/config/routes.rb index 62e59fdb0edee..323bc6e903e7e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -139,7 +139,6 @@ resources :page_views, only: %i[create update] resources :buffer_updates, only: [:create] - get "/notifications/:filter" => "notifications#index" get "/notifications/:filter/:org_id" => "notifications#index" patch "/onboarding_update" => "users#onboarding_update" @@ -153,8 +152,6 @@ post "/pusher/auth" => "pusher#auth" - # resources :users - get "/social_previews/article/:id" => "social_previews#article" get "/social_previews/user/:id" => "social_previews#user" get "/social_previews/organization/:id" => "social_previews#organization" diff --git a/spec/system/comments/user_fills_out_comment_spec.rb b/spec/system/comments/user_fills_out_comment_spec.rb index 41417f9db170f..6f352b025dddd 100644 --- a/spec/system/comments/user_fills_out_comment_spec.rb +++ b/spec/system/comments/user_fills_out_comment_spec.rb @@ -19,16 +19,12 @@ end it "User fill out commen box then click previews and submit" do - visit user.path visit article.path.to_s fill_in "text-area", with: raw_comment - find(".checkbox").click click_button("PREVIEW") - expect(page).to have_text(raw_comment) expect(page).to have_text("MARKDOWN") click_button("MARKDOWN") - # expect(page).to have_text(raw_comment) expect(page).to have_text("PREVIEW") click_button("SUBMIT") expect(page).to have_text(raw_comment) diff --git a/spec/system/organization/user_updates_org_settings_spec.rb b/spec/system/organization/user_updates_org_settings_spec.rb index 21c158c813a13..cd704ff946a86 100644 --- a/spec/system/organization/user_updates_org_settings_spec.rb +++ b/spec/system/organization/user_updates_org_settings_spec.rb @@ -10,17 +10,7 @@ it "user creates an organization" do visit "settings/organization" - fill_in "organization[name]", with: "Organization Name" - fill_in "organization[slug]", with: "Organization" - attach_file( - "organization_profile_image", - Rails.root.join("app", "assets", "images", "android-icon-36x36.png"), - ) - fill_in "Text color (hex)", with: "#ffffff" - fill_in "Background color (hex)", with: "#000000" - fill_in "organization[url]", with: "http://company.com" - fill_in "organization[summary]", with: "Summary" - fill_in "organization[proof]", with: "Proof" + fill_in_org_form click_button "SUBMIT" expect(page).to have_text("Your organization was successfully created and you are an admin.") end @@ -33,4 +23,18 @@ page.driver.browser.switch_to.alert.accept expect(page).not_to have_text(user2.name) end + + def fill_in_org_form + fill_in "organization[name]", with: "Organization Name" + fill_in "organization[slug]", with: "Organization" + attach_file( + "organization_profile_image", + Rails.root.join("app", "assets", "images", "android-icon-36x36.png"), + ) + fill_in "Text color (hex)", with: "#ffffff" + fill_in "Background color (hex)", with: "#000000" + fill_in "organization[url]", with: "http://company.com" + fill_in "organization[summary]", with: "Summary" + fill_in "organization[proof]", with: "Proof" + end end