Home

Unused local variables should be removed

Rule description

  • Unused local variables should be removed

 

Non-compliant Code Example

global function string testQueries (string ls_valor)

string ls_sqlsyntax

string query = "Delete FROM employee WHERE emp_id = '" + ls_valor + "'" //Non compliant code (local variable query never used)

string query1 = "Select * FROM Users WHERE Username = '" + ls_valor + "'" //Non compliant code (local variable query1 never used)

ls_sqlsyntax = "Insert INTO employee (emp_id) Values ('" + ls_valor + "')"

ls_valor = runQuery("Update Users Set city = 'city1' WHERE emp_id = '" + ls_valor + "'")

DECLARE my_cursor DYNAMIC CURSOR FOR SQLSA ;

string ls_where

ls_where = "EMPId  = " + ls_valor 

ls_sqlsyntax = "SELECT emp_id FROM employee WHERE " + ls_where 

PREPARE SQLSA FROM :ls_sqlsyntax;

PREPARE SQLSA FROM "Select * FROM employee WHERE city = 'city1' AND state='state1'";

OPEN DYNAMIC my_cursor ;

Return ls_valor
end function
Visual Expert 2020
 VEPBRULE72