Skip to content

Commit

Permalink
Enable Layout/AlignParameters (#2340)
Browse files Browse the repository at this point in the history
Check if the parameters on a multi-line method call or definition are aligned.

Resolves: #2021
  • Loading branch information
cyrillefr authored and benhalpern committed Apr 8, 2019
1 parent 36a21cd commit 4fd6637
Show file tree
Hide file tree
Showing 53 changed files with 322 additions and 328 deletions.
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Expand Up @@ -79,9 +79,3 @@ Rails/OutputSafety:
- 'app/models/message.rb'
- 'app/views/api/v0/articles/show.json.jbuilder'
- 'app/views/articles/feed.rss.builder'

Layout/AlignParameters:
Description: 'Here we check if the parameters on a multi-line method call or definition are aligned.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
Enabled: false

4 changes: 2 additions & 2 deletions app/black_box/black_box.rb
Expand Up @@ -12,7 +12,7 @@ def article_hotness_score(article)
two_day_bonus = usable_date > 48.hours.ago ? 330 : 0
four_day_bonus = usable_date > 96.hours.ago ? 330 : 0
FunctionCaller.new("blackbox-production-articleHotness",
{ article: article, user: article.user }.to_json).call +
{ article: article, user: article.user }.to_json).call +
reaction_points + recency_bonus + super_recent_bonus + super_super_recent_bonus + today_bonus + two_day_bonus + four_day_bonus
end

Expand All @@ -30,7 +30,7 @@ def calculate_spaminess(story)
return 100 unless story.user

FunctionCaller.new("blackbox-production-spamScore",
{ story: story, user: story.user }.to_json).call
{ story: story, user: story.user }.to_json).call
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/black_box/google_analytics.rb
Expand Up @@ -26,7 +26,7 @@ def get_pageviews
def get_feed_impression_info
requests = @article_ids.map do |id|
make_report_request("ga:eventAction==featured-feed-impression;ga:eventLabel==articles-#{id}",
"ga:totalEvents")
"ga:totalEvents")
end
results = fetch_all_results(requests)
@article_ids.zip(results).to_h
Expand All @@ -35,7 +35,7 @@ def get_feed_impression_info
def get_feed_click_info
requests = @article_ids.map do |id|
make_report_request("ga:eventAction==featured-feed-click;ga:eventLabel==articles-#{id}",
"ga:totalEvents")
"ga:totalEvents")
end
results = fetch_all_results(requests)
@article_ids.zip(results).to_h
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v0/articles_controller.rb
Expand Up @@ -3,8 +3,8 @@ module V0
class ArticlesController < ApiController
before_action :set_cache_control_headers, only: [:index]
caches_action :show,
cache_path: proc { |c| c.params.permit! },
expires_in: 5.minutes
cache_path: proc { |c| c.params.permit! },
expires_in: 5.minutes
respond_to :json

before_action :cors_preflight_check
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/api/v0/comments_controller.rb
Expand Up @@ -3,13 +3,13 @@ module V0
class CommentsController < ApplicationController
# before_action :set_cache_control_headers, only: [:index, :show]
caches_action :index,
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
respond_to :json

caches_action :show,
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
respond_to :json

def index
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v0/podcast_episodes_controller.rb
Expand Up @@ -2,8 +2,8 @@ module Api
module V0
class PodcastEpisodesController < ApiController
caches_action :index,
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
respond_to :json

before_action :cors_preflight_check
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v0/tags_controller.rb
Expand Up @@ -3,8 +3,8 @@ module V0
class TagsController < ApplicationController
# before_action :set_cache_control_headers, only: [:index]
caches_action :index,
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
respond_to :json

def index
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v0/videos_controller.rb
Expand Up @@ -2,8 +2,8 @@ module Api
module V0
class VideosController < ApiController
caches_action :index,
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
cache_path: proc { |c| c.params.permit! },
expires_in: 10.minutes
respond_to :json

before_action :cors_preflight_check
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/chat_channels_controller.rb
Expand Up @@ -132,7 +132,7 @@ def render_unopened_json_response
current_user.
chat_channel_memberships.includes(:chat_channel).
where("has_unopened_messages = ? OR status = ?",
true, "pending").
true, "pending").
where(show_global_badge_notification: true).
order("chat_channel_memberships.updated_at DESC")
else
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/followed_articles_controller.rb
Expand Up @@ -2,8 +2,8 @@ class FollowedArticlesController < ApplicationController
# No authorization required for entirely public controller

caches_action :index,
cache_path: proc { "followed_articles_#{current_user.id}__#{current_user.updated_at}__#{user_signed_in?}" },
expires_in: 35.minutes
cache_path: proc { "followed_articles_#{current_user.id}__#{current_user.updated_at}__#{user_signed_in?}" },
expires_in: 35.minutes

def index
@articles = if current_user
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/github_repos_controller.rb
Expand Up @@ -10,7 +10,7 @@ def create
redirect_to "/settings/integrations", notice: "GitHub repo added"
else
redirect_to "/settings/integrations",
error: "There was an error adding your Github repo"
error: "There was an error adding your Github repo"
end
end

Expand All @@ -22,7 +22,7 @@ def update
redirect_to "/settings/integrations", notice: "GitHub repo added"
else
redirect_to "/settings/integrations",
error: "There was an error removing your Github repo"
error: "There was an error removing your Github repo"
end
end

Expand Down
24 changes: 12 additions & 12 deletions app/controllers/internal/events_controller.rb
Expand Up @@ -39,18 +39,18 @@ def update

def event_params
params.require(:event).permit(:title,
:category,
:event_date,
:starts_at,
:ends_at,
:location_name,
:cover_image,
:location_url,
:description_markdown,
:published,
:host_name,
:profile_image,
:live_now)
:category,
:event_date,
:starts_at,
:ends_at,
:location_name,
:cover_image,
:location_url,
:description_markdown,
:published,
:host_name,
:profile_image,
:live_now)
end
end
end
22 changes: 11 additions & 11 deletions app/controllers/internal/users_controller.rb
Expand Up @@ -117,16 +117,16 @@ def merge

def user_params
params.require(:user).permit(:seeking_mentorship,
:offering_mentorship,
:quick_match,
:new_note,
:add_mentor,
:add_mentee,
:note_for_current_role,
:mentorship_note,
:user_status,
:toggle_mentorship,
:pro,
:merge_user_id)
:offering_mentorship,
:quick_match,
:new_note,
:add_mentor,
:add_mentee,
:note_for_current_role,
:mentorship_note,
:user_status,
:toggle_mentorship,
:pro,
:merge_user_id)
end
end
14 changes: 7 additions & 7 deletions app/controllers/omniauth_callbacks_controller.rb
Expand Up @@ -12,13 +12,13 @@ def github

def failure
logger.error "Omniauth failure",
omniauth_failure: {
error: request.env["omniauth.error"]&.inspect,
error_type: request.env["omniauth.error.type"].to_s,
auth: request.env["omniauth.auth"],
provider: request.env["omniauth.strategy"].to_s,
cookie: request.env["rack.request.cookie_hash"]
}
omniauth_failure: {
error: request.env["omniauth.error"]&.inspect,
error_type: request.env["omniauth.error.type"].to_s,
auth: request.env["omniauth.auth"],
provider: request.env["omniauth.strategy"].to_s,
cookie: request.env["rack.request.cookie_hash"]
}
super
end

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/podcast_episodes_controller.rb
Expand Up @@ -20,10 +20,10 @@ def index

def podcast_episode_params
params.require(:podcast_episode).permit(:title,
:body,
:image,
:social_image,
:remote_social_image_url,
:quote)
:body,
:image,
:social_image,
:remote_social_image_url,
:quote)
end
end
2 changes: 1 addition & 1 deletion app/controllers/pusher_controller.rb
Expand Up @@ -2,7 +2,7 @@ class PusherController < ApplicationController
def auth
if valid_channel
response = Pusher.authenticate(params[:channel_name], params[:socket_id],
user_id: current_user.id) # => required
user_id: current_user.id) # => required
render json: response
else
render json: { text: "Forbidden", status: "403" }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/stripe_active_cards_controller.rb
Expand Up @@ -42,7 +42,7 @@ def destroy
customer.sources.retrieve(params[:id]).delete
customer.save
redirect_to "/settings/billing",
notice: "Your card has been successfully removed."
notice: "Your card has been successfully removed."
else
redirect_to "/settings/billing", flash: { error:
"Can't remove card if you have an active membership. Please cancel your membership first." }
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/users_controller.rb
Expand Up @@ -66,7 +66,7 @@ def remove_association
identity_username = "#{provider}_username".to_sym
@user.update(identity_username => nil)
redirect_to "/settings/#{@tab}",
notice: "Your #{provider.capitalize} account was successfully removed."
notice: "Your #{provider.capitalize} account was successfully removed."
else
flash[:error] = "An error occurred. Please try again or send an email to: yo@dev.to"
redirect_to "/settings/#{@tab}"
Expand All @@ -93,7 +93,7 @@ def join_org
if (@organization = Organization.find_by(secret: params[:org_secret]))
current_user.update(organization_id: @organization.id)
redirect_to "/settings/organization",
notice: "You have joined the #{@organization.name} organization."
notice: "You have joined the #{@organization.name} organization."
else
not_found
end
Expand All @@ -103,7 +103,7 @@ def leave_org
authorize User
current_user.update(organization_id: nil, org_admin: nil)
redirect_to "/settings/organization",
notice: "You have left your organization."
notice: "You have left your organization."
end

def add_org_admin
Expand All @@ -112,23 +112,23 @@ def add_org_admin
user.update(org_admin: true)
user.add_role :analytics_beta_tester if user.organization.approved
redirect_to "/settings/organization",
notice: "#{user.name} is now an admin."
notice: "#{user.name} is now an admin."
end

def remove_org_admin
user = User.find(params[:user_id])
authorize user
user.update(org_admin: false)
redirect_to "/settings/organization",
notice: "#{user.name} is no longer an admin."
notice: "#{user.name} is no longer an admin."
end

def remove_from_org
user = User.find(params[:user_id])
authorize user
user.update(organization_id: nil)
redirect_to "/settings/organization",
notice: "#{user.name} is no longer part of your organization."
notice: "#{user.name} is no longer part of your organization."
end

def signout_confirm; end
Expand Down
46 changes: 23 additions & 23 deletions app/helpers/application_helper.rb
Expand Up @@ -108,14 +108,14 @@ def cloud_cover_url(url)
quality = "auto"

cl_image_path(url,
type: "fetch",
width: width,
height: height,
crop: "imagga_scale",
quality: quality,
flags: "progressive",
fetch_format: "auto",
sign_url: true)
type: "fetch",
width: width,
height: height,
crop: "imagga_scale",
quality: quality,
flags: "progressive",
fetch_format: "auto",
sign_url: true)
end

def cloud_social_image(article)
Expand All @@ -126,14 +126,14 @@ def cloud_social_image(article)
return src if src.start_with? "https://res.cloudinary.com/"

cl_image_path(src,
type: "fetch",
width: "1000",
height: "500",
crop: "imagga_scale",
quality: "auto",
flags: "progressive",
fetch_format: "auto",
sign_url: true)
type: "fetch",
width: "1000",
height: "500",
crop: "imagga_scale",
quality: "auto",
flags: "progressive",
fetch_format: "auto",
sign_url: true)
end
end

Expand All @@ -159,12 +159,12 @@ def org_bg_or_white(org)

def sanitize_rendered_markdown(processed_html)
ActionController::Base.helpers.sanitize processed_html.html_safe,
scrubber: RenderedMarkdownScrubber.new
scrubber: RenderedMarkdownScrubber.new
end

def sanitized_sidebar(text)
ActionController::Base.helpers.sanitize simple_format(text),
tags: %w[p b i em strike strong u br]
tags: %w[p b i em strike strong u br]
end

def track_split_version(url, version)
Expand All @@ -173,11 +173,11 @@ def track_split_version(url, version)

def follow_button(followable, style = "full")
tag :button, # Yikes
class: "cta follow-action-button",
data: {
info: { id: followable.id, className: followable.class.name, style: style }.to_json,
"follow-action-button" => true
}
class: "cta follow-action-button",
data: {
info: { id: followable.id, className: followable.class.name, style: style }.to_json,
"follow-action-button" => true
}
end

def user_colors_style(user)
Expand Down

0 comments on commit 4fd6637

Please sign in to comment.