Fix all Style/BracesAroundHashParameters rubocop issues and remove them from rubocop_todo list

This commit is contained in:
Bertocq
2017-06-25 15:57:05 +02:00
parent d2a06f99bf
commit 2fa92937d2
16 changed files with 47 additions and 65 deletions

View File

@@ -165,22 +165,6 @@ Layout/AlignParameters:
- 'spec/models/user_spec.rb'
- 'spec/rails_helper.rb'
# Offense count: 19
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: braces, no_braces, context_dependent
Style/BracesAroundHashParameters:
Exclude:
- 'app/controllers/valuation/spending_proposals_controller.rb'
- 'app/models/concerns/searchable.rb'
- 'app/models/verification/residence.rb'
- 'lib/manager_authenticator.rb'
- 'spec/controllers/management/users_controller_spec.rb'
- 'spec/features/admin/spending_proposals_spec.rb'
- 'spec/lib/manager_authenticator_spec.rb'
- 'spec/models/residence_spec.rb'
- 'spec/models/user_spec.rb'
# Offense count: 57
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact

View File

@@ -60,7 +60,7 @@ class Admin::Poll::PollsController < Admin::BaseController
end
def search_questions
@questions = ::Poll::Question.where("poll_id IS ? OR poll_id != ?", nil, @poll.id).search({search: @search}).order(title: :asc)
@questions = ::Poll::Question.where("poll_id IS ? OR poll_id != ?", nil, @poll.id).search(search: @search).order(title: :asc)
respond_to do |format|
format.js
end

View File

@@ -58,7 +58,7 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
end
def params_for_current_valuator
params.merge({valuator_id: current_user.valuator.id})
params.merge(valuator_id: current_user.valuator.id)
end
def restrict_access_to_assigned_items

View File

@@ -5,15 +5,14 @@ module Searchable
include PgSearch
include SearchCache
pg_search_scope :pg_search, {
against: :ignored, # not used since using a tsvector_column
using: {
tsearch: { tsvector_column: 'tsv', dictionary: "spanish", prefix: true }
},
ignoring: :accents,
ranked_by: '(:tsearch)',
order_within_rank: (self.column_names.include?('cached_votes_up') ? "#{self.table_name}.cached_votes_up DESC" : nil)
}
pg_search_scope :pg_search,
against: :ignored, # not used since using a tsvector_column
using: {
tsearch: { tsvector_column: 'tsv', dictionary: "spanish", prefix: true }
},
ignoring: :accents,
ranked_by: '(:tsearch)',
order_within_rank: (self.column_names.include?('cached_votes_up') ? "#{self.table_name}.cached_votes_up DESC" : nil)
end
end
end

View File

@@ -43,14 +43,13 @@ class Officing::Residence
end
def store_failed_census_call
FailedCensusCall.create({
FailedCensusCall.create(
user: user,
document_number: document_number,
document_type: document_type,
year_of_birth: year_of_birth,
poll_officer: officer
})
document_type: document_type,
year_of_birth: year_of_birth,
poll_officer: officer
)
end
def user_exists?

View File

@@ -47,13 +47,13 @@ class Verification::Residence
end
def store_failed_attempt
FailedCensusCall.create({
FailedCensusCall.create(
user: user,
document_number: document_number,
document_type: document_type,
date_of_birth: date_of_birth,
postal_code: postal_code
})
document_type: document_type,
date_of_birth: date_of_birth,
postal_code: postal_code
)
end
def geozone

View File

@@ -25,7 +25,7 @@ class ManagerAuthenticator
parsed_response = parser.parse((response[:get_applications_user_list_response][:get_applications_user_list_return]))
aplication_value = parsed_response["APLICACIONES"]["APLICACION"]
# aplication_value from UWEB can be an array of hashes or a hash
aplication_value.include?({"CLAVE_APLICACION" => application_key}) || aplication_value["CLAVE_APLICACION"] == application_key
aplication_value.include?("CLAVE_APLICACION" => application_key) || aplication_value["CLAVE_APLICACION"] == application_key
rescue
false
end

View File

@@ -50,7 +50,7 @@ class MigrateSpendingProposalsToInvestments
votes = ActsAsVotable::Vote.where(votable_type: 'SpendingProposal', votable_id: sp.id)
votes.each {|v| investment.vote_by({voter: v.voter, vote: 'yes'}) }
votes.each {|v| investment.vote_by(voter: v.voter, vote: 'yes') }
# Spending proposals are not commentable in Consul so we can not test this
#

View File

@@ -71,19 +71,19 @@ describe GraphqlController, type: :request do
let(:query_string) { "{ proposal(id: #{proposal.id}) { title } }" }
specify "when absent" do
get '/graphql', { query: query_string }
get '/graphql', query: query_string
expect(response).to have_http_status(:ok)
end
specify "when specified as the 'null' string" do
get '/graphql', { query: query_string, variables: 'null' }
get '/graphql', query: query_string, variables: 'null'
expect(response).to have_http_status(:ok)
end
specify "when specified as an empty string" do
get '/graphql', { query: query_string, variables: '' }
get '/graphql', query: query_string, variables: ''
expect(response).to have_http_status(:ok)
end

View File

@@ -10,7 +10,7 @@ describe Management::UsersController do
get :logout
expect(session[:manager]).to eq({user_key: "31415926", date: "20151031135905", login: "JJB033"})
expect(session[:manager]).to eq(user_key: "31415926", date: "20151031135905", login: "JJB033")
expect(session[:document_type]).to be_nil
expect(session[:document_number]).to be_nil
expect(response).to be_redirect

View File

@@ -47,7 +47,7 @@ feature 'Admin budget investments' do
budget_investment1.valuators << valuator1
budget_investment2.valuator_ids = [valuator1.id, valuator2.id]
budget_investment3.update({administrator_id: admin.id})
budget_investment3.update(administrator_id: admin.id)
visit admin_budget_budget_investments_path(budget_id: @budget.id)

View File

@@ -43,7 +43,7 @@ feature 'Admin spending proposals' do
spending_proposal1.valuators << valuator1
spending_proposal2.valuator_ids = [valuator1.id, valuator2.id]
spending_proposal3.update({administrator_id: admin.id})
spending_proposal3.update(administrator_id: admin.id)
visit admin_spending_proposals_path

View File

@@ -3,24 +3,24 @@ require 'rails_helper'
describe ManagerAuthenticator do
describe 'initialization params' do
it 'should cause auth to return false if blank login' do
authenticator = ManagerAuthenticator.new({login: "", clave_usuario: "31415926", fecha_conexion: "20151031135905"})
authenticator = ManagerAuthenticator.new(login: "", clave_usuario: "31415926", fecha_conexion: "20151031135905")
expect(authenticator.auth).to be false
end
it 'should cause auth to return false if blank user_key' do
authenticator = ManagerAuthenticator.new({login: "JJB033", clave_usuario: "", fecha_conexion: "20151031135905"})
authenticator = ManagerAuthenticator.new(login: "JJB033", clave_usuario: "", fecha_conexion: "20151031135905")
expect(authenticator.auth).to be false
end
it 'should cause auth to return false if blank date' do
authenticator = ManagerAuthenticator.new({login: "JJB033", clave_usuario: "31415926", fecha_conexion: ""})
authenticator = ManagerAuthenticator.new(login: "JJB033", clave_usuario: "31415926", fecha_conexion: "")
expect(authenticator.auth).to be false
end
end
describe '#auth' do
before(:all) do
@authenticator = ManagerAuthenticator.new({login: "JJB033", clave_usuario: "31415926", fecha_conexion: "20151031135905"})
@authenticator = ManagerAuthenticator.new(login: "JJB033", clave_usuario: "31415926", fecha_conexion: "20151031135905")
end
it 'should return false if not manager_exists' do
@@ -47,7 +47,7 @@ describe ManagerAuthenticator do
describe 'SOAP' do
before(:all) do
@authenticator = ManagerAuthenticator.new({login: "JJB033", clave_usuario: "31415926", fecha_conexion: "20151031135905"})
@authenticator = ManagerAuthenticator.new(login: "JJB033", clave_usuario: "31415926", fecha_conexion: "20151031135905")
end
it 'should call the verification user method' do

View File

@@ -44,12 +44,12 @@ describe Officing::Residence do
describe "new" do
it "should upcase document number" do
residence = Officing::Residence.new({document_number: "x1234567z"})
residence = Officing::Residence.new(document_number: "x1234567z")
expect(residence.document_number).to eq("X1234567Z")
end
it "should remove all characters except numbers and letters" do
residence = Officing::Residence.new({document_number: " 12.345.678 - B"})
residence = Officing::Residence.new(document_number: " 12.345.678 - B")
expect(residence.document_number).to eq("12345678B")
end
end
@@ -108,13 +108,13 @@ describe Officing::Residence do
residence.save
expect(FailedCensusCall.count).to eq(1)
expect(FailedCensusCall.first).to have_attributes({
expect(FailedCensusCall.first).to have_attributes(
user_id: residence.user.id,
poll_officer_id: residence.officer.id,
document_number: "12345678Z",
document_type: "1",
year_of_birth: Time.current.year
})
)
end
end

View File

@@ -13,19 +13,19 @@ describe Verification::Residence do
describe "dates" do
it "should be valid with a valid date of birth" do
residence = Verification::Residence.new({"date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => "1980"})
residence = Verification::Residence.new("date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => "1980")
expect(residence.errors[:date_of_birth].size).to eq(0)
end
it "should not be valid without a date of birth" do
residence = Verification::Residence.new({"date_of_birth(3i)" => "", "date_of_birth(2i)" => "", "date_of_birth(1i)" => ""})
residence = Verification::Residence.new("date_of_birth(3i)" => "", "date_of_birth(2i)" => "", "date_of_birth(1i)" => "")
expect(residence).to_not be_valid
expect(residence.errors[:date_of_birth]).to include("can't be blank")
end
end
it "should validate user has allowed age" do
residence = Verification::Residence.new({"date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => "#{5.years.ago.year}"})
residence = Verification::Residence.new("date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => "#{5.years.ago.year}")
expect(residence).to_not be_valid
expect(residence.errors[:date_of_birth]).to include("You don't have the required age to participate")
end
@@ -50,12 +50,12 @@ describe Verification::Residence do
describe "new" do
it "should upcase document number" do
residence = Verification::Residence.new({document_number: "x1234567z"})
residence = Verification::Residence.new(document_number: "x1234567z")
expect(residence.document_number).to eq("X1234567Z")
end
it "should remove all characters except numbers and letters" do
residence = Verification::Residence.new({document_number: " 12.345.678 - B"})
residence = Verification::Residence.new(document_number: " 12.345.678 - B")
expect(residence.document_number).to eq("12345678B")
end
end
@@ -99,13 +99,13 @@ describe Verification::Residence do
residence.save
expect(FailedCensusCall.count).to eq(1)
expect(FailedCensusCall.first).to have_attributes({
expect(FailedCensusCall.first).to have_attributes(
user_id: residence.user.id,
document_number: "12345678Z",
document_type: "1",
date_of_birth: Date.new(1980, 12, 31),
postal_code: "28001"
})
)
end
end

View File

@@ -434,13 +434,13 @@ describe User do
describe "document_number" do
it "should upcase document number" do
user = User.new({document_number: "x1234567z"})
user = User.new(document_number: "x1234567z")
user.valid?
expect(user.document_number).to eq("X1234567Z")
end
it "should remove all characters except numbers and letters" do
user = User.new({document_number: " 12.345.678 - B"})
user = User.new(document_number: " 12.345.678 - B")
user.valid?
expect(user.document_number).to eq("12345678B")
end