Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from
Dec 15, 2023

Conversation

diphtongue
Copy link
Contributor

What's done:

  • Fixed KDOC_WITHOUT_THROWS_TAG rule when it adds a @throws annotation to the function, which has throw inside try-catch block

Closes #1718

### What's done:
* test
### What's done:
* worked
- Fixed `KDOC_WITHOUT_THROWS_TAG` rule when it adds a @throws annotation to the function, which has `throw` inside try-catch block

Closes #1718
Copy link

codecov bot commented Dec 13, 2023

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 ⚠️
Additional details and impacted files
@@             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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

github-actions bot commented Dec 13, 2023

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

   164 files  ±0     164 suites  ±0   7m 37s ⏱️ +7s
1 423 tests +4  1 406 ✔️ +4  17 💤 ±0  0 ±0 
2 802 runs  +4  2 785 ✔️ +4  17 💤 ±0  0 ±0 

Results for commit 5b479d8. ± Comparison against base commit 02c1a7c.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Dec 13, 2023

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

   164 files  ±0     164 suites  ±0   5m 17s ⏱️ -12s
1 423 tests +4  1 386 ✔️ +4  37 💤 ±0  0 ±0 
2 802 runs  +4  2 765 ✔️ +4  37 💤 ±0  0 ±0 

Results for commit 5b479d8. ± Comparison against base commit 02c1a7c.

♻️ This comment has been updated with latest results.

@diphtongue diphtongue marked this pull request as ready for review December 13, 2023 13:10
@kgevorkyan
Copy link
Member

kgevorkyan commented Dec 13, 2023

Discussed offline, lets cover with tests following cases

  1. There shouldnt be any warning in:
try {
// ...
  throw(ex1)
// ...
} catch(ex1) {
} catch(ex2) {
} catch(ex3)
  1. There shouldnt be any warning in:
try {
// ...
  throw NumberException
// ...
} catch(IlligalArgumentException) {

since NumberException is child of IlligalArgumentException

  1. 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

- Fixed `KDOC_WITHOUT_THROWS_TAG` rule when it adds a @throws annotation to the function, which has `throw` inside try-catch block

Closes #1718
- Fixed `KDOC_WITHOUT_THROWS_TAG` rule when it adds a @throws annotation to the function, which has `throw` inside try-catch block
- Added tests, using real exceptions

Closes #1718
@diphtongue diphtongue merged commit d14f27d into master Dec 15, 2023
20 of 21 checks passed
@diphtongue diphtongue deleted the bugfix/kdoc-throws branch December 15, 2023 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KDOC_WITHOUT_THROWS_TAG add @throws annotation when throw inside try catch
3 participants