Commit 5a4ebfb4 authored by Jeroen van Baarsen's avatar Jeroen van Baarsen
Browse files

Fixed the Rails/ActionFilter cop


Signed-off-by: default avatarJeroen van Baarsen <jeroenvanbaarsen@gmail.com>
parent eb87bbc254b0
......@@ -954,7 +954,7 @@ Lint/Void:
Rails/ActionFilter:
Description: 'Enforces consistent use of action filter methods.'
Enabled: false
Enabled: true
Rails/DefaultScope:
Description: 'Checks if the argument passed to default_scope is a block.'
......
......@@ -3,7 +3,7 @@
# Automatically sets the layout and ensures an administrator is logged in
class Admin::ApplicationController < ApplicationController
layout 'admin'
before_filter :authenticate_admin!
before_action :authenticate_admin!
def authenticate_admin!
return render_404 unless current_user.is_admin?
......
class Admin::ApplicationSettingsController < Admin::ApplicationController
before_filter :set_application_setting
before_action :set_application_setting
def show
end
......
class Admin::BroadcastMessagesController < Admin::ApplicationController
before_filter :broadcast_messages
before_action :broadcast_messages
def index
@broadcast_message = BroadcastMessage.new
......
class Admin::DeployKeysController < Admin::ApplicationController
before_filter :deploy_keys, only: [:index]
before_filter :deploy_key, only: [:show, :destroy]
before_action :deploy_keys, only: [:index]
before_action :deploy_key, only: [:show, :destroy]
def index
end
def show
end
def new
......
class Admin::GroupsController < Admin::ApplicationController
before_filter :group, only: [:edit, :show, :update, :destroy, :project_update, :members_update]
before_action :group, only: [:edit, :show, :update, :destroy, :project_update, :members_update]
def index
@groups = Group.all
......
class Admin::KeysController < Admin::ApplicationController
before_filter :user, only: [:show, :destroy]
before_action :user, only: [:show, :destroy]
def show
@key = user.keys.find(params[:id])
......
class Admin::ProjectsController < Admin::ApplicationController
before_filter :project, only: [:show, :transfer]
before_filter :group, only: [:show, :transfer]
before_filter :repository, only: [:show, :transfer]
before_action :project, only: [:show, :transfer]
before_action :group, only: [:show, :transfer]
before_action :repository, only: [:show, :transfer]
def index
@projects = Project.all
......
class Admin::ServicesController < Admin::ApplicationController
before_filter :service, only: [:edit, :update]
before_action :service, only: [:edit, :update]
def index
@services = services_templates
......
class Admin::UsersController < Admin::ApplicationController
before_filter :user, only: [:show, :edit, :update, :destroy]
before_action :user, only: [:show, :edit, :update, :destroy]
def index
@users = User.order_name_asc.filter(params[:filter])
......
......@@ -6,15 +6,15 @@ class ApplicationController < ActionController::Base
PER_PAGE = 20
before_filter :authenticate_user_from_token!
before_filter :authenticate_user!
before_filter :reject_blocked!
before_filter :check_password_expiration
before_filter :ldap_security_check
before_filter :default_headers
before_filter :add_gon_variables
before_filter :configure_permitted_parameters, if: :devise_controller?
before_filter :require_email, unless: :devise_controller?
before_action :authenticate_user_from_token!
before_action :authenticate_user!
before_action :reject_blocked!
before_action :check_password_expiration
before_action :ldap_security_check
before_action :default_headers
before_action :add_gon_variables
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :require_email, unless: :devise_controller?
protect_from_forgery with: :exception
......
class Dashboard::MilestonesController < ApplicationController
before_filter :load_projects
before_action :load_projects
def index
project_milestones = case params[:state]
......
class Dashboard::ProjectsController < ApplicationController
before_filter :event_filter
before_action :event_filter
def starred
@projects = current_user.starred_projects
......
class DashboardController < ApplicationController
respond_to :html
before_filter :load_projects, except: [:projects]
before_filter :event_filter, only: :show
before_action :load_projects, except: [:projects]
before_action :event_filter, only: :show
def show
@projects = @projects.includes(:namespace)
......
class Explore::GroupsController < ApplicationController
skip_before_filter :authenticate_user!,
skip_before_action :authenticate_user!,
:reject_blocked, :set_current_user_for_observers
layout "explore"
......
class Explore::ProjectsController < ApplicationController
skip_before_filter :authenticate_user!,
skip_before_action :authenticate_user!,
:reject_blocked
layout 'explore'
......
class Groups::GroupMembersController < Groups::ApplicationController
skip_before_filter :authenticate_user!, only: [:index]
before_filter :group
skip_before_action :authenticate_user!, only: [:index]
before_action :group
# Authorize
before_filter :authorize_read_group!
before_filter :authorize_admin_group!, except: [:index, :leave]
before_action :authorize_read_group!
before_action :authorize_admin_group!, except: [:index, :leave]
layout :determine_layout
......@@ -49,7 +49,7 @@ def destroy
def resend_invite
redirect_path = group_group_members_path(@group)
@group_member = @group.group_members.find(params[:id])
if @group_member.invite?
......@@ -63,7 +63,7 @@ def resend_invite
def leave
@group_member = @group.group_members.where(user_id: current_user.id).first
if can?(current_user, :destroy_group_member, @group_member)
@group_member.destroy
redirect_to(dashboard_groups_path, notice: "You left #{group.name} group.")
......
class Groups::MilestonesController < ApplicationController
layout 'group'
before_filter :authorize_group_milestone!, only: :update
before_action :authorize_group_milestone!, only: :update
def index
project_milestones = case params[:state]
......
class GroupsController < Groups::ApplicationController
skip_before_filter :authenticate_user!, only: [:show, :issues, :merge_requests]
skip_before_action :authenticate_user!, only: [:show, :issues, :merge_requests]
respond_to :html
before_filter :group, except: [:new, :create]
before_action :group, except: [:new, :create]
# Authorize
before_filter :authorize_read_group!, except: [:new, :create]
before_filter :authorize_admin_group!, only: [:edit, :update, :destroy, :projects]
before_filter :authorize_create_group!, only: [:new, :create]
before_action :authorize_read_group!, except: [:new, :create]
before_action :authorize_admin_group!, only: [:edit, :update, :destroy, :projects]
before_action :authorize_create_group!, only: [:new, :create]
# Load group projects
before_filter :load_projects, except: [:new, :create, :projects, :edit, :update]
before_filter :event_filter, only: :show
before_filter :set_title, only: [:new, :create]
before_action :load_projects, except: [:new, :create, :projects, :edit, :update]
before_action :event_filter, only: :show
before_action :set_title, only: [:new, :create]
layout :determine_layout
......
class Import::BitbucketController < Import::BaseController
before_filter :verify_bitbucket_import_enabled
before_filter :bitbucket_auth, except: :callback
before_action :verify_bitbucket_import_enabled
before_action :bitbucket_auth, except: :callback
rescue_from OAuth::Error, with: :bitbucket_unauthorized
def callback
request_token = session.delete(:oauth_request_token)
request_token = session.delete(:oauth_request_token)
raise "Session expired!" if request_token.nil?
request_token.symbolize_keys!
access_token = client.get_token(request_token, params[:oauth_verifier], callback_import_bitbucket_url)
current_user.bitbucket_access_token = access_token.token
......@@ -21,7 +21,7 @@ def callback
def status
@repos = client.projects
@already_added_projects = current_user.created_projects.where(import_type: "bitbucket")
already_added_projects_names = @already_added_projects.pluck(:import_source)
......@@ -41,7 +41,7 @@ def create
repo_owner = repo["owner"]
repo_owner = current_user.username if repo_owner == client.user["user"]["username"]
@target_namespace = params[:new_namespace].presence || repo_owner
namespace = get_or_create_namespace || (render and return)
unless Gitlab::BitbucketImport::KeyAdder.new(repo, current_user).execute
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment