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:
Javi Martín
2024-10-30 15:55:29 +01:00
parent 9f38ed6bae
commit 07202fea10
9 changed files with 109 additions and 124 deletions

View File

@@ -781,6 +781,9 @@ Style/RaiseArgs:
Style/RedundantArgument:
Enabled: true
Style/RedundantBegin:
Enabled: true
Style/RedundantCondition:
Enabled: true

View File

@@ -9,7 +9,6 @@ class GraphqlController < ApplicationController
class QueryStringError < StandardError; end
def execute
begin
raise GraphqlController::QueryStringError if query_string.nil?
result = ConsulSchema.execute(
@@ -28,7 +27,6 @@ class GraphqlController < ApplicationController
rescue ArgumentError => e
render json: { message: e.message }, status: :bad_request
end
end
private

View File

@@ -25,7 +25,6 @@ class Legislation::Annotation < ApplicationRecord
end
def store_context
begin
html = draft_version.body_html
doc = Nokogiri::HTML(html)
@@ -42,7 +41,6 @@ class Legislation::Annotation < ApplicationRecord
rescue
"<span class=annotator-hl>#{quote}</span>"
end
end
def create_first_comment
comments.create(body: text, user: author)

View File

@@ -15,7 +15,6 @@ class MachineLearning
end
def run
begin
export_proposals_to_json
export_budget_investments_to_json
export_comments_to_json
@@ -66,7 +65,6 @@ class MachineLearning
handle_error(e)
raise e
end
end
handle_asynchronously :run, queue: "machine_learning"
class << self

View File

@@ -84,7 +84,6 @@ end
task :install_ruby do
on roles(:app) do
within release_path do
begin
current_ruby = capture(:rvm, "current")
rescue SSHKit::Command::Failed
after "install_ruby", "rvm1:install:rvm"
@@ -99,12 +98,10 @@ task :install_ruby do
end
end
end
end
task :install_node do
on roles(:app) do
with rails_env: fetch(:rails_env) do
begin
execute fetch(:fnm_install_node_command)
rescue SSHKit::Command::Failed
begin
@@ -119,7 +116,6 @@ task :install_node do
end
end
end
end
task :map_node_bins do
on roles(:app) do

View File

@@ -11,14 +11,12 @@ describe Officing::VotersController do
2.times.map do
Thread.new do
begin
post :create, params: {
voter: { poll_id: poll.id, user_id: user.id },
format: :js
}
rescue ActionDispatch::IllegalStateError
end
end
end.each(&:join)
expect(Poll::Voter.count).to eq 1

View File

@@ -8,7 +8,6 @@ describe Polls::AnswersController do
2.times.map do
Thread.new do
begin
post :create, params: {
question_id: question.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
end
end
end.each(&:join)
expect(Poll::Answer.count).to eq 1

View File

@@ -187,11 +187,9 @@ describe Poll::Answer do
[answer, other_answer].map do |poll_answer|
Thread.new do
begin
poll_answer.save_and_record_voter_participation
rescue ActiveRecord::RecordInvalid
end
end
end.each(&:join)
expect(Poll::Voter.count).to be 1

View File

@@ -18,14 +18,12 @@ module GraphQLAPI
def extract_fields(response, collection_name, field_chain)
fields = field_chain.split(".")
dig(response, "data.#{collection_name}.edges").map do |node|
begin
if fields.size > 1
node["node"][fields.first][fields.second]
else
node["node"][fields.first]
end
rescue NoMethodError
end
end.compact
end
end