Code Analysis Failure: Dead store to local variable

Iam not sure but I think you get the error message because you never use the assigned new LinkedHashSet<String>();

// LinkedHashSet assigned to widgetsToCreate 
LinkedHashSet<String> widgetsToCreate = new LinkedHashSet<String>();

// widgetsToCreate is not used
for (Map.Entry<String, String> entry : input.entrySet()) {
  //logic to add to widgetsToAdd based on content of the input Map
}

// new value assigned to widgetsToCreate, the LinkedHashSet assigned before wasn't used
widgetsToCreate = processInput(widgetsToAdd);

So you could write:

...
for (Map.Entry<String, String> entry : input.entrySet()) {
  //logic to add to widgetsToAdd based on content of the input Map
}
LinkedHashSet<String> widgetsToCreate = processInput(widgetsToAdd);

Tags:

Java