Add and apply Style/RedundantBegin rubocop rule
We're about to add code which might fall into the `RedundantBegin` category, so we're adding the rule in order to prevent that.
This commit is contained in:
@@ -781,6 +781,9 @@ Style/RaiseArgs:
|
|||||||
Style/RedundantArgument:
|
Style/RedundantArgument:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
Style/RedundantBegin:
|
||||||
|
Enabled: true
|
||||||
|
|
||||||
Style/RedundantCondition:
|
Style/RedundantCondition:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ class GraphqlController < ApplicationController
|
|||||||
class QueryStringError < StandardError; end
|
class QueryStringError < StandardError; end
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
begin
|
|
||||||
raise GraphqlController::QueryStringError if query_string.nil?
|
raise GraphqlController::QueryStringError if query_string.nil?
|
||||||
|
|
||||||
result = ConsulSchema.execute(
|
result = ConsulSchema.execute(
|
||||||
@@ -28,7 +27,6 @@ class GraphqlController < ApplicationController
|
|||||||
rescue ArgumentError => e
|
rescue ArgumentError => e
|
||||||
render json: { message: e.message }, status: :bad_request
|
render json: { message: e.message }, status: :bad_request
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ class Legislation::Annotation < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def store_context
|
def store_context
|
||||||
begin
|
|
||||||
html = draft_version.body_html
|
html = draft_version.body_html
|
||||||
doc = Nokogiri::HTML(html)
|
doc = Nokogiri::HTML(html)
|
||||||
|
|
||||||
@@ -42,7 +41,6 @@ class Legislation::Annotation < ApplicationRecord
|
|||||||
rescue
|
rescue
|
||||||
"<span class=annotator-hl>#{quote}</span>"
|
"<span class=annotator-hl>#{quote}</span>"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def create_first_comment
|
def create_first_comment
|
||||||
comments.create(body: text, user: author)
|
comments.create(body: text, user: author)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ class MachineLearning
|
|||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
begin
|
|
||||||
export_proposals_to_json
|
export_proposals_to_json
|
||||||
export_budget_investments_to_json
|
export_budget_investments_to_json
|
||||||
export_comments_to_json
|
export_comments_to_json
|
||||||
@@ -66,7 +65,6 @@ class MachineLearning
|
|||||||
handle_error(e)
|
handle_error(e)
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
end
|
|
||||||
handle_asynchronously :run, queue: "machine_learning"
|
handle_asynchronously :run, queue: "machine_learning"
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ end
|
|||||||
task :install_ruby do
|
task :install_ruby do
|
||||||
on roles(:app) do
|
on roles(:app) do
|
||||||
within release_path do
|
within release_path do
|
||||||
begin
|
|
||||||
current_ruby = capture(:rvm, "current")
|
current_ruby = capture(:rvm, "current")
|
||||||
rescue SSHKit::Command::Failed
|
rescue SSHKit::Command::Failed
|
||||||
after "install_ruby", "rvm1:install:rvm"
|
after "install_ruby", "rvm1:install:rvm"
|
||||||
@@ -99,12 +98,10 @@ task :install_ruby do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
task :install_node do
|
task :install_node do
|
||||||
on roles(:app) do
|
on roles(:app) do
|
||||||
with rails_env: fetch(:rails_env) do
|
with rails_env: fetch(:rails_env) do
|
||||||
begin
|
|
||||||
execute fetch(:fnm_install_node_command)
|
execute fetch(:fnm_install_node_command)
|
||||||
rescue SSHKit::Command::Failed
|
rescue SSHKit::Command::Failed
|
||||||
begin
|
begin
|
||||||
@@ -119,7 +116,6 @@ task :install_node do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
task :map_node_bins do
|
task :map_node_bins do
|
||||||
on roles(:app) do
|
on roles(:app) do
|
||||||
|
|||||||
@@ -11,14 +11,12 @@ describe Officing::VotersController do
|
|||||||
|
|
||||||
2.times.map do
|
2.times.map do
|
||||||
Thread.new do
|
Thread.new do
|
||||||
begin
|
|
||||||
post :create, params: {
|
post :create, params: {
|
||||||
voter: { poll_id: poll.id, user_id: user.id },
|
voter: { poll_id: poll.id, user_id: user.id },
|
||||||
format: :js
|
format: :js
|
||||||
}
|
}
|
||||||
rescue ActionDispatch::IllegalStateError
|
rescue ActionDispatch::IllegalStateError
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end.each(&:join)
|
end.each(&:join)
|
||||||
|
|
||||||
expect(Poll::Voter.count).to eq 1
|
expect(Poll::Voter.count).to eq 1
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ describe Polls::AnswersController do
|
|||||||
|
|
||||||
2.times.map do
|
2.times.map do
|
||||||
Thread.new do
|
Thread.new do
|
||||||
begin
|
|
||||||
post :create, params: {
|
post :create, params: {
|
||||||
question_id: question.id,
|
question_id: question.id,
|
||||||
option_id: question.question_options.find_by(title: "Answer A").id,
|
option_id: question.question_options.find_by(title: "Answer A").id,
|
||||||
@@ -16,7 +15,6 @@ describe Polls::AnswersController do
|
|||||||
}
|
}
|
||||||
rescue ActionDispatch::IllegalStateError, ActiveRecord::RecordInvalid
|
rescue ActionDispatch::IllegalStateError, ActiveRecord::RecordInvalid
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end.each(&:join)
|
end.each(&:join)
|
||||||
|
|
||||||
expect(Poll::Answer.count).to eq 1
|
expect(Poll::Answer.count).to eq 1
|
||||||
|
|||||||
@@ -187,11 +187,9 @@ describe Poll::Answer do
|
|||||||
|
|
||||||
[answer, other_answer].map do |poll_answer|
|
[answer, other_answer].map do |poll_answer|
|
||||||
Thread.new do
|
Thread.new do
|
||||||
begin
|
|
||||||
poll_answer.save_and_record_voter_participation
|
poll_answer.save_and_record_voter_participation
|
||||||
rescue ActiveRecord::RecordInvalid
|
rescue ActiveRecord::RecordInvalid
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end.each(&:join)
|
end.each(&:join)
|
||||||
|
|
||||||
expect(Poll::Voter.count).to be 1
|
expect(Poll::Voter.count).to be 1
|
||||||
|
|||||||
@@ -18,14 +18,12 @@ module GraphQLAPI
|
|||||||
def extract_fields(response, collection_name, field_chain)
|
def extract_fields(response, collection_name, field_chain)
|
||||||
fields = field_chain.split(".")
|
fields = field_chain.split(".")
|
||||||
dig(response, "data.#{collection_name}.edges").map do |node|
|
dig(response, "data.#{collection_name}.edges").map do |node|
|
||||||
begin
|
|
||||||
if fields.size > 1
|
if fields.size > 1
|
||||||
node["node"][fields.first][fields.second]
|
node["node"][fields.first][fields.second]
|
||||||
else
|
else
|
||||||
node["node"][fields.first]
|
node["node"][fields.first]
|
||||||
end
|
end
|
||||||
rescue NoMethodError
|
rescue NoMethodError
|
||||||
end
|
|
||||||
end.compact
|
end.compact
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user