Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RuboCop empty lines layout config #8014

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 10 additions & 10 deletions .ruby-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require:
- rubocop-performance
- rubocop-rails
- ./lib/custom_cops/empty_lines_around_rescued_exceptions.rb

AllCops:
TargetRubyVersion: 3.0
Expand All @@ -21,6 +22,7 @@ AllCops:
Exclude:
- commonlib/**/*
- db/schema.rb
- lib/themes/**/*
- node_modules/**/*
- vendor/**/*
- ".git/**/*"
Expand Down Expand Up @@ -136,13 +138,13 @@ Layout/EmptyComment:
Enabled: false

Layout/EmptyLineAfterGuardClause:
Enabled: false
Enabled: true

Layout/EmptyLineAfterMagicComment:
Enabled: false
Enabled: true

Layout/EmptyLineAfterMultilineCondition:
Enabled: false
Enabled: false # we prefer EmptyLinesAroundRescuedExceptions instead

Layout/EmptyLineBetweenDefs:
Enabled: true
Expand All @@ -154,24 +156,22 @@ Layout/EmptyLinesAroundAccessModifier:
Enabled: true

Layout/EmptyLinesAroundArguments:
Enabled: false
Enabled: true

Layout/EmptyLinesAroundAttributeAccessor:
Enabled: false
Enabled: true

Layout/EmptyLinesAroundBeginBody:
Enabled: false
Enabled: true

Layout/EmptyLinesAroundBlockBody:
Enabled: true
Exclude:
- spec/**/*

Layout/EmptyLinesAroundClassBody:
Enabled: true

Layout/EmptyLinesAroundExceptionHandlingKeywords:
Enabled: false
Enabled: false # we prefer EmptyLinesAroundRescuedExceptions instead

Layout/EmptyLinesAroundMethodBody:
Enabled: true
Expand Down Expand Up @@ -239,7 +239,7 @@ Layout/LeadingCommentSpace:
Enabled: true

Layout/LeadingEmptyLines:
Enabled: false
Enabled: true

Layout/LineContinuationLeadingSpace:
Enabled: false
Expand Down
1 change: 0 additions & 1 deletion app/controllers/admin_censor_rule_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Email: [email protected]; WWW: http://www.mysociety.org/

class AdminCensorRuleController < AdminController

before_action :set_editor, only: [:create, :update]
before_action :set_censor_rule, only: [:edit, :update, :destroy]
before_action :set_subject_and_censor_rule_and_form_url, only: [:new, :create]
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/admin_comment_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Email: [email protected]; WWW: http://www.mysociety.org/

class AdminCommentController < AdminController

before_action :set_comment, only: [:edit, :update]

def index
Expand All @@ -30,6 +29,7 @@ def edit

def update
raise ActiveRecord::RecordNotFound if cannot? :admin, @comment

old_body = @comment.body.dup
old_visible = @comment.visible
old_attention = @comment.attention_requested
Expand Down Expand Up @@ -75,5 +75,4 @@ def set_comment
def comment_hidden?(old_visibility, old_body)
[email protected] && old_visibility && old_body == @comment.body
end

end
2 changes: 0 additions & 2 deletions app/controllers/admin_general_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def timeline
# Recent events
@events_title = get_events_title


@events = WillPaginate::Collection.create((params[:page] or 1), 100) do |pager|
# create a hash for each model type being returned
info_request_event_ids = {}
Expand Down Expand Up @@ -140,7 +139,6 @@ def timeline
# set the total entries for the page to the overall number of results
pager.total_entries = timestamps.size
end

end

def stats
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/admin_holiday_imports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class AdminHolidayImportsController < AdminController

def new
@holiday_import = HolidayImport.new(holiday_import_params)
@holiday_import.populate if @holiday_import.valid?
Expand Down Expand Up @@ -30,5 +29,4 @@ def holiday_import_params
{}
end
end

end
2 changes: 0 additions & 2 deletions app/controllers/admin_holidays_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class AdminHolidaysController < AdminController

before_action :set_holiday, only: [:edit, :update, :destroy]

def index
Expand Down Expand Up @@ -67,5 +66,4 @@ def holiday_params
def set_holiday
@holiday = Holiday.find(params[:id])
end

end
1 change: 0 additions & 1 deletion app/controllers/admin_incoming_message_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class AdminIncomingMessageController < AdminController

before_action :set_incoming_message, only: [:edit, :update, :destroy, :redeliver]
before_action :set_info_request, :check_info_request

Expand Down
3 changes: 1 addition & 2 deletions app/controllers/admin_info_request_event_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
# Email: [email protected]; WWW: http://www.mysociety.org/

class AdminInfoRequestEventController < AdminController

before_action :set_info_request_event, only: [:update]

# used so due dates get fixed
def update
if @info_request_event.event_type != 'response'
raise "can only mark responses as requires clarification"
end

@info_request_event.described_state = 'waiting_clarification'
@info_request_event.calculated_state = 'waiting_clarification'
# TODO: deliberately don't update described_at so doesn't reenter search?
Expand All @@ -29,5 +29,4 @@ def update
def set_info_request_event
@info_request_event = InfoRequestEvent.find(params[:id])
end

end
1 change: 0 additions & 1 deletion app/controllers/admin_outgoing_message_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class AdminOutgoingMessageController < AdminController

before_action :set_outgoing_message, only: [:edit, :destroy, :update, :resend]
before_action :set_info_request, :check_info_request
before_action :set_is_initial_message, only: [:edit, :destroy]
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/admin_public_body_categories_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class AdminPublicBodyCategoriesController < AdminController

include TranslatableParams

before_action :set_public_body_category, only: [:edit, :update, :destroy]
Expand Down Expand Up @@ -104,5 +103,4 @@ def public_body_category_params
def set_public_body_category
@public_body_category = PublicBodyCategory.find(params[:id])
end

end
5 changes: 3 additions & 2 deletions app/controllers/admin_public_body_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Email: [email protected]; WWW: http://www.mysociety.org/

class AdminPublicBodyController < AdminController

include TranslatableParams

before_action :set_public_body, only: [:edit, :update, :destroy]
Expand Down Expand Up @@ -191,6 +190,7 @@ def import_csv
AlaveteliLocalization.
available_locales)
raise "dry run mismatched real run" if !errors.empty?

notes.push("Import was successful.")
end
end
Expand Down Expand Up @@ -219,10 +219,12 @@ def retrieve_csv_data(tempfile_name)
unless /csv_upload-\d{8}-\d{1,5}/.match(tempfile_name)
raise "Invalid filename in upload_csv: #{tempfile_name}"
end

tempfile_path = File.join(Dir.tmpdir, tempfile_name)
unless File.exist?(tempfile_path)
raise "Missing file in upload_csv: #{tempfile_name}"
end

csv_contents = File.read(tempfile_path)
File.delete(tempfile_path)
csv_contents
Expand Down Expand Up @@ -278,5 +280,4 @@ def public_body_params
def set_public_body
@public_body = PublicBody.find(params[:id])
end

end
2 changes: 0 additions & 2 deletions app/controllers/admin_public_body_headings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class AdminPublicBodyHeadingsController < AdminController

include TranslatableParams

before_action :set_public_body_heading, only: [:edit, :update, :destroy]
Expand Down Expand Up @@ -118,5 +117,4 @@ def public_body_heading_params
def set_public_body_heading
@public_body_heading = PublicBodyHeading.find(params[:id])
end

end
2 changes: 0 additions & 2 deletions app/controllers/admin_request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Email: [email protected]; WWW: http://www.mysociety.org/

class AdminRequestController < AdminController

before_action :set_info_request, :check_info_request, only: %i[
show edit update destroy move generate_upload_url hide
]
Expand Down Expand Up @@ -44,7 +43,6 @@ def update
old_tag_string = @info_request.tag_string
old_comments_allowed = @info_request.comments_allowed


if @info_request.update(info_request_params)
@info_request.log_event(
'edit',
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/admin_spam_addresses_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class AdminSpamAddressesController < AdminController

before_action :set_spam_address, only: [:destroy]

def index
Expand Down Expand Up @@ -37,5 +36,4 @@ def spam_address_params
def set_spam_address
@spam_address = SpamAddress.find(params[:id])
end

end
2 changes: 0 additions & 2 deletions app/controllers/admin_track_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Email: [email protected]; WWW: http://www.mysociety.org/

class AdminTrackController < AdminController

before_action :set_track_thing, only: [:destroy]

def index
Expand All @@ -32,5 +31,4 @@ def destroy
def set_track_thing
@track_thing = TrackThing.find(params[:id])
end

end
1 change: 0 additions & 1 deletion app/controllers/admin_user_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ def check_role_requirements
end
render action: 'edit' and return false
end

end

def set_admin_user
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/alaveteli_pro/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Email: [email protected]; WWW: http://www.mysociety.org/

class AlaveteliPro::BaseController < ApplicationController

before_action :pro_user_authenticated?
before_action :set_in_pro_area

Expand Down Expand Up @@ -45,5 +44,4 @@ def pro_user_authenticated?(reason_params = nil)
def set_in_pro_area
@in_pro_area = true
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def update_bodies
when 'remove'
public_body = PublicBody.find(update_bodies_params[:public_body_id])
raise ActiveRecord::RecordNotFound unless @draft

@draft.public_bodies.delete(public_body)
@draft.destroy! if @draft.public_bodies.empty?
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def create_batch
flash[:notice] = _('Your requests will now be private ' \
'until {{expiry_date}}.',
expiry_date: new_expiry_date)

rescue ActiveRecord::RecordInvalid
flash[:error] = _("Sorry, something went wrong updating your " \
"requests' privacy settings, please try again.")
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/alaveteli_pro/embargoes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def create
# shouldn't be reachable because CanCan should catch it, but just in case
raise PermissionDenied
end

@embargo = AlaveteliPro::Embargo.new(embargo_params)
if @embargo.save
flash[:notice] = _("Your request will now be private on " \
Expand All @@ -37,6 +38,7 @@ def destroy
@info_request = @embargo.info_request
# Embargoes cannot be updated individually on batch requests
raise PermissionDenied if @info_request.info_request_batch_id

if @embargo.destroy
@info_request.log_event('expire_embargo', {})
flash[:notice] = _("Your request is now public!")
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/alaveteli_pro/info_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def index
@per_page = 10
@request_summaries = request_summaries.paginate page: @page,
per_page: @per_page

end

def new
Expand Down Expand Up @@ -64,20 +63,21 @@ def show_errors
render "new"
end


def all_models_valid?
@info_request.valid? && @outgoing_message.valid? && \
(@embargo.nil? || @embargo.present? && @embargo.valid?)
end

def set_draft
return unless params[:draft_id]

@draft_info_request =
current_user.draft_info_requests.find(params[:draft_id])
end

def set_public_body
return unless params[:public_body]

@public_body = PublicBody.find_by_url_name(params[:public_body])
end

Expand All @@ -102,6 +102,7 @@ def create_initial_objects

def destroy_draft
return unless params[:draft_id]

current_user.draft_info_requests.destroy(params[:draft_id])
end

Expand Down
2 changes: 0 additions & 2 deletions app/controllers/alaveteli_pro/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Email: [email protected]; WWW: http://www.mysociety.org/

class AlaveteliPro::PagesController < AlaveteliPro::BaseController

skip_before_action :pro_user_authenticated?

def show
Expand All @@ -15,5 +14,4 @@ def show
raise ActiveRecord::RecordNotFound
end
end

end
2 changes: 0 additions & 2 deletions app/controllers/alaveteli_pro/payment_methods_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def update
Stripe::AuthenticationError,
Stripe::APIConnectionError,
Stripe::StripeError => e

if send_exception_notifications?
ExceptionNotifier.notify_exception(e, env: request.env)
end
Expand All @@ -41,5 +40,4 @@ def authenticate
email_subject: _('To update your payment details')
)
end

end
Loading