app/controllers/strikes_controller.rb
# File name: strikes_controller.rb# Class name: StrikesControllerLine is too long. [82/80]# Description: Controller used to communicate with the proprietary view of strikesStrikesController assumes too much for instance variable '@alumn'
StrikesController assumes too much for instance variable '@current_user'
StrikesController assumes too much for instance variable '@strike'class StrikesController < ApplicationController include SessionsHelper Cyclomatic complexity for index is too high. [4/3] def index id = params[:alumn_id] Space inside parentheses detected.
Use `||` instead of `or`.
Don't use parentheses around the condition of an `if`. if ( is_employee? or verify_alumn(id) or is_son?(id) )StrikesController declares the class variable '@@alumn'
Replace class var @@alumn with a class instance var. @@alumn = Alumn.find(id) @strikes = @@alumn.strikes elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end def newStrikesController tests '( is_employee? )' at least 5 times
Don't use parentheses around a method call.
Space inside parentheses detected.
Don't use parentheses around the condition of an `if`. if ( is_employee? )Replace class var @@alumn with a class instance var. @@alumn = Alumn.find(params[:alumn_id]) @strike = Strike.new elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end def showDon't use parentheses around a method call.
Don't use parentheses around the condition of an `if`.
Space inside parentheses detected. if ( logged_in? ) @strike = Strike.find(params[:id]) @alumn = Alumn.find_by_id(@strike.alumn_id) @employee = Employee.find(@strike.employee_id) elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end Method has too many lines. [17/10]
Cyclomatic complexity for create is too high. [4/3]
Method `create` has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
StrikesController#create has approx 8 statements def createSpace inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if ( is_employee? ) @strike = @@alumn.strikes.create(strike_params) @strike.employee_id = @current_user.idDon't use parentheses around a method call.
Don't use parentheses around the condition of an `if`. if (@strike.save) @@alumn.quantity_strike += 1 if @@alumn.savePrefer single-quoted strings when you don't need string interpolation or special symbols. flash[:success] = "AdvertĂȘncia criada com sucesso"Space missing after comma. redirect_to alumn_strike_path(@@alumn,@strike) elseStrikesController#create calls 'render 'strikes/new'' 2 times render 'strikes/new' end else render 'strikes/new' end elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end Method has too many lines. [13/10]
Cyclomatic complexity for destroy is too high. [4/3]
StrikesController#destroy has approx 6 statements
Method `destroy` has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. def destroySpace inside parentheses detected.
Don't use parentheses around the condition of an `if`.
Don't use parentheses around a method call. if ( is_employee? ) @strike = Strike.find(params[:id]) @alumn = Alumn.find_by_id(@strike.alumn_id) if @strike.destroy @alumn.quantity_strike -= 1 if @alumn.savePrefer single-quoted strings when you don't need string interpolation or special symbols. flash[:alert] = "AdvertĂȘncia excluĂda com sucesso" redirect_to users_path end end elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end def editDon't use parentheses around a method call.
Space inside parentheses detected.
Don't use parentheses around the condition of an `if`. if ( is_employee? ) @strike = Strike.find(params[:id]) @alumn = Alumn.find_by_id(@strike.alumn_id) elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end Method has too many lines. [11/10]
Similar blocks of code found in 2 locations. Consider refactoring. def updateDon't use parentheses around a method call.
Space inside parentheses detected.
Don't use parentheses around the condition of an `if`. if ( is_employee? ) @strike = Strike.find(params[:id]) if @strike.update(strike_params)Prefer single-quoted strings when you don't need string interpolation or special symbols. flash[:notice] = "AdvertĂȘncia alterada com sucesso" redirect_to strike_path(@strike) elsePrefer single-quoted strings when you don't need string interpolation or special symbols. render "strikes/edit" end elsePrefer single-quoted strings when you don't need string interpolation or special symbols. redirect_to "/errors/error_500" end end Keep a blank line before and after `private`. private def strike_params params.require(:strike).permit(:description_strike,Align the parameters of a method call if they span more than one line. :date_strike,Align the parameters of a method call if they span more than one line. employee_attributes: [:employee_id], alumn_attributes: [:alumn_id]) endend