-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
title: Deprecated된 항목은 어노테이션과 Javadoc태그를 가지고 있어야한다. | ||
tags: [java, Code Smell, Major, obsolete, bad-practice] | ||
--- | ||
|
||
사용 중단된 항목은 `@Deprecated` 어노테이션과 `@deprecated` Javadoc 태그 모두 명시하여아합니다. 해당 어노테이션은 IDE와 같은 도구들에게 사용 중단된 요소에 대해 경고를 하고 태그를 통해 언제 사용 중단이 되었는지 왜 되었는지 그리고 어떻게 리팩토링하면 되는지에 대해 설명해줍니다. | ||
|
||
### 규칙을 어긴 코드 | ||
|
||
```java | ||
class MyClass { | ||
|
||
@Deprecated | ||
public void foo1() { // 규칙을 어긴 코드: @deprecated Javadoc 태그를 추가하는 것이 누락되었습니다. | ||
} | ||
|
||
/** | ||
* @deprecated | ||
*/ | ||
public void foo2() { // 규칙을 어긴 코드: @Deprecated 어노테이션을 추가하는 것이 누락되었습니다. | ||
} | ||
|
||
} | ||
``` | ||
|
||
### 규칙을 준수한 코드 | ||
|
||
```java | ||
class MyClass { | ||
|
||
/** | ||
* @deprecated (언제, 왜, 리팩터링 조언...) | ||
*/ | ||
@Deprecated | ||
public void foo1() { | ||
} | ||
|
||
} | ||
``` | ||
|
||
### 참고 | ||
|
||
* [MITRE, CWE-396](https://cwe.mitre.org/data/definitions/396) - Declaration of Catch for Generic Exception | ||
* [CERT, ERR08-J.](https://wiki.sei.cmu.edu/confluence/display/java/ERR08-J.+Do+not+catch+NullPointerException+or+any+of+its+ancestors) - Do not catch NullPointerException or any of its ancestors | ||
|
||
--- | ||
|
||
If you like SONARKUBE, don't forget to give me a star. :star2: | ||
|
||
> [원문으로 바로가기](https://rules.sonarsource.com/java/tag/bad-practice/RSPEC-1123) | ||
> [](https://github.com/kantabile/sonarkube) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters