如何降低java代码中的认知复杂度

Son*_*ony 0 java sonarqube

请告知如何降低以下代码的认知复杂性

ids.add((row.getCell(11) != null) ? row.getCell(11).getStringCellValue() : "");
Run Code Online (Sandbox Code Playgroud)

And*_*w S 5

添加隐藏详细信息的方法,例如:

private String getCellValueOrDefault(Cell cell) {
    if (cell == null) {
       return "";
    }
    return cell.getStringValue();
}
Run Code Online (Sandbox Code Playgroud)

然后使用方法:

ids.add(getCellValueOrDefault(row.getCell(11));
Run Code Online (Sandbox Code Playgroud)