Skip to content

Commit

Permalink
Rubocop: parens vs ternary
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Jan 10, 2017
1 parent 72324ff commit 975717f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 18 deletions.
11 changes: 0 additions & 11 deletions .rubocop_todo.yml
Expand Up @@ -520,17 +520,6 @@ Style/SignalException:
- 'spec/factories/shared_factories.rb'
- 'spec/factories/user_factories.rb'

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment.
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
Style/TernaryParentheses:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/controllers/entities_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/helpers/tasks_helper.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -252,7 +252,7 @@ def respond_to_access_denied
def redirection_url
# Try to redirect somewhere sensible. Note: not all controllers have an index action
url = if current_user.present?
(respond_to?(:index) && action_name != 'index') ? { action: 'index' } : root_url
respond_to?(:index) && action_name != 'index' ? { action: 'index' } : root_url
else
login_url
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/entities_controller.rb
Expand Up @@ -208,7 +208,7 @@ def timeline(asset)
def set_view
if params['view']
controller = params['controller']
action = (params['action'] == 'show') ? 'show' : 'index' # create update redraw filter index actions all use index view
action = params['action'] == 'show' ? 'show' : 'index' # create update redraw filter index actions all use index view
current_user.pref[:"#{controller}_#{action}_view"] = params['view']
end
end
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/application_helper.rb
Expand Up @@ -453,15 +453,15 @@ def section_title(id, hidden = true, text = nil, info_text = nil)
# Return name of current view
def current_view_name
controller = params['controller']
action = (params['action'] == 'show') ? 'show' : 'index' # create update redraw filter index actions all use index view
action = params['action'] == 'show' ? 'show' : 'index' # create update redraw filter index actions all use index view
current_user.pref[:"#{controller}_#{action}_view"]
end

#----------------------------------------------------------------------------
# Get template in current context with current view name
def template_for_current_view
controller = params['controller']
action = (params['action'] == 'show') ? 'show' : 'index' # create update redraw filter index actions all use index view
action = params['action'] == 'show' ? 'show' : 'index' # create update redraw filter index actions all use index view
template = FatFreeCRM::ViewFactory.template_for_current_view(controller: controller, action: action, name: current_view_name)
template
end
Expand All @@ -470,7 +470,7 @@ def template_for_current_view
# Generate buttons for available views given the current context
def view_buttons
controller = params['controller']
action = (params['action'] == 'show') ? 'show' : 'index' # create update redraw filter index actions all use index view
action = params['action'] == 'show' ? 'show' : 'index' # create update redraw filter index actions all use index view
views = FatFreeCRM::ViewFactory.views_for(controller: controller, action: action)
return nil unless views.size > 1
lis = ''.html_safe
Expand All @@ -482,7 +482,7 @@ def view_buttons
"#{h view.name}-button"
end
lis << content_tag(:li) do
url = (action == "index") ? send("redraw_#{controller}_path") : send("#{controller.singularize}_path")
url = action == "index" ? send("redraw_#{controller}_path") : send("#{controller.singularize}_path")
link_to('#', title: t(view.name, default: h(view.title)), "data-view": h(view.name), "data-url": h(url), "data-context": action, class: classes) do
icon = view.icon || 'fa-bars'
content_tag(:i, nil, class: "fa #{h icon}")
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/tasks_helper.rb
Expand Up @@ -92,7 +92,7 @@ def hide_task_and_possibly_bucket(task, bucket)

#----------------------------------------------------------------------------
def replace_content(task, bucket = nil)
partial = (task.assigned_to && task.assigned_to != current_user.id) ? "assigned" : "pending"
partial = task.assigned_to && task.assigned_to != current_user.id ? "assigned" : "pending"
html = render(partial: "tasks/#{partial}", collection: [task], locals: { bucket: bucket })
text = "$('##{dom_id(task)}').html('#{j html}');\n".html_safe
end
Expand Down

0 comments on commit 975717f

Please sign in to comment.