Add and apply rubocop rules for empty lines

We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
This commit is contained in:
Javi Martín
2019-10-24 15:48:37 +02:00
parent b6750e8f17
commit db97f9d08c
585 changed files with 24 additions and 1645 deletions

View File

@@ -31,6 +31,24 @@ Capybara/FeatureMethods:
FactoryBot/AttributeDefinedStatically:
Enabled: true
Layout/EmptyLineBetweenDefs:
Enabled: true
Layout/EmptyLinesAroundAccessModifier:
Enabled: true
Layout/EmptyLinesAroundBlockBody:
Enabled: true
Layout/EmptyLinesAroundClassBody:
Enabled: true
Layout/EmptyLinesAroundMethodBody:
Enabled: true
Layout/EmptyLinesAroundModuleBody:
Enabled: true
Layout/IndentationConsistency:
EnforcedStyle: indented_internal_methods

View File

@@ -32,5 +32,4 @@ class AccountController < ApplicationController
end
params.require(:account).permit(*attributes)
end
end

View File

@@ -5,5 +5,4 @@ class Admin::ActivityController < Admin::BaseController
@activity = Activity.for_render.send(@current_filter)
.order(created_at: :desc).page(params[:page])
end
end

View File

@@ -1,5 +1,4 @@
class Admin::Api::StatsController < Admin::Api::BaseController
def show
unless params[:event].present? ||
params[:visits].present? ||

View File

@@ -10,5 +10,4 @@ class Admin::BaseController < ApplicationController
def verify_administrator
raise CanCan::AccessDenied unless current_user&.administrator?
end
end

View File

@@ -61,5 +61,4 @@ class Admin::BudgetGroupsController < Admin::BaseController
valid_attributes = [:max_votable_headings]
params.require(:budget_group).permit(*valid_attributes, translation_params(Budget::Group))
end
end

View File

@@ -66,5 +66,4 @@ class Admin::BudgetHeadingsController < Admin::BaseController
valid_attributes = [:price, :population, :allow_custom_content, :latitude, :longitude]
params.require(:budget_heading).permit(*valid_attributes, translation_params(Budget::Heading))
end
end

View File

@@ -25,5 +25,4 @@ class Admin::BudgetPhasesController < Admin::BaseController
valid_attributes = [:starts_at, :ends_at, :enabled]
params.require(:budget_phase).permit(*valid_attributes, translation_params(Budget::Phase))
end
end

View File

@@ -109,5 +109,4 @@ class Admin::BudgetsController < Admin::BaseController
def load_valuators
@valuators = Valuator.includes(:user).all.order(description: :asc).order("users.email ASC")
end
end

View File

@@ -1,5 +1,4 @@
class Admin::CommentsController < Admin::BaseController
include DownloadSettingsHelper
def index
@@ -16,5 +15,4 @@ class Admin::CommentsController < Admin::BaseController
end
end
end
end

View File

@@ -1,6 +1,4 @@
class Admin::DashboardController < Admin::BaseController
def index
end
end

View File

@@ -16,5 +16,4 @@ class Admin::DebatesController < Admin::BaseController
def resource_model
Debate
end
end

View File

@@ -1,5 +1,4 @@
class Admin::GeozonesController < Admin::BaseController
respond_to :html
load_and_authorize_resource

View File

@@ -30,5 +30,4 @@ class Admin::HiddenBudgetInvestmentsController < Admin::BaseController
def load_investment
@investment = Budget::Investment.with_hidden.find(params[:id])
end
end

View File

@@ -25,5 +25,4 @@ class Admin::HiddenCommentsController < Admin::BaseController
def load_comment
@comment = Comment.not_valuations.with_hidden.find(params[:id])
end
end

View File

@@ -28,5 +28,4 @@ class Admin::HiddenDebatesController < Admin::BaseController
def load_debate
@debate = Debate.with_hidden.find(params[:id])
end
end

View File

@@ -29,5 +29,4 @@ class Admin::HiddenProposalsController < Admin::BaseController
def load_proposal
@proposal = Proposal.with_hidden.find(params[:id])
end
end

View File

@@ -29,5 +29,4 @@ class Admin::HiddenUsersController < Admin::BaseController
def load_user
@user = User.with_hidden.find(params[:id])
end
end

View File

@@ -1,5 +1,4 @@
class Admin::HomepageController < Admin::BaseController
def show
load_header
load_feeds
@@ -24,5 +23,4 @@ class Admin::HomepageController < Admin::BaseController
def load_feeds
@feeds = Widget::Feed.order("created_at")
end
end

View File

@@ -10,5 +10,4 @@ class Admin::Legislation::BaseController < Admin::BaseController
def namespace
"admin"
end
end

View File

@@ -1,5 +1,4 @@
class Admin::Legislation::ProposalsController < Admin::Legislation::BaseController
has_orders %w[id title supports], only: :index
load_and_authorize_resource :process, class: "Legislation::Process"

View File

@@ -6,5 +6,4 @@ class Admin::LocalCensusRecords::BaseController < Admin::BaseController
def namespace
"admin"
end
end

View File

@@ -1,5 +1,4 @@
class Admin::MilestoneStatusesController < Admin::BaseController
before_action :load_status, only: [:edit, :update, :destroy]
def index

View File

@@ -1,5 +1,4 @@
class Admin::NewslettersController < Admin::BaseController
def index
@newsletters = Newsletter.all
end

View File

@@ -1,5 +1,4 @@
class Admin::OfficialsController < Admin::BaseController
def index
@officials = User.officials.page(params[:page]).for_render
end
@@ -29,5 +28,4 @@ class Admin::OfficialsController < Admin::BaseController
def user_params
params.require(:user).permit(:official_position, :official_level)
end
end

View File

@@ -26,5 +26,4 @@ class Admin::OrganizationsController < Admin::BaseController
@organization.reject
redirect_to request.query_parameters.merge(action: :index)
end
end

View File

@@ -31,5 +31,4 @@ class Admin::Poll::ActivePollsController < Admin::Poll::BaseController
def active_poll_params
params.require(:active_poll).permit(translation_params(ActivePoll))
end
end

View File

@@ -6,5 +6,4 @@ class Admin::Poll::BaseController < Admin::BaseController
def namespace
"admin"
end
end

View File

@@ -1,5 +1,4 @@
class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
before_action :load_poll, except: [:create, :destroy]
def index
@@ -74,5 +73,4 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
def load_search
@search = search_params[:search]
end
end

View File

@@ -41,5 +41,4 @@ class Admin::Poll::BoothsController < Admin::Poll::BaseController
def booth_params
params.require(:poll_booth).permit(:name, :location)
end
end

View File

@@ -1,5 +1,4 @@
class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController
before_action :load_poll
before_action :redirect_if_blank_required_params, only: [:by_officer]
before_action :load_booth_assignment, only: [:create]
@@ -66,5 +65,4 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController
def load_search
@search = search_params[:search]
end
end

View File

@@ -29,5 +29,4 @@ class Admin::Poll::OfficersController < Admin::Poll::BaseController
@officer.destroy!
redirect_to admin_officers_path
end
end

View File

@@ -1,5 +1,4 @@
class Admin::Poll::ShiftsController < Admin::Poll::BaseController
before_action :load_booth
before_action :load_officer

View File

@@ -1,5 +1,4 @@
class Admin::ProposalNotificationsController < Admin::BaseController
has_filters %w[without_confirmed_hide all with_confirmed_hide], only: :index
before_action :load_proposal, only: [:confirm_hide, :restore]
@@ -28,5 +27,4 @@ class Admin::ProposalNotificationsController < Admin::BaseController
def load_proposal
@proposal_notification = ProposalNotification.with_hidden.find(params[:id])
end
end

View File

@@ -38,5 +38,4 @@ class Admin::ProposalsController < Admin::BaseController
def proposal_params
params.require(:proposal).permit(:selected)
end
end

View File

@@ -1,5 +1,4 @@
class Admin::SignatureSheetsController < Admin::BaseController
def index
@signature_sheets = SignatureSheet.all.order(created_at: :desc)
end
@@ -29,5 +28,4 @@ class Admin::SignatureSheetsController < Admin::BaseController
def signature_sheet_params
params.require(:signature_sheet).permit(:signable_type, :signable_id, :required_fields_to_verify)
end
end

View File

@@ -6,5 +6,4 @@ class Admin::SiteCustomization::BaseController < Admin::BaseController
def namespace
"admin"
end
end

View File

@@ -5,5 +5,4 @@ class Admin::SiteCustomization::CardsController < Admin::SiteCustomization::Base
@page = ::SiteCustomization::Page.find(params[:page_id])
@cards = @page.cards
end
end

View File

@@ -1,5 +1,4 @@
class Admin::SiteCustomization::DocumentsController < Admin::SiteCustomization::BaseController
def index
@documents = Document.admin.page(params[:page])
end

View File

@@ -23,7 +23,6 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
end
end
end
end
redirect_to admin_site_customization_information_texts_path,

View File

@@ -1,5 +1,4 @@
class Admin::StatsController < Admin::BaseController
def show
@event_types = Ahoy::Event.pluck(:name).uniq.sort

View File

@@ -1,5 +1,4 @@
class Admin::SystemEmailsController < Admin::BaseController
before_action :load_system_email, only: [:view, :preview_pending, :moderate_pending]
def index

View File

@@ -27,5 +27,4 @@ class Admin::TagsController < Admin::BaseController
def find_tag
@tag = Tag.category.find(params[:id])
end
end

View File

@@ -45,6 +45,7 @@ class Admin::TrackersController < Admin::BaseController
end
private
def set_tracker
@tracker = Tracker.find(params[:id])
end

View File

@@ -1,5 +1,4 @@
class Admin::ValuatorGroupsController < Admin::BaseController
def index
@groups = ValuatorGroup.all.page(params[:page])
end
@@ -48,5 +47,4 @@ class Admin::ValuatorGroupsController < Admin::BaseController
def group_params
params.require(:valuator_group).permit(:name)
end
end

View File

@@ -50,5 +50,4 @@ class Admin::ValuatorsController < Admin::BaseController
params.require(:valuator).permit(:user_id, :description, :valuator_group_id,
:can_comment, :can_edit_dossier)
end
end

View File

@@ -1,5 +1,4 @@
class Admin::VerificationsController < Admin::BaseController
def index
@users = User.incomplete_verification.page(params[:page])
end
@@ -10,5 +9,4 @@ class Admin::VerificationsController < Admin::BaseController
.for_render
render :index
end
end

View File

@@ -6,5 +6,4 @@ class Admin::Widget::BaseController < Admin::BaseController
def namespace
"admin"
end
end

View File

@@ -1,5 +1,4 @@
class Admin::Widget::FeedsController < Admin::BaseController
def update
@feed = ::Widget::Feed.find(params[:id])
@feed.update!(feed_params)
@@ -12,5 +11,4 @@ class Admin::Widget::FeedsController < Admin::BaseController
def feed_params
params.require(:widget_feed).permit(:limit)
end
end

View File

@@ -78,7 +78,6 @@ module Budgets
end
@map_location = MapLocation.load_from_heading(@heading)
end
end
end
end

View File

@@ -26,6 +26,5 @@ module Budgets
def store_referer
session[:ballot_referer] = request.referer
end
end
end

View File

@@ -25,6 +25,7 @@ module Budgets
end
private
def investments_by_heading
base = @budget.investments.winners
base = base.joins(milestones: :translations).includes(:milestones)

View File

@@ -1,6 +1,5 @@
module Budgets
class InvestmentsController < ApplicationController
include FeatureFlags
include CommentableActions
include FlagActions
@@ -187,7 +186,5 @@ module Budgets
def load_map
@map_location = MapLocation.load_from_heading(@heading)
end
end
end

View File

@@ -34,6 +34,5 @@ module Budgets
@heading = headings.find_by_slug_or_id(params[:heading_id]) || headings.first
end
end
end
end

View File

@@ -1,6 +1,5 @@
module Budgets
class StatsController < ApplicationController
before_action :load_budget
load_and_authorize_resource :budget
@@ -15,6 +14,5 @@ module Budgets
def load_budget
@budget = Budget.find_by_slug_or_id! params[:budget_id]
end
end
end

View File

@@ -25,5 +25,4 @@ class BudgetsController < ApplicationController
def load_budget
@budget = Budget.find_by_slug_or_id! params[:id]
end
end

View File

@@ -30,5 +30,4 @@ module FlagActions
instance_variable_get("@#{resource_model.to_s.downcase}")
end
end
end

View File

@@ -4,5 +4,4 @@ module ImageAttributes
def image_attributes
[:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
end
end

View File

@@ -56,5 +56,4 @@ module ModerateActions
def author_id
:author_id
end
end

View File

@@ -1,5 +1,4 @@
module Polymorphic
private
def resource
@@ -31,5 +30,4 @@ module Polymorphic
def strong_params
send("#{resource_name}_params")
end
end

View File

@@ -1,5 +1,4 @@
module RemotelyTranslatable
private
def detect_remote_translations(*args)
@@ -25,5 +24,4 @@ module RemotelyTranslatable
args.compact - [feeds] + feeds.map(&:items)
end
end

View File

@@ -53,5 +53,4 @@ module Search
params[:order] = "relevance"
end
end
end

View File

@@ -73,5 +73,4 @@ class DebatesController < ApplicationController
@recommended_debates = Debate.recommendations(current_user).sort_by_random.limit(3)
end
end
end

View File

@@ -44,5 +44,4 @@ class DirectUploadsController < ApplicationController
.permit(:resource, :resource_type, :resource_id, :resource_relation,
:attachment, :cached_attachment, attachment_attributes: [])
end
end

View File

@@ -22,5 +22,4 @@ class DocumentsController < ApplicationController
end
end
end
end

View File

@@ -24,5 +24,4 @@ class FollowsController < ApplicationController
def followable_translation_key(followable)
followable.class.name.parameterize(separator: "_")
end
end

View File

@@ -22,5 +22,4 @@ class ImagesController < ApplicationController
end
end
end
end

View File

@@ -1,5 +1,4 @@
class InstallationController < ApplicationController
skip_authorization_check
def details
@@ -19,5 +18,4 @@ class InstallationController < ApplicationController
def settings_feature_flags
Setting.where("key LIKE 'feature.%'").each_with_object({}) { |x, n| n[x.key.remove("feature.")] = x.value }
end
end

View File

@@ -108,5 +108,4 @@ class Legislation::AnnotationsController < Legislation::BaseController
end
rescue JSON::ParserError
end
end

View File

@@ -36,5 +36,4 @@ class Legislation::DraftVersionsController < Legislation::BaseController
@process.draft_versions.published
end
end
end

View File

@@ -70,5 +70,4 @@ class Legislation::ProposalsController < Legislation::BaseController
def load_successful_proposals
@proposal_successful_exists = Legislation::Proposal.successful.exists?
end
end

View File

@@ -1,5 +1,4 @@
class Management::AccountController < Management::BaseController
before_action :only_verified_users
def show
@@ -30,5 +29,4 @@ class Management::AccountController < Management::BaseController
def only_verified_users
check_verified_user t("management.account.alert.unverified_user")
end
end

View File

@@ -61,5 +61,4 @@ class Management::BaseController < ActionController::Base
@manager_logged_in = User.find_by_manager_login(session[:manager]["login"])
end
end
end

View File

@@ -69,5 +69,4 @@ class Management::Budgets::InvestmentsController < Management::BaseController
def load_categories
@categories = Tag.category.order(:name)
end
end

View File

@@ -31,5 +31,4 @@ class Management::BudgetsController < Management::BaseController
def current_manager_administrator?
session[:manager]["login"].match("admin")
end
end

View File

@@ -1,6 +1,4 @@
class Management::DashboardController < Management::BaseController
def index
end
end

View File

@@ -1,5 +1,4 @@
class Management::DocumentVerificationsController < Management::BaseController
before_action :clean_document_number, only: :check
before_action :set_document, only: :check
@@ -48,5 +47,4 @@ class Management::DocumentVerificationsController < Management::BaseController
return if params[:document_verification][:document_number].blank?
params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase
end
end

View File

@@ -1,5 +1,4 @@
class Management::EmailVerificationsController < Management::BaseController
def new
@email_verification = Verification::Management::Email.new(email_verification_params)
end
@@ -19,5 +18,4 @@ class Management::EmailVerificationsController < Management::BaseController
def email_verification_params
params.require(:email_verification).permit(:document_type, :document_number, :email)
end
end

View File

@@ -74,5 +74,4 @@ class Management::ProposalsController < Management::BaseController
def set_comment_flags(comments)
@comment_flags = managed_user ? managed_user.comment_flags(comments) : {}
end
end

View File

@@ -43,5 +43,4 @@ class Management::SessionsController < ActionController::Base
manager = ManagerAuthenticator.new(params).auth
session[:manager] = manager if manager.present?
end
end

View File

@@ -1,5 +1,4 @@
class Management::UserInvitesController < Management::BaseController
def new
end
@@ -9,5 +8,4 @@ class Management::UserInvitesController < Management::BaseController
Mailer.user_invite(email).deliver_later
end
end
end

View File

@@ -1,5 +1,4 @@
class Management::UsersController < Management::BaseController
def new
@user = User.new(user_params)
end
@@ -66,5 +65,4 @@ class Management::UsersController < Management::BaseController
def user_with_email
@user.skip_password_validation = true
end
end

View File

@@ -11,5 +11,4 @@ class Moderation::BaseController < ApplicationController
def verify_moderator
raise CanCan::AccessDenied unless current_user&.moderator? || current_user&.administrator?
end
end

View File

@@ -20,5 +20,4 @@ class Moderation::Budgets::InvestmentsController < Moderation::BaseController
def resource_model
Budget::Investment
end
end

View File

@@ -1,6 +1,4 @@
class Moderation::DashboardController < Moderation::BaseController
def index
end
end

View File

@@ -16,5 +16,4 @@ class Moderation::DebatesController < Moderation::BaseController
def resource_model
Debate
end
end

View File

@@ -1,5 +1,4 @@
class Moderation::UsersController < Moderation::BaseController
before_action :load_users, only: :index
load_and_authorize_resource
@@ -29,5 +28,4 @@ class Moderation::UsersController < Moderation::BaseController
@user.block
Activity.log(current_user, :block, @user)
end
end

View File

@@ -42,5 +42,4 @@ class NotificationsController < ApplicationController
polymorphic_hierarchy_path(notification.linkable_resource)
end
end
end

View File

@@ -1,5 +1,4 @@
class Officing::BallotSheetsController < Officing::BaseController
before_action :verify_booth
before_action :load_poll
before_action :load_officer_assignments, only: [:new, :create]
@@ -66,5 +65,4 @@ class Officing::BallotSheetsController < Officing::BaseController
def ballot_sheet_params
params.permit(:data, :poll_id, :officer_assignment_id)
end
end

View File

@@ -20,5 +20,4 @@ class Officing::BoothController < Officing::BaseController
def set_booth(booth)
session[:booth_id] = booth.id
end
end

View File

@@ -1,6 +1,4 @@
class Officing::DashboardController < Officing::BaseController
def index
end
end

View File

@@ -15,5 +15,4 @@ class Officing::PollsController < Officing::BaseController
[]
end
end
end

View File

@@ -1,5 +1,4 @@
class Officing::ResidenceController < Officing::BaseController
before_action :load_officer_assignment
before_action :verify_officer_assignment
before_action :verify_booth
@@ -23,5 +22,4 @@ class Officing::ResidenceController < Officing::BaseController
params.require(:residence).permit(:document_number, :document_type, :year_of_birth,
:date_of_birth, :postal_code)
end
end

View File

@@ -116,5 +116,4 @@ class Officing::ResultsController < Officing::BaseController
def index_params
params.permit(:booth_assignment_id, :date)
end
end

View File

@@ -38,5 +38,4 @@ class Officing::VotersController < Officing::BaseController
.where(final: false)
.first
end
end

View File

@@ -1,5 +1,4 @@
class Organizations::RegistrationsController < Devise::RegistrationsController
invisible_captcha only: [:create], honeypot: :address, scope: :user
def new
@@ -35,5 +34,4 @@ class Organizations::RegistrationsController < Devise::RegistrationsController
params.require(:user).permit(:email, :password, :phone_number, :password_confirmation, :terms_of_service,
organization_attributes: [:name, :responsible_name])
end
end

View File

@@ -1,5 +1,4 @@
class Polls::AnswersController < ApplicationController
load_and_authorize_resource :poll
load_and_authorize_resource :question, class: "Poll::Question"
authorize_resource :answer, class: "Poll::Answer"
@@ -66,5 +65,4 @@ class Polls::AnswersController < ApplicationController
@answers = @question.question_answers.visibles
end
end
end

View File

@@ -1,5 +1,4 @@
class Polls::QuestionsController < ApplicationController
load_and_authorize_resource :poll
load_and_authorize_resource :question, class: "Poll::Question"
@@ -77,5 +76,4 @@ class Polls::QuestionsController < ApplicationController
@answers = @question.question_answers.visibles
end
end
end

View File

@@ -78,5 +78,4 @@ class PollsController < ApplicationController
def generate_and_store_new_pair(question)
Poll::PairAnswer.generate_pair(question, current_user)
end
end

View File

@@ -29,5 +29,4 @@ class ProposalNotificationsController < ApplicationController
def proposal_notification_params
params.require(:proposal_notification).permit(:title, :body, :proposal_id)
end
end

Some files were not shown because too many files have changed in this diff Show More