[英]Sonarqube squid:S2699 if jsonPath validation
I have implemented controller test (using spring web testing framework). 我已经实现了控制器测试(使用Spring Web测试框架)。
mvc.perform(MockMvcRequestBuilders.post("/calendar").contentType(V1_0)
.content(toJSON(createCalendarDto(expectedCalendar))))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(V1_0))
.andExpect(jsonPath("$.id", is(notNullValue())))
//...
.andExpect(jsonPath("$.email", is(expectedCalendar.getEmail())));
this test covers some important cases, checking json structure and field values. 该测试涵盖了一些重要情况,检查json结构和字段值。
Test works correctly, sonar prints a message: 测试工作正常,声纳显示一条消息:
Tests should include assertions. 测试应包括断言。 Code smell Critical squid:S2699
典味香熏鱿鱼:S2699
I could use workaround like @SuppressWarnings("squid:S2699")
but I hope it can be managed in better way. 我可以使用类似
@SuppressWarnings("squid:S2699")
解决方法,但我希望可以采用更好的方法进行管理。
java 1.8 Sonarcube Version 6.3.1 Spring-boot 1.4.3 Java 1.8 Sonarcube版本6.3.1春季启动1.4.3
You've found a false positive in a rule. 您发现规则中存在误报。 Specifically, your test framework is not taken into account by the rule.
具体来说,该规则不考虑您的测试框架。
The best course for rule false positives in general is to open a thread on the SonarQube Google Group saying, essentially, "For language L, could you add case X to rule Y, please?". 通常,规则误报的最佳方法通常是在SonarQube Google Group上打开一个线程,本质上说:“对于语言L,请问您可以将规则X加上大小写X吗?”。 Don't forget to include a minimum code sample to reproduce the false positive.
不要忘了包含一个最小的代码样本来重现误报。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.