[deploy] Routine Rubocop fixes (#8293)
* rubocop -a fixes * rubocop --auto-gen-config
This commit is contained in:
parent
3c840610a1
commit
9215d04f08
7 changed files with 52 additions and 53 deletions
|
|
@ -6,7 +6,7 @@ require:
|
|||
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config`
|
||||
# on 2020-05-28 18:37:09 +0200 using RuboCop version 0.84.0.
|
||||
# on 2020-06-05 15:47:42 +0200 using RuboCop version 0.84.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
|
||||
|
|
@ -15,13 +15,13 @@ require:
|
|||
# Offense count: 273
|
||||
# Configuration parameters: IgnoredMethods.
|
||||
Metrics/AbcSize:
|
||||
Max: 64
|
||||
Max: 62
|
||||
|
||||
# Offense count: 7
|
||||
# Offense count: 14
|
||||
# Configuration parameters: CountComments, ExcludedMethods.
|
||||
# ExcludedMethods: refine
|
||||
Metrics/BlockLength:
|
||||
Max: 53
|
||||
Max: 61
|
||||
|
||||
# Offense count: 8
|
||||
Performance/OpenStruct:
|
||||
|
|
@ -40,7 +40,7 @@ RSpec/ExampleLength:
|
|||
- 'spec/models/comment_spec.rb'
|
||||
- 'spec/requests/display_ad_events_spec.rb'
|
||||
|
||||
# Offense count: 866
|
||||
# Offense count: 872
|
||||
RSpec/MultipleExpectations:
|
||||
Max: 12
|
||||
|
||||
|
|
@ -74,15 +74,13 @@ Rails/OutputSafety:
|
|||
- 'app/models/display_ad.rb'
|
||||
- 'app/models/message.rb'
|
||||
|
||||
# Offense count: 7
|
||||
# Offense count: 5
|
||||
# Configuration parameters: Include.
|
||||
# Include: app/models/**/*.rb
|
||||
Rails/UniqueValidationWithoutIndex:
|
||||
Exclude:
|
||||
- 'app/models/article.rb'
|
||||
- 'app/models/comment.rb'
|
||||
- 'app/models/follow.rb'
|
||||
- 'app/models/broadcast.rb'
|
||||
|
||||
# Offense count: 33
|
||||
# Cop supports --auto-correct.
|
||||
|
|
@ -98,7 +96,7 @@ Style/SingleLineBlockParams:
|
|||
Exclude:
|
||||
- 'app/labor/markdown_fixer.rb'
|
||||
|
||||
# Offense count: 533
|
||||
# Offense count: 546
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
||||
# URISchemes: http, https
|
||||
|
|
|
|||
|
|
@ -29,20 +29,20 @@ class FollowsController < ApplicationController
|
|||
skip_authorization
|
||||
render(plain: "not-logged-in") && return unless current_user
|
||||
|
||||
response = params.require(:ids).map(&:to_i).each_with_object({}) do |id, hsh|
|
||||
hsh[id] = if current_user.id == id
|
||||
"self"
|
||||
else
|
||||
following_them_check = FollowChecker.new(current_user, params[:followable_type], id).cached_follow_check
|
||||
following_you_check = FollowChecker.new(User.find_by(id: id), params[:followable_type], current_user.id).cached_follow_check
|
||||
if following_them_check && following_you_check
|
||||
"mutual"
|
||||
elsif following_you_check
|
||||
"follow-back"
|
||||
else
|
||||
following_them_check.to_s
|
||||
end
|
||||
end
|
||||
response = params.require(:ids).map(&:to_i).index_with do |id|
|
||||
if current_user.id == id
|
||||
"self"
|
||||
else
|
||||
following_them_check = FollowChecker.new(current_user, params[:followable_type], id).cached_follow_check
|
||||
following_you_check = FollowChecker.new(User.find_by(id: id), params[:followable_type], current_user.id).cached_follow_check
|
||||
if following_them_check && following_you_check
|
||||
"mutual"
|
||||
elsif following_you_check
|
||||
"follow-back"
|
||||
else
|
||||
following_them_check.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
render json: response
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ module Podcasts
|
|||
end
|
||||
|
||||
def to_h
|
||||
ATTRIBUTES.each_with_object({}) do |key, hash|
|
||||
hash[key] = instance_variable_get("@#{key}")
|
||||
ATTRIBUTES.index_with do |key|
|
||||
instance_variable_get("@#{key}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
36
db/seeds.rb
36
db/seeds.rb
|
|
@ -118,7 +118,7 @@ end
|
|||
|
||||
seeder.create_if_none(Tag) do
|
||||
tags = %w[beginners career computerscience git go
|
||||
java javascript linux productivity python security webdev]
|
||||
java javascript linux productivity python security webdev]
|
||||
|
||||
tags.each do |tag_name|
|
||||
Tag.create!(
|
||||
|
|
@ -141,16 +141,16 @@ seeder.create_if_none(Article, num_articles) do
|
|||
tags.concat Tag.order(Arel.sql("RANDOM()")).limit(3).pluck(:name)
|
||||
|
||||
markdown = <<~MARKDOWN
|
||||
---
|
||||
title: #{Faker::Book.title} #{Faker::Lorem.sentence(word_count: 2).chomp('.')}
|
||||
published: true
|
||||
cover_image: #{Faker::Company.logo}
|
||||
tags: #{tags.join(', ')}
|
||||
---
|
||||
---
|
||||
title: #{Faker::Book.title} #{Faker::Lorem.sentence(word_count: 2).chomp('.')}
|
||||
published: true
|
||||
cover_image: #{Faker::Company.logo}
|
||||
tags: #{tags.join(', ')}
|
||||
---
|
||||
|
||||
#{Faker::Hipster.paragraph(sentence_count: 2)}
|
||||
#{Faker::Markdown.random}
|
||||
#{Faker::Hipster.paragraph(sentence_count: 2)}
|
||||
#{Faker::Hipster.paragraph(sentence_count: 2)}
|
||||
#{Faker::Markdown.random}
|
||||
#{Faker::Hipster.paragraph(sentence_count: 2)}
|
||||
MARKDOWN
|
||||
|
||||
Article.create!(
|
||||
|
|
@ -272,16 +272,16 @@ seeder.create_if_none(Broadcast) do
|
|||
end
|
||||
|
||||
welcome_thread_content = <<~HEREDOC
|
||||
---
|
||||
title: Welcome Thread - v0
|
||||
published: true
|
||||
description: Introduce yourself to the community!
|
||||
tags: welcome
|
||||
---
|
||||
---
|
||||
title: Welcome Thread - v0
|
||||
published: true
|
||||
description: Introduce yourself to the community!
|
||||
tags: welcome
|
||||
---
|
||||
|
||||
Hey there! Welcome to #{ApplicationConfig['COMMUNITY_NAME']}!
|
||||
Hey there! Welcome to #{ApplicationConfig['COMMUNITY_NAME']}!
|
||||
|
||||
Leave a comment below to introduce yourself to the community!✌️
|
||||
Leave a comment below to introduce yourself to the community!✌️
|
||||
HEREDOC
|
||||
|
||||
Article.create!(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace :app_initializer do
|
|||
Rake::Task["search:setup"].execute
|
||||
|
||||
puts "\n== Preparing database =="
|
||||
system('bin/rails db:prepare')
|
||||
system("bin/rails db:prepare")
|
||||
|
||||
puts "\n== Updating Data =="
|
||||
Rake::Task["data_updates:enqueue_data_update_worker"].execute
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ if Rails.env.development?
|
|||
|
||||
namespace :pages do
|
||||
desc "Automated sync of Page HTML body by listening to changes of local file"
|
||||
task :sync, [:slug, :filepath] => [:environment] do |task, args|
|
||||
task :sync, %i[slug filepath] => [:environment] do |_task, args|
|
||||
next if Rails.env.production?
|
||||
|
||||
pathname = Pathname.new(args.filepath)
|
||||
|
||||
if !File.file?(pathname) || Page.find_by(slug: args.slug).nil?
|
||||
|
|
@ -32,7 +33,7 @@ if Rails.env.development?
|
|||
puts "Watching file '#{pathname}' for changes... Happy Coding!"
|
||||
begin
|
||||
sleep
|
||||
rescue Exception => e
|
||||
rescue StandardError
|
||||
puts "\nBye :)"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,27 +27,27 @@ describe FeatureFlag, type: :helper do
|
|||
let(:user) { UserStruct.new(flipper_id: 1) }
|
||||
|
||||
it "returns false when flag doesn't exist" do
|
||||
expect(described_class.accessible?("missing_flag")).to be_truthy # rubocop:disable Rspec/PredicateMatcher
|
||||
expect(described_class.accessible?("missing_flag")).to be(true)
|
||||
end
|
||||
|
||||
it "returns true when flag is empty" do
|
||||
expect(described_class.accessible?("")).to be_truthy # rubocop:disable Rspec/PredicateMatcher
|
||||
expect(described_class.accessible?("")).to be(true)
|
||||
end
|
||||
|
||||
it "returns true when flag is nil" do
|
||||
expect(described_class.accessible?(nil)).to be_truthy # rubocop:disable Rspec/PredicateMatcher
|
||||
expect(described_class.accessible?(nil)).to be(true)
|
||||
end
|
||||
|
||||
context "when flag exists and is set to off" do
|
||||
before { Flipper.disable("flag") }
|
||||
|
||||
it "returns false" do
|
||||
expect(described_class.accessible?("flag")).to be_falsy # rubocop:disable Rspec/PredicateMatcher
|
||||
expect(described_class.accessible?("flag")).to be(false)
|
||||
end
|
||||
|
||||
it "returns true when flag is on for user" do
|
||||
Flipper.enable_actor("flag", user)
|
||||
expect(described_class.accessible?("flag", user)).to be_truthy # rubocop:disable Rspec/PredicateMatcher
|
||||
expect(described_class.accessible?("flag", user)).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -55,11 +55,11 @@ describe FeatureFlag, type: :helper do
|
|||
before { Flipper.enable("flag") }
|
||||
|
||||
it "returns true" do
|
||||
expect(described_class.accessible?("flag")).to be_truthy # rubocop:disable Rspec/PredicateMatcher
|
||||
expect(described_class.accessible?("flag")).to be(true)
|
||||
end
|
||||
|
||||
it "returns true for a user" do
|
||||
expect(described_class.accessible?("flag", user)).to be_truthy # rubocop:disable Rspec/PredicateMatcher
|
||||
expect(described_class.accessible?("flag", user)).to be(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue