saveourtool / diktat

Strict coding standard for Kotlin and a custom set of rules for detecting code smells, code style issues and bugs
https://diktat.saveourtool.com
MIT License
544 stars 39 forks source link

`KDOC_WITHOUT_THROWS_TAG` add `@throws` annotation when throw inside try-catch #1862

Closed diphtongue closed 11 months ago

diphtongue commented 11 months ago

What's done:

Closes #1718

codecov[bot] commented 11 months ago

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (02c1a7c) 78.55% compared to head (5b479d8) 78.54%.

Files Patch % Lines
.../diktat/ruleset/rules/chapter2/kdoc/KdocMethods.kt 73.68% 0 Missing and 5 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1862 +/- ## ============================================ - Coverage 78.55% 78.54% -0.02% - Complexity 2456 2463 +7 ============================================ Files 133 133 Lines 8654 8673 +19 Branches 2189 2198 +9 ============================================ + Hits 6798 6812 +14 Misses 882 882 - Partials 974 979 +5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 11 months ago

JUnit Tests (Windows, EnricoMi/publish-unit-test-result-action@v2)

   164 files  ±0     164 suites  ±0   7m 37s :stopwatch: +7s 1 423 tests +4  1 406 :heavy_check_mark: +4  17 :zzz: ±0  0 :x: ±0  2 802 runs  +4  2 785 :heavy_check_mark: +4  17 :zzz: ±0  0 :x: ±0 

Results for commit 5b479d8d. ± Comparison against base commit 02c1a7cc.

:recycle: This comment has been updated with latest results.

github-actions[bot] commented 11 months ago

JUnit Tests (macOS, EnricoMi/publish-unit-test-result-action@v2)

   164 files  ±0     164 suites  ±0   5m 17s :stopwatch: -12s 1 423 tests +4  1 386 :heavy_check_mark: +4  37 :zzz: ±0  0 :x: ±0  2 802 runs  +4  2 765 :heavy_check_mark: +4  37 :zzz: ±0  0 :x: ±0 

Results for commit 5b479d8d. ± Comparison against base commit 02c1a7cc.

:recycle: This comment has been updated with latest results.

kgevorkyan commented 11 months ago

Discussed offline, lets cover with tests following cases

1) There shouldnt be any warning in:

try {
// ...
  throw(ex1)
// ...
} catch(ex1) {
} catch(ex2) {
} catch(ex3)

2) There shouldnt be any warning in:

try {
// ...
  throw NumberException
// ...
} catch(IlligalArgumentException) {

since NumberException is child of IlligalArgumentException

3) We should warn in this case

try {
// ...
  throw(ex1)
// ...
throw(ex2)
throw(ex3)
} catch(ex1) {
} catch(ex2) {
} 

ex3 here is not catched , so we need add @throws ex3