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

Fixed KdocComments #1754

Merged
merged 30 commits into from
Oct 16, 2023
Merged

Conversation

DrAlexD
Copy link
Member

@DrAlexD DrAlexD commented Sep 28, 2023

What's done:

  • Changed warning KDOC_NO_CONSTRUCTOR_PROPERTY to KDOC_NO_CONSTRUCTOR_PROPERTY_WITH_COMMENT in some cases when property or parameter has comment before.
  • Added check is warning KDOC_NO_CONSTRUCTOR_PROPERTY_WITH_COMMENT fixable for case when property or parameter has any tags in KDoc-comment before. If it has = non-fixed.
  • Added configuration for @param tags creation: isParamTagsForParameters and isParamTagsForPrivateProperties.
  • Added fixed warnings KDOC_NO_CONSTRUCTOR_PROPERTY and KDOC_NO_CONSTRUCTOR_PROPERTY_WITH_COMMENT for cases when configuration options are on, and then private properties and parameters must have @param tags in class-KDoc. Additionally added logic for replacing incorrect tag with correct one regardless of whether configuration is enabled or not.
  • Added non-fixed warning KDOC_EXTRA_PROPERTY for redundant @param tags in class-KDoc.
  • Reworked fix tests. Added tests for cases when @property or @param tag exist in class-KDoc.
  • Added new warning tests.

It's part of #1737

### What's done:
- Added non-fixed warning `KDOC_EXTRA_PROPERTY` for case when `private` or `override` property has `@property` tag in class-KDoc.
- Removed fixed warning `KDOC_NO_CONSTRUCTOR_PROPERTY` for case when `override` property  hasn't `@property` tag in class-KDoc.
- Added non-fixed warning `KDOC_NO_CONSTRUCTOR_PROPERTY_WITH_COMMENT` for case when `private` or `override` property has comment before.
- Changed warning `KDOC_NO_CONSTRUCTOR_PROPERTY` to `KDOC_NO_CONSTRUCTOR_PROPERTY_WITH_COMMENT` for case when non-`private` and non-`override` property has comment before.
- Added check is warning `KDOC_NO_CONSTRUCTOR_PROPERTY_WITH_COMMENT` fixable for case when non-`private` and non-`override` property has tags in KDoc-comment before. If it has = non-fixed.
- Fixed case when text from comment before non-`private` and non-`override` property didn't append to the end of `@property` text in class-KDoc for that property.
- Fixed case when `@property` text in class-KDoc didn't create for KDoc-comment before non-`private` and non-`override` property.
- Fixed functions `removeWithWhiteSpace` and `removeChildMergingSurroundingWhitespaces` for additional handling KDoc-comments.
- Reworked fix tests. Added fix test for case when `@property` tag exist in class-KDoc.
- Added warning tests.

It's part of saveourtool#1737
…D/diktat into feature/fix-kdoc-comments

# Conflicts:
#	diktat-rules/src/main/kotlin/com/saveourtool/diktat/ruleset/rules/chapter2/kdoc/KdocComments.kt
@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

Merging #1754 (b03af2c) into master (e0fb721) will increase coverage by 0.33%.
The diff coverage is 85.37%.

@@             Coverage Diff              @@
##             master    #1754      +/-   ##
============================================
+ Coverage     76.75%   77.09%   +0.33%     
- Complexity     2301     2376      +75     
============================================
  Files           126      126              
  Lines          8295     8408     +113     
  Branches       2081     2131      +50     
============================================
+ Hits           6367     6482     +115     
+ Misses          997      976      -21     
- Partials        931      950      +19     
Files Coverage Δ
...lin/com/saveourtool/diktat/cli/DiktatProperties.kt 0.00% <ø> (ø)
...n/com/saveourtool/diktat/common/cli/CliArgument.kt 0.00% <ø> (ø)
...aveourtool/diktat/plugin/gradle/DiktatExtension.kt 100.00% <ø> (ø)
...rtool/diktat/plugin/gradle/tasks/DiktatTaskBase.kt 61.53% <ø> (ø)
...om/saveourtool/diktat/ktlint/DiktatReporterImpl.kt 0.00% <ø> (ø)
...m/saveourtool/diktat/ruleset/constants/Warnings.kt 96.36% <ø> (ø)
...com/saveourtool/diktat/ruleset/rules/DiktatRule.kt 62.50% <ø> (ø)
...uleset/rules/chapter3/MultipleModifiersSequence.kt 93.44% <ø> (ø)
.../ruleset/rules/chapter3/files/TopLevelOrderRule.kt 92.15% <ø> (ø)
...diktat/ruleset/rules/chapter2/kdoc/KdocComments.kt 88.81% <85.37%> (+7.00%) ⬆️

…-comment before private and override property

- fixed case when there wasn't empty line after class-Kdoc description and before any tag
- fixed case when indentation wasn't created before content of new line if tag block cannot be described in one line
@DrAlexD DrAlexD enabled auto-merge (squash) October 2, 2023 12:37
@nulls nulls added bug Something isn't working tests Improve testing labels Oct 2, 2023
@DrAlexD DrAlexD requested a review from nulls October 2, 2023 13:04
@nulls nulls added this to the 2.0.0 milestone Oct 2, 2023
@DrAlexD DrAlexD disabled auto-merge October 5, 2023 15:34
…` tags in class-KDoc

- added fixed warnings `KDOC_NO_CONSTRUCTOR_PROPERTY` and `KDOC_NO_CONSTRUCTOR_PROPERTY_WITH_COMMENT` due to `private` properties and parameters must have `@param` tags in class-KDoc
…meters` and `isParamTagsForPrivateProperties`

- fix affected classes
@DrAlexD DrAlexD enabled auto-merge (squash) October 16, 2023 09:12
@DrAlexD DrAlexD merged commit 71c81d4 into saveourtool:master Oct 16, 2023
27 checks passed
@DrAlexD DrAlexD deleted the feature/fix-kdoc-comments branch October 16, 2023 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tests Improve testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants