1class UsersController < ApplicationController
 
2
 
3  before_action :authenticate, except: [ :emailExist, :usernameExist, :create ]
 
4  skip_before_action :verify_authenticity_token, :only => [
 
5    :emailExist,
 
6    :usernameExist,
 
7    :create,
 
8    :update
 
 9  ]
 
  • Complexity 2 » saikuro
  • Method name "emailExist" should match pattern /^[_a-z<>=\[\]|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/ » roodi
  • UncommunicativeMethodName - has the name 'emailExist' » reek
11  def emailExist
 
12    if checkExist?(:email, params[:email])
 
13      render :text => '1'
 
14    else
 
15      render :text => '0'
 
16    end
 
17  end
 
  • Complexity 2 » saikuro
  • Method name "usernameExist" should match pattern /^[_a-z<>=\[\]|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/ » roodi
  • UncommunicativeMethodName - has the name 'usernameExist' » reek
19  def usernameExist
 
20    if checkExist?(:name, params[:username])
 
21      render :text => 'exist'
 
22    else
 
23      render :text => 'not exist'
 
24    end
 
25  end
 
  • Complexity 2 » saikuro
27  def create
 
28    @user = User.new(user_params)
 
29    if @user.save
 
30      render status: :created, nothing: true
 
31    else
 
32      render json: @user.errors, status: :unprocessable_entity
 
33    end
 
34  end
 
  • Complexity 2 » saikuro
36  def update
 
37    @user = current_user
 
38    if @user.update(user_params)
 
39      render 'show'
 
40    else
 
41      render json:current_user.errors, status: :unprocessable_entity
 
42    end
 
43  end
 
 
45  private
  • Complexity 1 » saikuro
  • Method name "checkExist?" should match pattern /^[_a-z<>=\[\]|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/ » roodi
  • UtilityFunction - doesn't depend on instance state » reek
  • UncommunicativeMethodName - has the name 'checkExist?' » reek
46    def checkExist?(field_name, value)
 
47      User.exists?(field_name => value)
 
48    end
 
  • Complexity 1 » saikuro
50    def user_params
 
51      params.require(:user).permit(:name,:password, :password_confirmation, :email, :phone)
 
52    end
 
53end