通过注释抑制IntelliJ IDEA中的重复警告 [英] Suppress duplicate warnings in IntelliJ IDEA by annotation

查看:785
本文介绍了通过注释抑制IntelliJ IDEA中的重复警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从版本15开始, IntelliJ就代码重复警告我.

在某些情况下,这可能是有意的,因此我想通过使用@SuppressWarnings批注忽略/抑制此警告.但是正确的值是什么?

In some cases this might be intentional, so I want to ignore/suppress this warning by using the @SuppressWarnings annotation. But what is the correct value for this?

我不是要完全像问题中那样禁用这种检查

I'm not asking for disabling this kind of inspection completely as in question Is it possible to disable duplicate code detection in Intellij?

推荐答案

这对我有用.如果要在两个地方都禁止显示警告,则必须在两个类/方法上都设置它.

This works for me. You have to set it on both classes/methods if you want to suppress the warning both places.

@SuppressWarnings("Duplicates")
private void myDuplicatedMethod() {
    ...
}

这篇关于通过注释抑制IntelliJ IDEA中的重复警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆