Fix Style/RedundantParentheses rubocop issues

This commit is contained in:
Bertocq
2017-09-25 22:44:58 +02:00
parent 2c35cbd27a
commit 22822aa173
16 changed files with 48 additions and 53 deletions

View File

@@ -668,11 +668,6 @@ Style/RedundantBegin:
- 'app/controllers/graphql_controller.rb'
- 'app/models/legislation/annotation.rb'
# Offense count: 55
# Cop supports --auto-correct.
Style/RedundantParentheses:
Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.

View File

@@ -1,7 +1,7 @@
class Admin::SettingsController < Admin::BaseController
def index
all_settings = (Setting.all).group_by { |s| s.type }
all_settings = Setting.all.group_by { |s| s.type }
@settings = all_settings['common']
@feature_flags = all_settings['feature']
@banner_styles = all_settings['banner-style']

View File

@@ -30,7 +30,7 @@ class Legislation::AnnotationsController < ApplicationController
def create
if !@process.allegations_phase.open? || @draft_version.final_version?
render(json: {}, status: :not_found) && (return)
render(json: {}, status: :not_found) && return
end
existing_annotation = @draft_version.annotations.where(

View File

@@ -12,8 +12,8 @@ module ProposalsHelper
percentage = (proposal.total_votes.to_f * 100 / Proposal.votes_needed_for_success)
case percentage
when 0 then "0%"
when 0..(0.1) then "0.1%"
when (0.1)..100 then number_to_percentage(percentage, strip_insignificant_zeros: true, precision: 1)
when 0..0.1 then "0.1%"
when 0.1..100 then number_to_percentage(percentage, strip_insignificant_zeros: true, precision: 1)
else "100%"
end
end

View File

@@ -24,7 +24,7 @@ module Graphqlable
end
def graphql_type_description
(model_name.human).to_s
model_name.human.to_s
end
end

View File

@@ -95,7 +95,7 @@ feature 'Admin::Organizations' do
click_on 'Verify'
end
expect(current_path).to eq(admin_organizations_path)
expect(page).to have_content ('Verified')
expect(page).to have_content 'Verified'
expect(organization.reload.verified?).to eq(true)
end
@@ -108,18 +108,18 @@ feature 'Admin::Organizations' do
click_on "Verified"
within("#organization_#{organization.id}") do
expect(page).to have_content ('Verified')
expect(page).to have_content 'Verified'
expect(page).to_not have_link('Verify')
expect(page).to have_link('Reject')
click_on 'Reject'
end
expect(current_path).to eq(admin_organizations_path)
expect(page).to_not have_content (organization.name)
expect(page).to_not have_content organization.name
click_on 'Rejected'
expect(page).to have_content ('Rejected')
expect(page).to have_content (organization.name)
expect(page).to have_content 'Rejected'
expect(page).to have_content organization.name
expect(organization.reload.rejected?).to eq(true)
end
@@ -137,10 +137,10 @@ feature 'Admin::Organizations' do
click_on 'Verify'
end
expect(current_path).to eq(admin_organizations_path)
expect(page).to_not have_content (organization.name)
expect(page).to_not have_content organization.name
click_on('Verified')
expect(page).to have_content (organization.name)
expect(page).to have_content organization.name
expect(organization.reload.verified?).to eq(true)
end

View File

@@ -264,7 +264,7 @@ feature 'Budget Investments' do
fill_in "budget_investment_title", with: "search"
within("div#js-suggest") do
expect(page).to have_content ("You are seeing 5 of 6 investments containing the term 'search'")
expect(page).to have_content "You are seeing 5 of 6 investments containing the term 'search'"
end
end
@@ -279,7 +279,7 @@ feature 'Budget Investments' do
fill_in "budget_investment_title", with: "item"
within('div#js-suggest') do
expect(page).to_not have_content ('You are seeing')
expect(page).to_not have_content 'You are seeing'
end
end
@@ -294,7 +294,7 @@ feature 'Budget Investments' do
fill_in "budget_investment_title", with: "search"
within('div#js-suggest') do
expect(page).to_not have_content ('You are seeing')
expect(page).to_not have_content 'You are seeing'
end
end
end

View File

@@ -27,7 +27,7 @@ feature 'Email campaigns' do
visit admin_stats_path
expect(page).to have_content "#{@campaign1.name} (1)"
expect(page).to_not have_content (@campaign2.name).to_s
expect(page).to_not have_content @campaign2.name.to_s
end
end

View File

@@ -879,7 +879,7 @@ feature 'Debates' do
check "debate_terms_of_service"
within('div#js-suggest') do
expect(page).to have_content ("You are seeing 5 of 6 debates containing the term 'debate'")
expect(page).to have_content "You are seeing 5 of 6 debates containing the term 'debate'"
end
end
@@ -895,7 +895,7 @@ feature 'Debates' do
check "debate_terms_of_service"
within('div#js-suggest') do
expect(page).to_not have_content ('You are seeing')
expect(page).to_not have_content 'You are seeing'
end
end
end

View File

@@ -24,9 +24,9 @@ feature 'Managed User' do
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content (user.username).to_s
expect(page).to have_content (user.email).to_s
expect(page).to have_content (user.document_number).to_s
expect(page).to have_content user.username.to_s
expect(page).to have_content user.email.to_s
expect(page).to have_content user.document_number.to_s
end
end
@@ -45,9 +45,9 @@ feature 'Managed User' do
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content (user.username).to_s
expect(page).to have_content (user.email).to_s
expect(page).to have_content (user.document_number).to_s
expect(page).to have_content user.username.to_s
expect(page).to have_content user.email.to_s
expect(page).to have_content user.document_number.to_s
end
end
@@ -78,9 +78,9 @@ feature 'Managed User' do
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content (user.username).to_s
expect(page).to have_content (user.email).to_s
expect(page).to have_content (user.document_number).to_s
expect(page).to have_content user.username.to_s
expect(page).to have_content user.email.to_s
expect(page).to have_content user.document_number.to_s
end
end
@@ -106,9 +106,9 @@ feature 'Managed User' do
user = User.last
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content (user.username).to_s
expect(page).to have_content (user.email).to_s
expect(page).to have_content (user.document_number).to_s
expect(page).to have_content user.username.to_s
expect(page).to have_content user.email.to_s
expect(page).to have_content user.document_number.to_s
end
end
@@ -134,8 +134,8 @@ feature 'Managed User' do
user = User.last
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content (user.username).to_s
expect(page).to have_content (user.document_number).to_s
expect(page).to have_content user.username.to_s
expect(page).to have_content user.document_number.to_s
end
end
end
@@ -151,14 +151,14 @@ feature 'Managed User' do
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content (user.username).to_s
expect(page).to have_content user.username.to_s
click_link "Change user"
end
expect(page).to have_content "User session signed out successfully."
expect(page).to_not have_content "Identified as"
expect(page).to_not have_content (user.username).to_s
expect(page).to_not have_content user.username.to_s
expect(current_path).to eq(management_root_path)
end

View File

@@ -16,9 +16,9 @@ feature 'Proposals' do
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content (user.username).to_s
expect(page).to have_content (user.email).to_s
expect(page).to have_content (user.document_number).to_s
expect(page).to have_content user.username.to_s
expect(page).to have_content user.email.to_s
expect(page).to have_content user.document_number.to_s
end
fill_in 'proposal_title', with: 'Help refugees'
@@ -119,9 +119,9 @@ feature 'Proposals' do
within(".account-info") do
expect(page).to have_content "Identified as"
expect(page).to have_content (user.username).to_s
expect(page).to have_content (user.email).to_s
expect(page).to have_content (user.document_number).to_s
expect(page).to have_content user.username.to_s
expect(page).to have_content user.email.to_s
expect(page).to have_content user.document_number.to_s
end
within(".proposals-list") do

View File

@@ -29,7 +29,7 @@ feature 'Users' do
expect(user).to be_level_three_verified
expect(user).to be_residence_verified
expect(user).to_not be_confirmed
expect(user.date_of_birth).to have_content (Date.new(1980, 12, 31))
expect(user.date_of_birth).to have_content Date.new(1980, 12, 31)
sent_token = /.*confirmation_token=(.*)".*/.match(ActionMailer::Base.deliveries.last.body.to_s)[1]
visit user_confirmation_path(confirmation_token: sent_token)
@@ -69,7 +69,7 @@ feature 'Users' do
expect(user).to be_level_three_verified
expect(user).to be_residence_verified
expect(user).to be_confirmed
expect(user.date_of_birth).to have_content (Date.new(1980, 12, 31))
expect(user.date_of_birth).to have_content Date.new(1980, 12, 31)
end
scenario 'Delete a level 2 user account from document verification page', :js do

View File

@@ -1390,7 +1390,7 @@ feature 'Proposals' do
check "proposal_terms_of_service"
within('div#js-suggest') do
expect(page).to have_content ("You are seeing 5 of 6 proposals containing the term 'search'")
expect(page).to have_content "You are seeing 5 of 6 proposals containing the term 'search'"
end
end
@@ -1406,7 +1406,7 @@ feature 'Proposals' do
check "proposal_terms_of_service"
within('div#js-suggest') do
expect(page).to_not have_content ('You are seeing')
expect(page).to_not have_content 'You are seeing'
end
end
end

View File

@@ -103,7 +103,7 @@ describe Budget::Investment do
let(:investment) { create(:budget_investment) }
it "returns the proposal id" do
expect(investment.code).to include((investment.id).to_s)
expect(investment.code).to include(investment.id.to_s)
end
it "returns the administrator id when assigned" do

View File

@@ -687,12 +687,12 @@ describe Debate do
describe "#last_week" do
it "should return debates created this week" do
debate = create(:debate)
expect(Debate.last_week.all).to include (debate)
expect(Debate.last_week.all).to include debate
end
it "should not show debates created more than a week ago" do
debate = create(:debate, created_at: 8.days.ago)
expect(Debate.last_week.all).to_not include (debate)
expect(Debate.last_week.all).to_not include debate
end
end

View File

@@ -27,7 +27,7 @@ describe Verification::Residence do
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).to_s)
"date_of_birth(1i)" => 5.years.ago.year.to_s)
expect(residence).to_not be_valid
expect(residence.errors[:date_of_birth]).to include("You don't have the required age to participate")
end