org.sonar.l10n.java.rules.squid.MissingDeprecatedCheck.html Maven / Gradle / Ivy
Deprecation should be marked with both the @Deprecated
annotation and @deprecated Javadoc tag. The annotation enables tools such as IDEs to warn about referencing deprecated elements, and the tag can be used to explain when it was deprecated, why, and how references should be refactored.
The following code illustrates this rule:
Noncompliant Code Example
class MyClass {
@Deprecated
public void foo1() {
}
/**
* @deprecated
*/
public void foo2() { // Noncompliant
}
}
Compliant Solution
class MyClass {
/**
* @deprecated (when, why, refactoring advice...)
*/
@Deprecated
public void foo1() {
}
/**
* @deprecated (when, why, refactoring advice...)
*/
@Deprecated
public void foo2() {
}
}
Exceptions
The members and methods of a deprecated class or interface are ignored by this rule. The classes and interfaces themselves are still subject to it.
/**
* @deprecated (when, why, etc...)
*/
@Deprecated
class Qix {
public void foo() {} // Compliant; class is deprecated
}
/**
* @deprecated (when, why, etc...)
*/
@Deprecated
interface Plop {
void bar();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy