Skip to content

Commit

Permalink
Add rubocop spacing rules
Browse files Browse the repository at this point in the history
We were following these rules in most places; we just didn't define them
anywhere.
  • Loading branch information
javierm committed Jul 5, 2019
1 parent ec7590f commit b09d920
Show file tree
Hide file tree
Showing 250 changed files with 597 additions and 520 deletions.
26 changes: 26 additions & 0 deletions .erb-lint.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
---
linters:
ExtraNewline:
enabled: true
FinalNewline:
enabled: true
SelfClosingTag:
enabled: false
SpaceAroundErbTag:
enabled: true
SpaceIndentation:
enabled: true
SpaceInHtmlTag:
enabled: true
TrailingWhitespace:
Expand All @@ -14,5 +18,27 @@ linters:
enabled: true
only:
- Layout/EndOfLine
- Layout/SpaceAfterColon
- Layout/SpaceAfterComma
- Layout/SpaceAfterMethodName
- Layout/SpaceAfterNot
- Layout/SpaceAfterSemicolon
- Layout/SpaceAroundBlockParameters
- Layout/SpaceAroundOperators
- Layout/SpaceBeforeBlockBraces
- Layout/SpaceBeforeComma
- Layout/SpaceBeforeComment
- Layout/SpaceBeforeFirstArg
- Layout/SpaceBeforeSemicolon
- Layout/SpaceInsideArrayLiteralBrackets
- Layout/SpaceInsideArrayPercentLiteral
- Layout/SpaceInsideBlockBraces
- Layout/SpaceInsideHashLiteralBraces
- Layout/SpaceInsideParens
- Layout/SpaceInsidePercentLiteralDelimiters
- Layout/SpaceInsideRangeLiteral
- Layout/SpaceInsideReferenceBrackets
- Layout/SpaceInsideStringInterpolation
- Layout/Tab
- Lint/LiteralAsCondition
- Style/PercentLiteralDelimiters
67 changes: 67 additions & 0 deletions .rubocop_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,73 @@ Layout/EmptyLines:
Layout/EndOfLine:
EnforcedStyle: lf

Layout/SpaceAfterColon:
Enabled: true

Layout/SpaceAfterComma:
Enabled: true

Layout/SpaceAfterMethodName:
Enabled: true

Layout/SpaceAfterNot:
Enabled: true

Layout/SpaceAfterSemicolon:
Enabled: true

Layout/SpaceAroundBlockParameters:
Enabled: true

Layout/SpaceAroundOperators:
Enabled: true

Layout/SpaceBeforeBlockBraces:
Enabled: true

Layout/SpaceBeforeComma:
Enabled: true

Layout/SpaceBeforeComment:
Enabled: true

Layout/SpaceBeforeFirstArg:
Enabled: true

Layout/SpaceBeforeSemicolon:
Enabled: true

Layout/SpaceInsideArrayLiteralBrackets:
Enabled: true

Layout/SpaceInsideArrayPercentLiteral:
Enabled: true

Layout/SpaceInsideBlockBraces:
Enabled: true

Layout/SpaceInsideHashLiteralBraces:
Enabled: true
EnforcedStyle: compact

Layout/SpaceInsideParens:
Enabled: true

Layout/SpaceInsidePercentLiteralDelimiters:
Enabled: true

Layout/SpaceInsideRangeLiteral:
Enabled: true

Layout/SpaceInsideReferenceBrackets:
Enabled: true

Layout/SpaceInsideStringInterpolation:
Enabled: true

Layout/Tab:
Enabled: true

Layout/TrailingBlankLines:
Enabled: true

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/budgets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def assigned_users_translation
private

def budget_params
descriptions = Budget::Phase::PHASE_KINDS.map{|p| "description_#{p}"}.map(&:to_sym)
descriptions = Budget::Phase::PHASE_KINDS.map { |p| "description_#{p}" }.map(&:to_sym)
valid_attributes = [:phase,
:currency_symbol,
:help_link,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def index

respond_to do |format|
format.html
format.csv {send_data to_csv(Comment.sort_by_newest, Comment),
format.csv { send_data to_csv(Comment.sort_by_newest, Comment),
type: "text/csv",
disposition: "attachment",
filename: "comments.csv" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def update

administrator_task.update(user: current_user, executed_at: Time.now)
redirect_to admin_dashboard_administrator_tasks_path,
{ flash: { notice: t("admin.dashboard.administrator_tasks.update.success") } }
{ flash: { notice: t("admin.dashboard.administrator_tasks.update.success") }}
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/admin/download_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ class Admin::DownloadSettingsController < Admin::BaseController
load_and_authorize_resource

def edit
permitted = downloadable_params
permitted = downloadable_params
@download_settings = []
if permitted_models.include? permitted[:resource]
set_edit(permitted[:resource])
end
end

def update
permitted = downloadable_params
permitted = downloadable_params
if permitted[:downloadable]
DownloadSetting.where(name_model: get_model(permitted[:resource]).to_s,
config: permitted[:config].to_i).each do |download_setting|
Expand All @@ -27,7 +27,7 @@ def update
private

def set_edit(resource)
@download_resource = {name: resource, config: get_config}
@download_resource = { name: resource, config: get_config }
@download_settings = get_attrs(get_model(resource), get_config)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/legislation/processes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def index
.page(params[:page])
respond_to do |format|
format.html
format.csv {send_data to_csv(process_for_download, Legislation::Process),
format.csv { send_data to_csv(process_for_download, Legislation::Process),
type: "text/csv",
disposition: "attachment",
filename: "legislation_processes.csv" }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/poll/booth_assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def search_booths
def show
included_relations = [:recounts, :voters, officer_assignments: [officer: [:user]]]
@booth_assignment = @poll.booth_assignments.includes(*included_relations).find(params[:id])
@voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date}
@voters_by_date = @booth_assignment.voters.group_by { |v| v.created_at.to_date }
@partial_results = @booth_assignment.partial_results
@recounts = @booth_assignment.recounts
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def update
flash.now[:error] = t("admin.site_customization.images.update.error")

@images = SiteCustomization::Image.all_images
idx = @images.index {|e| e.name == @image.name }
idx = @images.index { |e| e.name == @image.name }
@images[idx] = @image

render :index
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/admin/stats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ def budget_balloting

authorize! :read_admin_stats, @budget, message: t("admin.stats.budgets.no_data_before_balloting_phase")

@user_count = @budget.ballots.select {|ballot| ballot.lines.any? }.count
@user_count = @budget.ballots.select { |ballot| ballot.lines.any? }.count

@vote_count = @budget.lines.count

@vote_count_by_heading = @budget.lines.group(:heading_id).count.collect {|k,v| [Budget::Heading.find(k).name, v]}.sort
@vote_count_by_heading = @budget.lines.group(:heading_id).count.collect { |k, v| [Budget::Heading.find(k).name, v] }.sort

@user_count_by_district = User.where.not(balloted_heading_id: nil).group(:balloted_heading_id).count.collect {|k,v| [Budget::Heading.find(k).name, v]}.sort
@user_count_by_district = User.where.not(balloted_heading_id: nil).group(:balloted_heading_id).count.collect { |k, v| [Budget::Heading.find(k).name, v] }.sort
end

def polls
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/budgets/investments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def suggest
end

def json_data
investment = Budget::Investment.find(params[:id])
investment = Budget::Investment.find(params[:id])
data = {
investment_id: investment.id,
investment_title: investment.title,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/commentable_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def index
set_resources_instance
respond_to do |format|
format.html
format.csv {send_data to_csv(resources_csv, resource_model),
format.csv { send_data to_csv(resources_csv, resource_model),
type: "text/csv",
disposition: "attachment",
filename: "#{get_resource(resource_model)}.csv" }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/dashboard/group_supports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def calculate_week(date)
end

def calculate_year_of_week(date)
year = date.year
year = date.year
if first_week_of_year?(date) && date.end_of_week.year != date.year
year = year + 1
elsif last_week_of_year?(date) && date.beginning_of_week.year != date.year
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/concerns/moderate_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ def moderate
@resources = @resources.where(id: params[:resource_ids])

if params[:hide_resources].present?
@resources.accessible_by(current_ability, :hide).each {|resource| hide_resource resource}
@resources.accessible_by(current_ability, :hide).each { |resource| hide_resource resource }

elsif params[:ignore_flags].present?
@resources.accessible_by(current_ability, :ignore_flag).each(&:ignore_flag)

elsif params[:block_authors].present?
author_ids = @resources.pluck(author_id).uniq
User.where(id: author_ids).accessible_by(current_ability, :block).each {|user| block_user user}
User.where(id: author_ids).accessible_by(current_ability, :block).each { |user| block_user user }
end

redirect_to request.query_parameters.merge(action: :index)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/dashboard/actions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def create_request
Dashboard::AdministratorTask.create(source: @dashboard_executed_action)

redirect_to progress_proposal_dashboard_path(proposal.to_param),
{ flash: { info: t("dashboard.create_request.success") } }
{ flash: { info: t("dashboard.create_request.success") }}
else
flash.now[:alert] = @dashboard_executed_action.errors.full_messages.join("<br>")
render :new_request
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/direct_uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create
render json: { cached_attachment: @direct_upload.relation.cached_attachment,
filename: @direct_upload.relation.attachment.original_filename,
destroy_link: render_destroy_upload_link(@direct_upload).html_safe,
attachment_url: @direct_upload.relation.attachment.url}
attachment_url: @direct_upload.relation.attachment.url }
else
@direct_upload.destroy_attachment
render json: { errors: @direct_upload.errors[:attachment].join(", ") },
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/legislation/processes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def resume
@phase = :resume
respond_to do |format|
format.html
format.xlsx {render xlsx: "resume_to_xlsx", filename: ("resume-" + Date.today.to_s + ".xlsx")}
format.xlsx { render xlsx: "resume_to_xlsx", filename: ("resume-" + Date.today.to_s + ".xlsx") }
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/management/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ def destroy_session

def admin?
if current_user.try(:administrator?)
session[:manager] = {login: "admin_user_#{current_user.id}"}
session[:manager] = { login: "admin_user_#{current_user.id}" }
end
end

def manager?
if current_user.try(:manager?)
session[:manager] = {login: "manager_user_#{current_user.id}"}
session[:manager] = { login: "manager_user_#{current_user.id}" }
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/officing/polls_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Officing::PollsController < Officing::BaseController

def index
@polls = current_user.poll_officer? ? current_user.poll_officer.voting_days_assigned_polls : []
@polls = @polls.select {|poll| poll.current?(Time.current) || poll.current?(1.day.ago)}
@polls = @polls.select { |poll| poll.current?(Time.current) || poll.current?(1.day.ago) }
end

def final
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/polls/answers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create
load_for_answers
if @question.enum_type&.include?("answer_couples")
last_pair ||= generate_and_store_new_pair(@question)
@last_pair_question_answers = {@question.id => last_pair}
@last_pair_question_answers = { @question.id => last_pair }
end
render "polls/questions/answer", format: :js
end
Expand All @@ -34,7 +34,7 @@ def delete
load_for_answers
if @question.enum_type&.include?("answer_couples")
last_pair ||= generate_and_store_new_pair(@question)
@last_pair_question_answers = {@question.id => last_pair}
@last_pair_question_answers = { @question.id => last_pair }
end
render "polls/questions/answer", format: :js
end
Expand All @@ -53,10 +53,10 @@ def check_question_answer_exist
def load_for_answers
@page = params[:page].present? ? params[:page] : 1
question_answers
@answers_by_question_id = {@question.id => @question.answers
@answers_by_question_id = { @question.id => @question.answers
.by_author(current_user)
.order(:order)
.pluck(:answer)}
.pluck(:answer) }
end

def question_answers
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/polls/questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def answer
load_for_answers
if @question.enum_type&.include?("answer_couples")
last_pair ||= generate_and_store_new_pair(@question)
@last_pair_question_answers = {@question.id => last_pair}
@last_pair_question_answers = { @question.id => last_pair }
end
end

Expand Down Expand Up @@ -39,10 +39,10 @@ def prioritized_answers
def load_for_answers
@page = params[:page].present? ? params[:page] : 1
question_answers
@answers_by_question_id = {@question.id => @question.answers
@answers_by_question_id = { @question.id => @question.answers
.by_author(current_user)
.order(:order)
.pluck(:answer)}
.pluck(:answer) }
end

def vote_stored(answer, new_answer, token)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/tracking/budget_investments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def heading_filters
filters << {
name: heading.name,
id: heading.id,
count: investments.select{|i| i.heading_id == heading.id}.size
count: investments.select { |i| i.heading_id == heading.id }.size
}
end
filters.uniq
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Tracking::ProposalProgressBarsController < Tracking::ProgressBarsController
class Tracking::ProposalProgressBarsController < Tracking::ProgressBarsController

private
def progressable
Expand Down
Loading

0 comments on commit b09d920

Please sign in to comment.