Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "WARNING - Suspicious code. The result of the 'getprop' operator is not being used." mean?

"WARNING - Suspicious code. The result of the 'getprop' operator is not being used."

I'm seeing this for two lines in my JavaScript code when I use the closure compiler. They are typedefs in among other typedefs that don't report issues. What should I be looking for?

EDIT

Affected code:

/**
 * @typedef {{playerId: number, playerName: string, baseScores: Array.<number>, bonusScores: Array.<number>,
 *          teamScoreAdjustments: Array.<number>}}
 */
wias.GameTableTeamMember;

/**
 * @typedef {{id: number, teamMembers: Array<wias.GameTableTeamMember>, teamName: string}}
 */
wias.GameTableTeam;

/**
 * @typedef {{id: number, availableRound: boolean, bonusScoring: boolean, complete: boolean, gameLength: number,
 *          gameType: string, lastPlayed: string, numberOfRounds: number, teams: Array.<wias.GameTableTeam>, winners:
 *          Array.<string>}}
 */
wias.GameTable;

Warning:

wias.js:77: WARNING - Suspicious code. The result of the 'getprop' operator is not being used.
wias.GameTableTeam;
^

Why a warning there and not elsewhere?

like image 624
Ben Flynn Avatar asked Feb 03 '12 06:02

Ben Flynn


1 Answers

It means that you have code which does nothing.

Typedef's (or record types) are more tricky for the compiler to point to the exact spot where the issue is, but somewhere you are getting a value which is not being used.

some reading about the type system and what works best with the compiler https://docs.google.com/document/d/1Uq_vNyPZjlRvYZJclX6N37Fjsiah4XNciEPSBfFiREs/edit

and to recreate the warning simply

if (true) {
   //have nothing in here
}
like image 171
lennel Avatar answered Oct 01 '22 22:10

lennel