Skip to content

I've improved the KDocs and inline comments in DateTimeDiffer and `… #413

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hossain-khan
Copy link
Owner

…DateTimeDifferTest`.

This will enhance the documentation and comments in DateTimeDiffer.kt and its corresponding test file DateTimeDifferTest.kt.

Here are the key changes:

  • DateTimeDiffer.kt:

    • I updated the KDocs for diffWorkingHours and workingDuration to include explicit @param, @return, and @throws tags.
    • I restructured KDoc descriptions for better clarity on function behavior, assumptions, and handling of edge cases (e.g., times outside working hours, weekends).
    • I removed commented-out debugging code.
    • I converted a "Future Note" to a TODO comment.
    • I improved inline comments to explain the "why" behind complex logic, not just the "what".
    • I replaced informal comments with professional explanations.
  • DateTimeDifferTest.kt:

    • I reviewed and confirmed the accuracy of the main class KDoc.
    • I removed an overly verbose multi-line comment block, replacing it with a concise explanation.
    • I corrected a misleading comment in one of the test cases.
    • I ensured test method names are descriptive and inline comments are helpful and accurate.

These changes aim to make your code easier to understand, maintain, and use.

…DateTimeDifferTest`.

This will enhance the documentation and comments in `DateTimeDiffer.kt` and its corresponding test file `DateTimeDifferTest.kt`.

Here are the key changes:

- **`DateTimeDiffer.kt`**:
    - I updated the KDocs for `diffWorkingHours` and `workingDuration` to include explicit `@param`, `@return`, and `@throws` tags.
    - I restructured KDoc descriptions for better clarity on function behavior, assumptions, and handling of edge cases (e.g., times outside working hours, weekends).
    - I removed commented-out debugging code.
    - I converted a "Future Note" to a `TODO` comment.
    - I improved inline comments to explain the "why" behind complex logic, not just the "what".
    - I replaced informal comments with professional explanations.

- **`DateTimeDifferTest.kt`**:
    - I reviewed and confirmed the accuracy of the main class KDoc.
    - I removed an overly verbose multi-line comment block, replacing it with a concise explanation.
    - I corrected a misleading comment in one of the test cases.
    - I ensured test method names are descriptive and inline comments are helpful and accurate.

These changes aim to make your code easier to understand, maintain, and use.
@hossain-khan hossain-khan marked this pull request as draft June 1, 2025 14:24
@hossain-khan hossain-khan requested a review from Copilot June 1, 2025 14:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances documentation and inline comments in DateTimeDiffer and its tests for clarity and maintainability.

  • Refactored KDoc in DateTimeDiffer.kt: added explicit tags, restructured descriptions, removed debug code, and added a TODO.
  • Cleaned up verbose comments in DateTimeDifferTest.kt: replaced with concise, scenario-based inline comments.
  • Improved inline explanations to focus on the “why” of complex logic, not just the “what.”

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/main/kotlin/dev/hossain/time/DateTimeDiffer.kt Enhanced KDoc, removed debugging blocks, added TODO, clarified logic with inline comments.
src/test/kotlin/dev/hossain/time/DateTimeDifferTest.kt Simplified comments, added realistic test scenario notes, removed large commented-out sections.
Comments suppressed due to low confidence (2)

src/test/kotlin/dev/hossain/time/DateTimeDifferTest.kt:130

  • [nitpick] The test name uses diff instead of the method under test, diffWorkingHours. Rename the test to start with diffWorkingHours - given… to maintain consistency with other tests.
fun `diff - given start time is before working hour and end time during work hour - provides diff of working hour only`() {

src/main/kotlin/dev/hossain/time/DateTimeDiffer.kt:109

  • This assignment overrides the previousWorkingDay calculated just above from nextWorkingDayAfterWeekend, potentially skipping the intended start time. Consider reusing nextWorkingDayAfterWeekend directly rather than chaining off the original previousWorkingDay.
previousWorkingDay = previousWorkingDay.nextWorkingDay().prevWorkingHour()

*
* @param startInstant The start instant of the period.
* @param endInstant The end instant of the period.
* @param timeZoneId The ZoneId to determine local working days and hours.
Copy link
Preview

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The KDoc parameter name timeZoneId does not match the function signature which uses zoneId. Update the @param to zoneId for accuracy.

Copilot uses AI. Check for mistakes.

* ↑ ↑
* Start End
* of Day of Day
* ↑ ↑ ↑
Copy link
Preview

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The ASCII art arrows and labels for week start, week end, and weekend are misaligned and can be confusing. Consider simplifying or realigning this diagram for clarity, or removing it if it adds more complexity than benefit.

Copilot uses AI. Check for mistakes.

@hossain-khan
Copy link
Owner Author

Has some good inline comments for different cases. Salvage them later.

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.

1 participant