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

Rubocop trailing comma rules #939

Merged
merged 3 commits into from
May 18, 2021
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -504,30 +504,3 @@ Style/SafeNavigation:
# Configuration parameters: AllowIfMethodIsEmpty.
Style/SingleLineMethods:
Enabled: false

# Offense count: 41
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArguments:
Enabled: false

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArrayLiteral:
Exclude:
- 'app/lib/log.rb'
- 'app/policies/user_policy.rb'
- 'db/seeds.rb'
- 'spec/forms/base_form_spec.rb'
- 'spec/forms/submission_form_spec.rb'
- 'spec/lib/tasks/support/listing_converter_spec.rb'

# Offense count: 36
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
Enabled: false
2 changes: 1 addition & 1 deletion app/blueprints/question_blueprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class QuestionBlueprint < Blueprinter::Base
:input_type,
:is_required,
:option_list,
:hint_text,
:hint_text
)
end
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def default_url_options
def context
@context ||= Context.new(
user: current_user,
admin_param: params[:admin],
admin_param: params[:admin]
)
end
helper_method :context
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/asks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create
submission: submission,
user: context.user,
system_setting: context.system_settings,
organization: context.host_organization,
organization: context.host_organization
)
redirect_to thank_you_path, notice: 'Ask was successfully created.'
else
Expand All @@ -42,7 +42,7 @@ def render_form(submission)
@json = {
submission: SubmissionBlueprint.render_as_hash(submission),
configuration: ConfigurationBlueprint.render_as_hash(nil),
form: FormBlueprint.render_as_hash(@form),
form: FormBlueprint.render_as_hash(@form)
}.to_json

render :new
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def category_params
:display_to_public,
:is_created_by_admin,
:parent_id,
categories_attributes: [],
categories_attributes: []
)
end
end
2 changes: 1 addition & 1 deletion app/controllers/custom_form_questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def custom_form_question_params
:name,
:display_order,
:form_hook,
option_list: [],
option_list: []
)
end
end
2 changes: 1 addition & 1 deletion app/controllers/form_questions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def set_form_dropdowns
def form_question_params
params.require(:form_question).permit(
:form_id,
:custom_form_question_id,
:custom_form_question_id
)
end
end
2 changes: 1 addition & 1 deletion app/controllers/listings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def listing_params
:submission_id,
:title,
:type,
tag_list: [],
tag_list: []
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def location_params
:zip,
:county,
:region,
:neighborhood,
:neighborhood
)
end
end
4 changes: 2 additions & 2 deletions app/controllers/offers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create
submission: submission,
user: context.user,
system_setting: context.system_settings,
organization: context.host_organization,
organization: context.host_organization
)
redirect_to thank_you_path, notice: 'Offer was successfully created.'
else
Expand All @@ -42,7 +42,7 @@ def render_form(submission)
@json = {
submission: SubmissionBlueprint.render_as_hash(submission),
configuration: ConfigurationBlueprint.render_as_hash(nil),
form: FormBlueprint.render_as_hash(@form),
form: FormBlueprint.render_as_hash(@form)
}.to_json

render :new
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def organization_params
:logo_url,
:name,
:phone,
:website_url,
:website_url
)
end
end
2 changes: 1 addition & 1 deletion app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def person_params
region
neighborhood
_destroy
],
]
)
end
end
2 changes: 1 addition & 1 deletion app/controllers/public_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def contributions
def landing_page
@json = GenerateLandingPageJson.run!(
system_setting: context.system_settings,
organization: context.host_organization,
organization: context.host_organization
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/service_areas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def service_area_params
name
description
_destroy
],
]
)
end
end
2 changes: 1 addition & 1 deletion app/controllers/submission_response_imports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def create
SubmissionResponseImportJob.perform_later(
user_id: current_user.id,
file_name: uploaded_file.original_filename,
file_contents: uploaded_file.read,
file_contents: uploaded_file.read
)

flash[:notice] = 'Your file has been uploaded and is being imported'
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/submission_responses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def submission_response_params
:integer_response,
:string_response,
:submission_id,
:text_response,
:text_response
)
end
end
4 changes: 2 additions & 2 deletions app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def create
submission: @submission,
user: context.user,
system_setting: context.system_settings,
organization: context.host_organization,
organization: context.host_organization
)
redirect_to submissions_path, notice: 'Submission successfully created.'
else
Expand Down Expand Up @@ -66,7 +66,7 @@ def submission_params
:form_name,
:person_id,
:privacy_level_requested,
:service_area_id,
:service_area_id
)
end
end
2 changes: 1 addition & 1 deletion app/controllers/system_settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def system_setting_params
:confirmation_page_text_footer,
:landing_page_text_what,
:landing_page_text_who,
:landing_page_text_how,
:landing_page_text_how
)
end
end
2 changes: 1 addition & 1 deletion app/forms/community_resource_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CommunityResourceForm < BaseForm
def execute
CommunityResource.find_or_new(id).tap do |community_resource|
community_resource.attributes = given_inputs.merge(
location: LocationForm.build(location),
location: LocationForm.build(location)
)
end
end
Expand Down
8 changes: 4 additions & 4 deletions app/forms/submission_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def build_listings
category: category_id,
location: @location,
person: @person,
service_area: service_area,
service_area: service_area
)
end
end
Expand All @@ -54,7 +54,7 @@ def build_submission_responses
SubmissionResponseForm.build(
submission: submission,
custom_form_question_id: custom_form_question_id,
string_response: answer,
string_response: answer
)
end
end
Expand All @@ -64,13 +64,13 @@ def submission_attributes
.slice(
:form_name,
:privacy_level_requested,
:service_area,
:service_area
)
.merge(
body: body_json,
person: @person,
listings: @listings,
submission_responses: @submission_responses,
submission_responses: @submission_responses
)
end

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/communication_log_buttons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def remote_communication_log_button(
title: 'New communication log',
class: "button add-button #{margin_class} is-primary is-outlined",
method: method,
remote: remote,
remote: remote
) do
"<span class='#{icon_class}'></span><span style='padding-left: 0.25em'> #{button_text}</span>".html_safe
end
Expand Down Expand Up @@ -136,7 +136,7 @@ def new_communication_log_button(person, match: nil, subject: nil, body: nil, cr
subject: subject,
body: body,
created_by_id: created_by&.id,
sent_at: Time.now,
sent_at: Time.now
)
link_to(
link_path,
Expand Down
2 changes: 1 addition & 1 deletion app/interactions/claim_contribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def ensure_person_record
name: peer_alias,
user: current_user,
email: current_user.email,
preferred_contact_method: ContactMethod.email,
preferred_contact_method: ContactMethod.email
)
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/interactions/email_new_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def execute
email = SubmissionMailer.new_submission_confirmation_email(
submission: submission,
system_setting: system_setting,
organization: organization,
organization: organization
)

status = Messenger.new(email, 'new_submission_confirmation_email').deliver_now
Expand All @@ -19,7 +19,7 @@ def execute
email: email,
delivery_status: status,
person: submission.person,
initiator: user,
initiator: user
)
end
end
4 changes: 2 additions & 2 deletions app/interactions/email_peer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def execute
contribution,
organization: organization,
peer_alias: peer_alias,
message: message,
message: message
)

status = Messenger.new(peer_to_peer_email, 'peer_to_peer_email').deliver_now
Expand All @@ -21,7 +21,7 @@ def execute
email: peer_to_peer_email,
delivery_status: status,
person: contribution.person,
initiator: user,
initiator: user
)
end
end
2 changes: 1 addition & 1 deletion app/interactions/generate_landing_page_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def execute
landing_page_text_what: sanitize(system_setting.landing_page_text_what),
landing_page_text_who: sanitize(system_setting.landing_page_text_who),
landing_page_text_how: sanitize(system_setting.landing_page_text_how),
organization_name: organization.name,
organization_name: organization.name
}.to_json
end

Expand Down
2 changes: 1 addition & 1 deletion app/lib/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.error exception, preamble = nil
lines = [
preamble,
"#{exception.message} (#{exception.class})",
*Rails.backtrace_cleaner.clean(exception.backtrace),
*Rails.backtrace_cleaner.clean(exception.backtrace)
]

Rails.logger.error lines.compact.join("\n")
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/peer_to_peer_match_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def peer_to_peer_email(contribution, peer_alias:, message:, organization:)
contribution: contribution,
message: message,
organization: organization,
peer_email_address: peer_email_address,
peer_email_address: peer_email_address
}
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ class Category < ApplicationRecord
belongs_to :parent, {
class_name: 'Category',
inverse_of: :categories,
optional: true,
optional: true
}
has_many :categories, -> { order(:display_order, :name) }, {
class_name: 'Category',
foreign_key: :parent_id,
inverse_of: :parent,
inverse_of: :parent
}

validates :name, presence: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/communication_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def self.log_email(email:, delivery_status:, person:, initiator: nil)
subject: email.subject,
body: email.html_part&.body || email.body.raw_source,
created_by: initiator,
auto_generated: true,
auto_generated: true
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def to_h
can_admin: can_admin?,
host_organization: host_organization,
system_settings: system_settings,
user: user,
user: user
}
end
end
2 changes: 1 addition & 1 deletion app/models/custom_form_question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CustomFormQuestion < ApplicationRecord
'select' => 'string_response',
'string' => 'string_response',
'textarea' => 'string_response', # for some reason textarea are being stored as string_response
'youtube_video_id' => 'string_response',
'youtube_video_id' => 'string_response'
}

scope :for_form, ->(form) { joins(:form_questions).where(form_questions: {form: form}) }
Expand Down
2 changes: 1 addition & 1 deletion app/models/donation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Donation < ApplicationRecord
where(
'donations.created_at >= ? AND donations.created_at <= ?',
Time.zone.now.beginning_of_month,
Time.zone.now.end_of_month,
Time.zone.now.end_of_month
)
}

Expand Down
Loading