Skip to content

Commit

Permalink
rubocop fix Style/Indent*
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinKo committed Apr 8, 2015
1 parent 157b6b8 commit 9f04f44
Show file tree
Hide file tree
Showing 95 changed files with 1,532 additions and 1,549 deletions.
17 changes: 0 additions & 17 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,23 +143,6 @@ Style/GlobalVars:
Style/IfUnlessModifier:
Enabled: false

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/IndentHash:
Enabled: false

# Offense count: 285
# Cop supports --auto-correct.
Style/IndentationConsistency:
Enabled: false

# Offense count: 32
# Cop supports --auto-correct.
# Configuration parameters: Width.
Style/IndentationWidth:
Enabled: false

# Offense count: 40
# Cop supports --auto-correct.
Style/Lambda:
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/addresses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def destroy

private

def set_address
@address = current_user.addresses.find(params[:id])
end
def set_address
@address = current_user.addresses.find(params[:id])
end
end
164 changes: 82 additions & 82 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,111 +59,111 @@ def after_sign_in_path_for resource_or_scope

protected

def json_request?
request.format.json?
end
def json_request?
request.format.json?
end

# Pundit checker
# Pundit checker

def verify_authorized_with_exceptions
verify_authorized unless pundit_unverified_controller
end
def verify_authorized_with_exceptions
verify_authorized unless pundit_unverified_controller
end

def pundit_unverified_controller
(pundit_unverified_modules.include? self.class.name.split('::').first) || (pundit_unverified_classes.include? self.class.name)
end
def pundit_unverified_controller
(pundit_unverified_modules.include? self.class.name.split('::').first) || (pundit_unverified_classes.include? self.class.name)
end

def pundit_unverified_modules
['Devise', 'RailsAdmin']
end
def pundit_unverified_modules
['Devise', 'RailsAdmin']
end

def pundit_unverified_classes
[
'RegistrationsController', 'SessionsController', 'ConfirmationsController', 'ToolboxController',
'BankDetailsController', 'ExportsController', 'WelcomeController',
'CategoriesController', 'Peek::ResultsController', 'StyleguidesController',
'RemoteValidationsController', 'DiscourseController'
]
end
def pundit_unverified_classes
[
'RegistrationsController', 'SessionsController', 'ConfirmationsController', 'ToolboxController',
'BankDetailsController', 'ExportsController', 'WelcomeController',
'CategoriesController', 'Peek::ResultsController', 'StyleguidesController',
'RemoteValidationsController', 'DiscourseController'
]
end

def build_search_cache
search_params = {}
form_search_params = params.for(ArticleSearchForm)[:article_search_form]
search_params.merge!(form_search_params) if form_search_params.is_a?(Hash)
@search_cache = ArticleSearchForm.new(search_params)
end
def build_search_cache
search_params = {}
form_search_params = params.for(ArticleSearchForm)[:article_search_form]
search_params.merge!(form_search_params) if form_search_params.is_a?(Hash)
@search_cache = ArticleSearchForm.new(search_params)
end

# Caching security: Set response headers to prevent caching
# @api semipublic
# @return [undefined]
def dont_cache
response.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
response.headers['Pragma'] = 'no-cache'
response.headers['Expires'] = 'Fri, 01 Jan 1990 00:00:00 GMT'
end
# Caching security: Set response headers to prevent caching
# @api semipublic
# @return [undefined]
def dont_cache
response.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
response.headers['Pragma'] = 'no-cache'
response.headers['Expires'] = 'Fri, 01 Jan 1990 00:00:00 GMT'
end

# If user wants to sell
def ensure_complete_profile
# Check if the user has filled all fields
unless current_user.can_sell?
flash[:error] = t('article.notices.incomplete_profile')
redirect_to edit_user_registration_path(incomplete_profile: true)
end
# If user wants to sell
def ensure_complete_profile
# Check if the user has filled all fields
unless current_user.can_sell?
flash[:error] = t('article.notices.incomplete_profile')
redirect_to edit_user_registration_path(incomplete_profile: true)
end
end

def check_value_of_goods
current_user.count_value_of_goods
if current_user.value_of_goods_cents > (current_user.max_value_of_goods_cents + current_user.max_value_of_goods_cents_bonus)
flash[:error] = I18n.t('article.notices.max_limit')
redirect_to user_path(current_user)
end
def check_value_of_goods
current_user.count_value_of_goods
if current_user.value_of_goods_cents > (current_user.max_value_of_goods_cents + current_user.max_value_of_goods_cents_bonus)
flash[:error] = I18n.t('article.notices.max_limit')
redirect_to user_path(current_user)
end
end

def render_css_from_controller controller
@controller_specific_css = controller
end
def render_css_from_controller controller
@controller_specific_css = controller
end

def unset_cart
# gets called on every page load. when a session has expired, the old cart cookie needs to be cleared
if !current_user && cookies[:cart] && !view_context.current_cart
# if no user is logged in and there is a cart cookie but that cart can't be found / wasn't allowed
cookies.delete :cart
end
def unset_cart
# gets called on every page load. when a session has expired, the old cart cookie needs to be cleared
if !current_user && cookies[:cart] && !view_context.current_cart
# if no user is logged in and there is a cart cookie but that cart can't be found / wasn't allowed
cookies.delete :cart
end
end

def profile_request
Rack::MiniProfiler.authorize_request if current_user && current_user.admin?
end
def profile_request
Rack::MiniProfiler.authorize_request if current_user && current_user.admin?
end

private

def layout_by_param
if params[:iframe]
'iframe'
else
nil
end
def layout_by_param
if params[:iframe]
'iframe'
else
nil
end
end

def after_sign_in_if_banned resource_or_scope
if resource_or_scope.is_a?(User) && resource_or_scope.banned?
sign_out resource_or_scope
flash.discard
'/banned'
end
def after_sign_in_if_banned resource_or_scope
if resource_or_scope.is_a?(User) && resource_or_scope.banned?
sign_out resource_or_scope
flash.discard
'/banned'
end
end

def after_sign_in_if_ajax
toolbox_reload_path if request.xhr?
end
def after_sign_in_if_ajax
toolbox_reload_path if request.xhr?
end

def after_sign_in_if_sepa_required user
# If a legal Entity hasn't accepted direct debit but has any articles
if user.is_a?(LegalEntity) && !user.direct_debit &&
Article.unscoped.where(seller: user).limit(1).count > 0
def after_sign_in_if_sepa_required user
# If a legal Entity hasn't accepted direct debit but has any articles
if user.is_a?(LegalEntity) && !user.direct_debit &&
Article.unscoped.where(seller: user).limit(1).count > 0

flash[:error] = t('users.notices.sepa_missing')
'/user/edit?incomplete_profile=true'
end
flash[:error] = t('users.notices.sepa_missing')
'/user/edit?incomplete_profile=true'
end
end
end
22 changes: 11 additions & 11 deletions app/controllers/article_templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ def destroy

private

def set_article_template
@article_template = Article.unscoped.find(params[:id])
end
def set_article_template
@article_template = Article.unscoped.find(params[:id])
end

def collection_url
user_path(current_user, anchor: 'my_article_templates')
end
def collection_url
user_path(current_user, anchor: 'my_article_templates')
end

def save_images
# At least try to save the images -> not persisted in browser
@article_template.images.each do |image|
image.save
end
def save_images
# At least try to save the images -> not persisted in browser
@article_template.images.each do |image|
image.save
end
end
end
Loading

0 comments on commit 9f04f44

Please sign in to comment.