Skip to content

Commit

Permalink
docs: RSPEC-1123
Browse files Browse the repository at this point in the history
  • Loading branch information
ssungwxx committed Mar 4, 2023
1 parent 23dfedc commit 519b4eb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
52 changes: 52 additions & 0 deletions _posts/java/2023-03-04-RSPEC-1123.md
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)
> [![Star This Project](https://img.shields.io/github/stars/kantabile/sonarkube.svg?label=Stars&style=social)](https://github.com/kantabile/sonarkube)
1 change: 0 additions & 1 deletion _posts/java/2023-03-04-RSPEC-1181.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ tags: [java, Code Smell, Major, cwe, error-handling, bad-practice, cert]
```java
try { /* ... */ } catch (Throwable t) { /* ... */ }
try { /* ... */ } catch (Error e) { /* ... */ }
// ...
```

### 규칙을 준수한 코드
Expand Down

0 comments on commit 519b4eb

Please sign in to comment.