1
Vote

Rule JS1003 reporting on Switch statements

description

When I have a switch statement, and there are several clauses that use a value, rule JS1003 reports that the variable declaration should be moved into the switch statement.
var value = new ComplexSharedObject("param1","param2");
switch(intValue)
{
    case 1:
        return methodOne(value);
    case 2:
        return methodTwo(value);
    default:
        return methodDefault(value);
}
This will report a violation of rule JS1003, when there is no way to move the declaration in the code it uses as suggested.

Visual Studio 2012 Update 3 (11.0.60610.01)
.Net framework 4.5.50709
StyleCop 4.7.44.0
JSL Rules 2.0.0.0

comments