Conditional logging with minimal cyclomatic complexity

前端 未结 12 1931
情歌与酒
情歌与酒 2020-11-27 10:58

After reading \"What’s your/a good limit for cyclomatic complexity?\", I realize many of my colleagues were quite annoyed with this new QA policy on our project: no more 10

12条回答
  •  长情又很酷
    2020-11-27 11:27

    Here is an elegant solution using ternary expression

    logger.info(logger.isInfoEnabled() ? "Log Statement goes here..." : null);

提交回复
热议问题