Routine rubocop lint fixes (#4638) [ci skip]

This commit is contained in:
rhymes 2019-10-30 15:46:57 +01:00 committed by Mac Siri
parent fd3d87c759
commit 36d1df7f49
6 changed files with 68 additions and 62 deletions

View file

@ -1,16 +1,16 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-10-23 22:13:39 +0100 using RuboCop version 0.75.0.
# on 2019-10-28 15:15:12 +0100 using RuboCop version 0.75.1.
# 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
# versions of RuboCop, may require this file to be generated again.
# Offense count: 232
# Offense count: 235
Metrics/AbcSize:
Max: 75
# Offense count: 12
# Offense count: 13
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
@ -26,11 +26,16 @@ RSpec/ExampleLength:
- 'spec/requests/api/v0/articles_spec.rb'
- 'spec/requests/display_ad_events_spec.rb'
# Offense count: 427
# Offense count: 444
# Configuration parameters: AggregateFailuresByDefault.
RSpec/MultipleExpectations:
Max: 8
# Offense count: 1
RSpec/UnspecifiedException:
Exclude:
- 'spec/requests/messages_spec.rb'
# Offense count: 1
# Configuration parameters: Include.
# Include: app/helpers/**/*.rb
@ -64,7 +69,7 @@ Style/GuardClause:
Exclude:
- 'app/models/article.rb'
# Offense count: 3066
# Offense count: 3143
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https

View file

@ -49,10 +49,9 @@ class UserBlocksController < ApplicationController
private
def check_sign_in_status
unless current_user
skip_authorization
render json: { result: "not-logged-in", status: 401 }, status: :unauthorized
return
end
return if current_user
skip_authorization
render json: { result: "not-logged-in", status: 401 }, status: :unauthorized
end
end

View file

@ -33,7 +33,7 @@ class Organization < ApplicationRecord
format: { with: /\A[a-zA-Z0-9\-_]+\Z/ },
length: { in: 2..18 },
exclusion: { in: ReservedWords.all,
message: "%{value} is a reserved word. Contact yo@dev.to for help registering your organization." }
message: "%<value>s is a reserved word. Contact yo@dev.to for help registering your organization." }
validates :url, url: { allow_blank: true, no_local: true, schemes: %w[https http] }
validates :secret, uniqueness: { allow_blank: true }
validates :location, :email, :company_size, length: { maximum: 64 }

View file

@ -106,29 +106,29 @@ class User < ApplicationRecord
format: /\A(http(s)?:\/\/)?(www.twitch.tv|twitch.tv)\/.*\Z/
validates :shirt_gender,
inclusion: { in: %w[unisex womens],
message: "%{value} is not a valid shirt style" },
message: "%<value>s is not a valid shirt style" },
allow_blank: true
validates :shirt_size,
inclusion: { in: %w[xs s m l xl 2xl 3xl 4xl],
message: "%{value} is not a valid size" },
message: "%<value>s is not a valid size" },
allow_blank: true
validates :tabs_or_spaces,
inclusion: { in: %w[tabs spaces],
message: "%{value} is not a valid answer" },
message: "%<value>s is not a valid answer" },
allow_blank: true
validates :editor_version,
inclusion: { in: %w[v1 v2],
message: "%{value} must be either v1 or v2" }
message: "%<value>s must be either v1 or v2" }
validates :config_theme,
inclusion: { in: %w[default night_theme pink_theme minimal_light_theme ten_x_hacker_theme],
message: "%{value} is not a valid theme" }
message: "%<value>s is not a valid theme" }
validates :config_font,
inclusion: { in: %w[default sans_serif monospace comic_sans],
message: "%{value} is not a valid font selection" }
message: "%<value>s is not a valid font selection" }
validates :config_navbar,
inclusion: { in: %w[default static],
message: "%{value} is not a valid navbar value" }
message: "%<value>s is not a valid navbar value" }
validates :shipping_country,
length: { in: 2..2 },
allow_blank: true

View file

@ -8,7 +8,7 @@ RSpec.describe UserBlock, type: :model do
it { is_expected.to validate_inclusion_of(:config).in_array(%w[default]) }
it "prevents the blocker from blocking itself" do
user_block = UserBlock.new(blocker_id: 1, blocked_id: 1, config: "default")
user_block = described_class.new(blocker_id: 1, blocked_id: 1, config: "default")
expect(user_block.valid?).to eq false
expect(user_block.errors.full_messages).to include "Blocker can't be the same as the blocked_id"
end

View file

@ -365,7 +365,7 @@ RSpec.describe User, type: :model do
user.config_navbar = "not valid navbar input"
expect(user).not_to be_valid
end
end
end
## Registration
describe "user registration" do
@ -562,58 +562,60 @@ end
end
end
it "creates proper body class with defaults" do
expect(user.decorate.config_body_class).to eq("default default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
describe "theming properties" do
it "creates proper body class with defaults" do
expect(user.decorate.config_body_class).to eq("default default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "determines dark theme if night theme" do
user.config_theme = "night_theme"
expect(user.decorate.dark_theme?).to eq(true)
end
it "determines dark theme if night theme" do
user.config_theme = "night_theme"
expect(user.decorate.dark_theme?).to eq(true)
end
it "determines dark theme if ten x hacker" do
user.config_theme = "ten_x_hacker_theme"
expect(user.decorate.dark_theme?).to eq(true)
end
it "determines dark theme if ten x hacker" do
user.config_theme = "ten_x_hacker_theme"
expect(user.decorate.dark_theme?).to eq(true)
end
it "determines not dark theme if not one of the dark themes" do
user.config_theme = "default"
expect(user.decorate.dark_theme?).to eq(false)
end
it "determines not dark theme if not one of the dark themes" do
user.config_theme = "default"
expect(user.decorate.dark_theme?).to eq(false)
end
it "creates proper body class with sans serif config" do
user.config_font = "sans_serif"
expect(user.decorate.config_body_class).to eq("default sans-serif-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "creates proper body class with sans serif config" do
user.config_font = "sans_serif"
expect(user.decorate.config_body_class).to eq("default sans-serif-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "creates proper body class with night theme" do
user.config_theme = "night_theme"
expect(user.decorate.config_body_class).to eq("night-theme default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "creates proper body class with night theme" do
user.config_theme = "night_theme"
expect(user.decorate.config_body_class).to eq("night-theme default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "creates proper body class with pink theme" do
user.config_theme = "pink_theme"
expect(user.decorate.config_body_class).to eq("pink-theme default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "creates proper body class with pink theme" do
user.config_theme = "pink_theme"
expect(user.decorate.config_body_class).to eq("pink-theme default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "creates proper body class with minimal light theme" do
user.config_theme = "minimal_light_theme"
expect(user.decorate.config_body_class).to eq("minimal-light-theme default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "creates proper body class with minimal light theme" do
user.config_theme = "minimal_light_theme"
expect(user.decorate.config_body_class).to eq("minimal-light-theme default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "creates proper body class with pro user" do
user.add_role(:pro)
expect(user.decorate.config_body_class).to eq("default default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "creates proper body class with pro user" do
user.add_role(:pro)
expect(user.decorate.config_body_class).to eq("default default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "creates proper body class with trusted user" do
user.add_role(:trusted)
expect(user.decorate.config_body_class).to eq("default default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "creates proper body class with trusted user" do
user.add_role(:trusted)
expect(user.decorate.config_body_class).to eq("default default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
end
it "creates proper body class with trusted user" do
user.config_navbar = "static"
expect(user.decorate.config_body_class).to eq("default default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} #{user.config_navbar}-navbar-config")
it "works with static navbar" do
user.config_navbar = "static"
expect(user.decorate.config_body_class).to eq("default default-article-body pro-status-#{user.pro?} trusted-status-#{user.trusted} static-navbar-config")
end
end
it "does not allow to change to username that is taken" do