作为一名开发人员,我处于早期阶段,需要帮助来解决 Sonar 错误,该错误表示以下代码的字段双重分配。
//Inside constructor
list1 = new ArrayList();
....
...
// in some method
if(description.equalsIgnoreCase(MAPPED_CATIA_MODELS)) {
tempList = new ArrayList();
tempList = list1 ; // gives error here as "Correctness - Double assignment of field."
addKey = true;
}
请建议需要更改的内容。谢谢。