The analyzer generates “warning S1125: Remove the unnecessary Boolean literal(s).” on the line of code for the ‘required’ boolean assignment. In the code snippet below, ‘item’ object is an optional (can be null) ‘to be cloned’ item of DataItem type. Code intent is 'use values from the cloned item, if there is one, otherwise use defaults. ‘titleHtml’ property is of string type (and no warning is generated), ‘required’ is a bool type. Looks like S1905 warning is caused by the first (true) part of the ternary statement, but since 2nd (false) ternary statement is not a ‘true’ literal, the warning really should not be shown.
var newItem = new Datatem()
{
// Skipping code lines ....
titleHtml = item == null ? string.Empty : item.titleHtml,
required = item == null ? false : item.required
};