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

Development: Cleanup legacy and unused client code in the communication feature #8842

Merged
merged 5 commits into from
Jun 27, 2024

Conversation

egekurt123
Copy link
Contributor

@egekurt123 egekurt123 commented Jun 21, 2024

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data.
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only
  • I documented the TypeScript code using JSDoc style.

Motivation and Context

This PR addresses the removal of unused and legacy code within the communications module, including old Sidebar files.

Steps for Testing

  • Ensure that no functionality is affected after the deletion of files/code.

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Code Review

  • Code Review 1
  • Code Review 2

Summary by CodeRabbit

  • Refactor

    • Removed unused components from the course conversations module.
    • Simplified ChannelsOverviewDialogComponent by removing unnecessary service dependencies.
    • Cleaned up MetisService by removing unused methods and reordering existing ones.
  • Tests

    • Updated MetisService test suite to remove references to outdated configurations and simplify tags update logic.

@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Jun 21, 2024
@egekurt123 egekurt123 marked this pull request as ready for review June 21, 2024 22:04
@egekurt123 egekurt123 requested a review from a team as a code owner June 21, 2024 22:04
Copy link

coderabbitai bot commented Jun 21, 2024

Walkthrough

The recent updates primarily focus on removing unused components and services in the Angular application. Specifically, several components were excluded from the CourseConversationsModule, a service was eliminated from the ChannelsOverviewDialogComponent, and redundant methods were removed from the MetisService. Corresponding adjustments were made in the test suite, particularly simplifying post tag updates and modifying post retrieval approaches.

Changes

File Path Change Summary
src/.../course-conversations.module.ts Removed ConversationSelectionSidebarComponent, ConversationSidebarSectionComponent, and ConversationSidebarEntryComponent from the module declarations.
src/.../channels-overview-dialog.component.ts Removed the dependency on ConversationService from ChannelsOverviewDialogComponent.
src/.../metis/metis.service.ts Removed unused methods updateCoursePostTags and getSimilarPosts, reordering the remaining methods.
src/.../metis/metis.service.spec.ts Updated test file, removing references to CourseInformationSharingConfiguration, simplifying post tag updates, and adjusting post retrieval methods.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range comments (8)
src/main/webapp/app/overview/course-conversations/dialogs/channels-overview-dialog/channels-overview-dialog.component.ts (2)

Line range hint 98-98: Remove forbidden non-null assertions.

Using non-null assertions (!) bypasses TypeScript's strict null checks, which can lead to runtime errors if not handled carefully. Consider using optional chaining or proper error handling to ensure robustness.

- this.course.id!
+ this.course?.id

Also applies to: 107-107, 134-134


Line range hint 118-126: Change to an optional chain.

To improve code safety and readability, replace the non-null assertion with an optional chain. This change prevents potential runtime errors due to null or undefined values.

- channels?.filter((channel) => channel.subType === this.channelSubType) ?? []
+ channels?.filter((channel) => channel.subType === this.channelSubType)
src/main/webapp/app/shared/metis/metis.service.ts (3)

Line range hint 64-64: Avoid non-null assertions.

The use of non-null assertions in multiple places in this service could lead to potential runtime errors if the assumptions about non-null values prove incorrect. Refactor these to use safer access patterns or add necessary checks.

- this.courseId = course.id!;
+ this.courseId = course?.id;

Also applies to: 143-143, 178-178, 181-181, 203-203, 223-223, 234-234, 250-250, 270-270, 277-277, 293-293, 331-331, 348-348, 357-357, 374-374, 382-382


Line range hint 380-380: Use strict equality checks.

Replace the loose equality check (==) with strict equality (===) to avoid potential bugs due to type coercion.

- r.id == reaction.id
+ r.id === reaction.id

Line range hint 417-419: Remove unnecessary else clause.

The else clause is redundant and can be omitted to simplify the flow of control in the method.

- } else {
-   return;
- }
src/test/javascript/spec/service/metis/metis.service.spec.ts (3)

Line range hint 166-166: Avoid non-null assertion.

Using non-null assertions can lead to potential runtime errors. Consider using optional chaining or proper error handling.

- post.id!
+ post.id

Line range hint 315-315: Replace non-null assertions with safer alternatives.

Non-null assertions are used without checking for nullity, which might lead to errors. Use the optional chaining operator for safer access.

- answerPost.id!
+ answerPost.id
- post.answers!
+ post.answers

Also applies to: 316-316


Line range hint 386-386: Multiple non-null assertion issues.

Several non-null assertions are used throughout the reaction service methods. Replace these with optional chaining to prevent potential runtime errors.

- reaction.id!
+ reaction.id
- post.reactions!
+ post.reactions
- metisPostInChannel.conversation!.id!
+ metisPostInChannel.conversation?.id
- metisChannel.id
+ metisChannel.id
- metisLectureChannelDTO.id
+ metisLectureChannelDTO.id
- metisPostInChannel.content!
+ metisPostInChannel.content

Also applies to: 399-399, 411-411, 424-424, 428-428, 429-429

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 21, 2024
SimonEntholzer
SimonEntholzer previously approved these changes Jun 22, 2024
Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

As far as I checked the code and testing locally nothing seems to have broken

marlon-luca-bu
marlon-luca-bu previously approved these changes Jun 23, 2024
Copy link
Contributor

@marlon-luca-bu marlon-luca-bu left a comment

Choose a reason for hiding this comment

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

Code

# Conflicts:
#	src/main/webapp/app/overview/course-conversations/layout/conversation-selection-sidebar/conversation-sidebar-section/conversation-sidebar-section.component.ts
Copy link
Contributor

@JohannesStoehr JohannesStoehr left a comment

Choose a reason for hiding this comment

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

Removal looks good to me

Copy link
Contributor

@marlon-luca-bu marlon-luca-bu left a comment

Choose a reason for hiding this comment

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

Adaptions look good to me

Copy link
Contributor

@asliayk asliayk left a comment

Choose a reason for hiding this comment

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

tested locally, everything looks fine

@krusche krusche changed the title Communication: Cleanup legacy and unused code Development: Cleanup legacy and unused client code in the communication feature Jun 27, 2024
@krusche krusche added this to the 7.3.1 milestone Jun 27, 2024
@krusche krusche merged commit 18e9f4b into develop Jun 27, 2024
55 checks passed
@krusche krusche deleted the chore/communication/remove-legacy-code branch June 27, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore client Pull requests that update TypeScript code. (Added Automatically!) code quality component:Communication ready to merge small tests
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

None yet

6 participants