IntelliJ IDEA @SuppressWarnings for validation with tool name

I know that I can suppress warnings from IntelliJ IDEA inspections:

@SuppressWarnings("CollectionDeclaredAsConcreteClass")
public PropertiesExpander(Properties properties) {
    this.properties.putAll(properties);
}

It may not be clear to a person from the outside for whom the tool requires this suppression.

PMD uses prefixes for this:

@SuppressWarnings("PMD.UnusedLocalVariable")

FindBugs uses highlighted annotation:

@SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")

Can I clearly indicate that this suppression is for IntelliJ IDEA only?

+4
source share
2 answers

A way to suppress this method argument is to use the javadoc tag:

/**
 * @noinspection CollectionDeclaredAsConcreteClass
 */
public PropertiesExpander(Properties properties) {
    this.properties.putAll(properties);
}

javadoc IntelliJ, . , :

/**
 * @noinspection IntelliJ CollectionDeclaredAsConcreteClass
 */
public PropertiesExpander(Properties properties) {
    this.properties.putAll(properties);
}

, , :

/** @noinspection CollectionDeclaredAsConcreteClass */
public PropertiesExpander(Properties properties) {
    this.properties.putAll(properties);
}

@SuppressWarnings.

:

enter image description here

Alt + Enter notUsedLocalVariable, Suppress for statement with comment ( Remove variable ...).

// Suppress for statement.

( ) , :

enter image description here

, .

, , , .

+3

@SuppressWarnings:

@SuppressWarnings("idea: CollectionDeclaredAsConcreteClass")
public PropertiesExpander(Properties properties) {
    this.properties.putAll(properties);
}

, idea: , .

+3

Source: https://habr.com/ru/post/1605641/


All Articles