Rubocop fixes (#14868)

This commit is contained in:
rhymes 2021-09-30 19:22:09 +02:00 committed by GitHub
parent 096cf18b10
commit 8b4a909aac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 25 additions and 21 deletions

View file

@ -15,6 +15,7 @@ AllCops:
- node_modules/**/*
- tmp/**/*
- vendor/**/*
- .pryrc
DisplayStyleGuide: true
ExtraDetails: true
NewCops: enable # opt-in to new cops by default

View file

@ -47,8 +47,8 @@ gem "honeybadger", "~> 4.9" # Used for tracking application errors
gem "honeycomb-beeline", "~> 2.7.0" # Monitoring and Observability gem
gem "html_truncator", "~> 0.4" # Truncate an HTML string properly
gem "htmlentities", "~> 4.3", ">= 4.3.4" # A module for encoding and decoding (X)HTML entities
gem "i18n-js", "~> 3.9.0" # Helps with internationalization in Rails.
gem "httparty", "~> 0.20" # Makes http fun! Also, makes consuming restful web services dead easy
gem "i18n-js", "~> 3.9.0" # Helps with internationalization in Rails.
gem "imgproxy", "~> 2.0" # A gem that easily generates imgproxy URLs for your images
gem "inline_svg", "~> 1.7" # Embed SVG documents in your Rails views and style them with CSS
gem "jbuilder", "~> 2.11" # Create JSON structures via a Builder-style DSL

View file

@ -1,5 +1,5 @@
module DisplayAdHelper
def display_ads_placement_area_options_array
DisplayAd::ALLOWED_PLACEMENT_AREAS_HUMAN_READABLE.zip(DisplayAd::ALLOWED_PLACEMENT_AREAS)
DisplayAd::ALLOWED_PLACEMENT_AREAS_HUMAN_READABLE.zip(DisplayAd::ALLOWED_PLACEMENT_AREAS)
end
end

View file

@ -20,7 +20,8 @@ class DisplayAd < ApplicationRecord
ALLOWED_TAGS = %w[
a abbr add b blockquote br center cite code col colgroup dd del dl dt em figcaption
h1 h2 h3 h4 h5 h6 hr img kbd li mark ol p pre q rp rt ruby small source span strong sub sup table
tbody td tfoot th thead time tr u ul video].freeze
tbody td tfoot th thead time tr u ul video
].freeze
ALLOWED_ATTRIBUTES = %w[href src alt height width].freeze
def self.for_display(area)

View file

@ -37,19 +37,19 @@
"jest --findRelatedTests"
],
"{app,spec,config,lib}/**/*.rb": [
"bundle exec rubocop --require rubocop-rspec --auto-correct"
"bundle exec rubocop --require rubocop-rspec --auto-correct --enable-pending-cops"
],
"scripts/{release,stage_release}": [
"bundle exec rubocop --require rubocop-rspec --auto-correct"
"bundle exec rubocop --require rubocop-rspec --auto-correct --enable-pending-cops"
],
"app/views/**/*.jbuilder": [
"bundle exec rubocop --require rubocop-rspec --auto-correct"
"bundle exec rubocop --require rubocop-rspec --auto-correct --enable-pending-cops"
],
"./Gemfile": [
"bundle exec rubocop --require rubocop-rspec --auto-correct"
"bundle exec rubocop --require rubocop-rspec --auto-correct --enable-pending-cops"
],
"*.rake": [
"bundle exec rubocop --require rubocop-rspec --auto-correct"
"bundle exec rubocop --require rubocop-rspec --auto-correct --enable-pending-cops"
],
"app/**/*.html.erb": [
"bundle exec erblint --autocorrect"

View file

@ -3,7 +3,8 @@ require "rails_helper"
describe DisplayAdHelper, type: :helper do
describe ".display_ads_placement_area_options_array" do
it "returns proper human value" do
expect(helper.display_ads_placement_area_options_array[1]).to eq ["Sidebar Left (Second Position)", "sidebar_left_2"]
expect(helper.display_ads_placement_area_options_array[1]).to eq ["Sidebar Left (Second Position)",
"sidebar_left_2"]
end
end
end

View file

@ -106,7 +106,7 @@ RSpec.describe CodesandboxTag, type: :liquid_tag do
expect(liquid.render).to include("<iframe")
end
it "accepts a vaild id with special_characters of / . @ % _ " do
it "accepts a vaild id with special_characters of / . @ % _" do
liquid = generate_tag(valid_id_with_special_characters)
expect(liquid.render).to include("<iframe")
end

View file

@ -150,7 +150,7 @@ RSpec.describe Organization, type: :model do
expect(organization.errors[:slug].to_s.include?("reserved")).to be true
end
it "takes organization slug into account " do
it "takes organization slug into account" do
create(:user, username: "lightalloy")
organization = build(:organization, slug: "lightalloy")
expect(organization).not_to be_valid

View file

@ -27,7 +27,7 @@ RSpec.describe "Pages", type: :request do
page.save! # Trigger processing of page.body_html
end
it "returns json data " do
it "returns json data" do
get "/page/#{page.slug}"
expect(response.media_type).to eq("application/json")

View file

@ -72,7 +72,6 @@ RSpec.describe "Stories::TaggedArticlesIndex", type: :request do
expect { get "/t/#{tag.name}" }.not_to raise_error(ActiveRecord::RecordNotFound)
end
it "renders page with top/week etc." do
get "/t/#{tag.name}/top/week"
expect(response.body).to include(tag.name)

View file

@ -62,7 +62,8 @@ RSpec.describe "StoriesIndex", type: :request do
it "renders all display_ads of different placements when published and approved" do
org = create(:organization)
ad = create(:display_ad, published: true, approved: true, organization: org, placement_area: "sidebar_left")
second_left_ad = create(:display_ad, published: true, approved: true, organization: org, placement_area: "sidebar_left_2")
second_left_ad = create(:display_ad, published: true, approved: true, organization: org,
placement_area: "sidebar_left_2")
right_ad = create(:display_ad, published: true, approved: true, placement_area: "sidebar_right",
organization: org)
@ -86,7 +87,8 @@ RSpec.describe "StoriesIndex", type: :request do
it "renders only one display ad of placement" do
org = create(:organization)
left_ad = create(:display_ad, published: true, approved: true, placement_area: "sidebar_left", organization: org)
second_left_ad = create(:display_ad, published: true, approved: true, placement_area: "sidebar_left", organization: org)
second_left_ad = create(:display_ad, published: true, approved: true, placement_area: "sidebar_left",
organization: org)
get "/"
expect(response.body).to include(left_ad.processed_html).or(include(second_left_ad.processed_html))

View file

@ -72,7 +72,7 @@ RSpec.describe Html::Parser, type: :service do
end
it "detects height and width" do
allow(FastImage).to receive(:size).and_return([100,200])
allow(FastImage).to receive(:size).and_return([100, 200])
html = "<img src='https://image.com/image.jpg'>"
parsed_html = described_class.new(html).prefix_all_images(350, synchronous_detail_detection: true).html
expect(parsed_html).to include("height=\"200\"")

View file

@ -42,7 +42,7 @@ RSpec.describe "User visits a homepage", type: :system do
visit "/"
end
it "shows correct articles " do
it "shows correct articles" do
expect(page).to have_selector(".crayons-story", count: 2)
expect(page).to have_text(article.title)
expect(page).to have_text(article2.title)

View file

@ -25,7 +25,7 @@ RSpec.describe "User comments", type: :system do
end
context "when user has too many comments" do
it "show user's last comments ", js: true do
it "show user's last comments", js: true do
stub_const("CommentsHelper::MAX_COMMENTS_TO_RENDER", 1)
visit "/user3000/comments"
within("#substories div.profile-comment-card") do

View file

@ -44,7 +44,7 @@ RSpec.describe GithubRepos::RepoSyncWorker, type: :worker do
end
end
it "does not touch repo user again if recently updated " do
it "does not touch repo user again if recently updated" do
repo.update_column(:updated_at, 1.day.ago)
worker.perform(repo.id)
old_updated_at = repo.user.reload.github_repos_updated_at

View file

@ -14,7 +14,7 @@ RSpec.describe Notifications::MentionWorker, type: :worker do
expect(service).to have_received(:call).with(mention).once
end
it "does nothing for non-existent mention " do
it "does nothing for non-existent mention" do
worker.perform(nil)
expect(service).not_to have_received(:call)
end

View file

@ -10,7 +10,7 @@ RSpec.describe Notifications::MilestoneWorker, type: :worker do
allow(Notifications::Milestone::Send).to receive(:call)
end
specify "fetch article id only if :article_id key in hash " do
specify "fetch article id only if :article_id key in hash" do
allow(Article).to receive(:find_by)
worker.perform("Reaction", 456)
expect(Article).to have_received(:find_by).with(id: 456)