Merge pull request #4168 from consul/dependabot/bundler/rubocop-0.92.0

Bump rubocop from 0.83.0 to 0.91.0
This commit is contained in:
Javi Martín
2020-10-23 14:19:55 +02:00
committed by GitHub
24 changed files with 70 additions and 48 deletions

View File

@@ -1,6 +1,6 @@
rubocop:
config_file: .rubocop.yml
version: 0.83.0
version: 0.91.0
scss:
config_file: .scss-lint.yml
erblint:

View File

@@ -15,6 +15,7 @@ Bundler/DuplicatedGem:
Bundler/OrderedGems:
Enabled: true
ConsiderPunctuation: true
Capybara/CurrentPathExpectation:
Enabled: true
@@ -165,9 +166,15 @@ Layout/TrailingWhitespace:
Lint/AmbiguousRegexpLiteral:
Enabled: true
Lint/ConstantDefinitionInBlock:
Enabled: true
Lint/DuplicateMethods:
Enabled: true
Lint/EmptyFile:
Enabled: true
Lint/LiteralAsCondition:
Enabled: true
@@ -367,9 +374,15 @@ Security/JSONLoad:
Security/YAMLLoad:
Enabled: true
Style/AccessorGrouping:
Enabled: true
Style/AndOr:
Enabled: true
Style/ArrayCoercion:
Enabled: true
Style/BlockDelimiters:
Enabled: true
@@ -406,6 +419,9 @@ Style/PercentLiteralDelimiters:
Style/Proc:
Enabled: true
Style/RedundantFileExtensionInRequire:
Enabled: true
Style/RedundantFreeze:
Enabled: true

View File

@@ -102,7 +102,7 @@ group :development do
gem "erb_lint", require: false
gem "github_changelog_generator", "~> 1.15.2"
gem "mdl", "~> 0.11.0", require: false
gem "rubocop", "~> 0.83.0", require: false
gem "rubocop", "~> 0.91.0", require: false
gem "rubocop-performance", "~> 1.7.1", require: false
gem "rubocop-rails", "~> 2.3.2", require: false
gem "rubocop-rspec", "~> 1.35.0", require: false

View File

@@ -493,13 +493,17 @@ GEM
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.3)
rubocop (0.83.0)
rubocop (0.91.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.4.0, < 1.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.7.1)
parser (>= 2.7.1.5)
rubocop-performance (1.7.1)
rubocop (>= 0.82.0)
rubocop-rails (2.3.2)
@@ -707,7 +711,7 @@ DEPENDENCIES
rinku (~> 2.0.6)
rollbar (~> 3.0.0)
rspec-rails (~> 4.0)
rubocop (~> 0.83.0)
rubocop (~> 0.91.0)
rubocop-performance (~> 1.7.1)
rubocop-rails (~> 2.3.2)
rubocop-rspec (~> 1.35.0)

View File

@@ -6,10 +6,10 @@ module Translatable
def translation_params(resource_model, options = {})
attributes = [:id, :locale, :_destroy]
if options[:only]
attributes += [*options[:only]]
attributes += Array(options[:only])
else
attributes += resource_model.translated_attribute_names
end
{ translations_attributes: attributes - [*options[:except]] }
{ translations_attributes: attributes - Array(options[:except]) }
end
end

View File

@@ -14,7 +14,7 @@ module FollowablesHelper
return unless follow.followable.present?
followable = follow.followable
partial = followable_class_name(followable) + "_follow"
partial = "#{followable_class_name(followable)}_follow"
locals = { followable_class_name(followable).to_sym => followable }
render partial, locals

View File

@@ -3,7 +3,7 @@ module TracksHelper
track_data = ""
prefix = " data-track-event-"
data.each do |key, value|
track_data = track_data + prefix + key.to_s + "=" + value + " "
track_data = "#{track_data}#{prefix}#{key}=#{value} "
end
content_for :track_event do
track_data

View File

@@ -21,6 +21,6 @@ module VerificationHelper
data_to_mask = match[2]
email_provider = match[3]
data_to_display + "*" * data_to_mask.size + "@" + email_provider
"#{data_to_display}#{"*" * data_to_mask.size}@#{email_provider}"
end
end

View File

@@ -7,9 +7,9 @@ module VotesHelper
return "0%" if debate.total_votes == 0
if vote == "likes"
debate_percentage_of_likes(debate).to_s + "%"
"#{debate_percentage_of_likes(debate)}%"
elsif vote == "dislikes"
(100 - debate_percentage_of_likes(debate)).to_s + "%"
"#{100 - debate_percentage_of_likes(debate)}%"
end
end

View File

@@ -89,9 +89,7 @@ class User < ApplicationRecord
accepts_nested_attributes_for :organization, update_only: true
attr_accessor :skip_password_validation
attr_accessor :use_redeemable_code
attr_accessor :login
attr_accessor :skip_password_validation, :use_redeemable_code, :login
scope :administrators, -> { joins(:administrator) }
scope :moderators, -> { joins(:moderator) }

View File

@@ -1,9 +1,7 @@
class Verification::Management::Email
include ActiveModel::Model
attr_accessor :document_type
attr_accessor :document_number
attr_accessor :email
attr_accessor :document_type, :document_number, :email
validates :document_type, :document_number, :email, presence: true
validates :email, format: { with: Devise.email_regexp }, allow_blank: true

View File

@@ -129,4 +129,4 @@ class Rails::Engine
end
end
require "./config/application_custom.rb"
require "./config/application_custom"

View File

@@ -7,7 +7,7 @@ section "Creating Admin Notifications & Templates" do
"people will discuss & support it.",
body_es: "Recuerda que puedes crear propuestas y los ciudadanos las debatirán y apoyarán.",
link: Setting["url"] + "/proposals",
link: "#{Setting["url"]}/proposals",
segment_recipient: "administrators"
).deliver

View File

@@ -17,7 +17,7 @@ section "Creating Users" do
def unique_document_number
@document_number ||= 12345678
@document_number += 1
"#{@document_number}#{[*"A".."Z"].sample}"
"#{@document_number}#{("A".."Z").to_a.sample}"
end
admin = create_user("admin@consul.dev", "admin")

View File

@@ -1,9 +1,7 @@
require "rails_helper"
describe HasFilters do
class FakeController < ActionController::Base; end
controller(FakeController) do
controller(ActionController::Base) do
include HasFilters
has_filters ["all", "pending", "reviewed"], only: :index

View File

@@ -1,9 +1,7 @@
require "rails_helper"
describe HasOrders do
class FakeController < ActionController::Base; end
controller(FakeController) do
controller(ActionController::Base) do
include HasOrders
has_orders ["created_at", "votes_count", "flags_count", "relevance"], only: :index
has_orders ->(c) { ["votes_count", "flags_count"] }, only: :new

View File

@@ -1,10 +1,14 @@
require "rails_helper"
describe ConsulFormBuilder do
class DummyModel
include ActiveModel::Model
OPTIONS = %w[Good Bad Ugly].freeze
attr_accessor :title, :quality
before do
dummy_model = Class.new do
include ActiveModel::Model
attr_accessor :title, :quality
end
stub_const("DummyModel", dummy_model)
stub_const("DummyModel::OPTIONS", %w[Good Bad Ugly].freeze)
end
let(:builder) { ConsulFormBuilder.new(:dummy, DummyModel.new, ActionView::Base.new, {}) }

View File

@@ -1,12 +1,16 @@
require "rails_helper"
describe Statisticable do
class DummyStats
include Statisticable
before do
dummy_stats = Class.new do
include Statisticable
def participants
User.all
def participants
User.all
end
end
stub_const("DummyStats", dummy_stats)
end
let(:stats) { DummyStats.new(nil) }

View File

@@ -235,12 +235,11 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
end
login_as user_to_login
visit send(path, arguments)
FILENAMES ||= %w[clippy empty logo].freeze
send(fill_resource_method_name) if fill_resource_method_name
documentable.class.max_documents_allowed.times.zip(FILENAMES).each do |_n, fn|
documentable_attach_new_file(Rails.root.join("spec/fixtures/files/#{fn}.pdf"))
%w[clippy empty logo].take(documentable.class.max_documents_allowed).each do |filename|
documentable_attach_new_file(Rails.root.join("spec/fixtures/files/#{filename}.pdf"))
end
click_on submit_button

View File

@@ -22,7 +22,7 @@ describe "Homepage" do
scenario "Admin menu links to homepage path" do
visit new_admin_widget_card_path(header_card: true)
click_link Setting["org_name"] + " Administration"
click_link "#{Setting["org_name"]} Administration"
expect(page).to have_current_path(admin_root_path)
end

View File

@@ -58,7 +58,7 @@ describe "Documents" do
scenario "Create" do
visit new_admin_site_customization_document_path
attach_file("document_attachment", Rails.root + "spec/fixtures/files/logo.pdf")
attach_file("document_attachment", "#{Rails.root}/spec/fixtures/files/logo.pdf")
click_button "Upload"
expect(page).to have_content "Document uploaded succesfully"

View File

@@ -33,8 +33,7 @@ describe "Social media meta tags" do
expect(page).to have_property "og:title", with: meta_title
expect(page).to have_property "article:publisher", with: url
expect(page).to have_property "article:author", with: "https://www.facebook.com/" +
facebook_handle
expect(page).to have_property "article:author", with: "https://www.facebook.com/#{facebook_handle}"
expect(page).to have_property "og:url", with: "#{Capybara.app_host}/"
expect(page).to have_property "og:image", with: "#{Capybara.app_host}/social_media_icon.png"
expect(page).to have_property "og:site_name", with: org_name

View File

@@ -1,13 +1,17 @@
require "rails_helper"
describe "shared errors" do
class DummyModel
include ActiveModel::Model
attr_accessor :title, :description, :days
before do
dummy_model = Class.new do
include ActiveModel::Model
attr_accessor :title, :description, :days
validates :title, presence: true
validates :description, presence: true, length: { in: 10..100 }
validates :days, numericality: { greater_than: 10 }
validates :title, presence: true
validates :description, presence: true, length: { in: 10..100 }
validates :days, numericality: { greater_than: 10 }
end
stub_const("DummyModel", dummy_model)
end
it "counts the number of fields with errors" do