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

chore: Remove findById signature with Optional #34302

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

sharat87
Copy link
Member

@sharat87 sharat87 commented Jun 18, 2024

Follow up to #34281.

The .findById method is now removed.

No conflicts, but needs extra changes in this PR for build to pass on EE.

/test sanity

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9563607766
Commit: 02f6031
Cypress dashboard.
Tags: @tag.Sanity

Summary by CodeRabbit

  • Refactor
    • Updated methods to use direct values instead of Optional for permissions, simplifying method signatures and improving readability.

Copy link
Contributor

coderabbitai bot commented Jun 18, 2024

Walkthrough

The changes across multiple files focus on refining the method signatures by removing the usage of Optional parameters. Specifically, parameters involving AclPermission were simplified to directly accept the AclPermission object or be set to null where appropriate. This update aims to enhance code clarity and reduce potential complications associated with optional parameters.

Changes

File Path Change Summary
app/.../server/datasources/base/DatasourceServiceCEImpl.java Removed the usage of Optional in method signatures, directly passing AclPermission.
app/.../server/repositories/AppsmithRepository.java Removed the deprecated findById method with Optional<AclPermission>.
app/.../server/repositories/ce/BaseAppsmithRepositoryCEImpl.java Simplified findById method signature to directly pass AclPermission.
app/.../server/services/ce/WorkspaceServiceCE.java Removed the findById method that accepted Optional<AclPermission>.
app/.../server/services/ce/WorkspaceServiceCEImpl.java Updated findById method to remove the overload with Optional<AclPermission>.

Poem

In lines of code we simplify,
Optional’s grip we untie,
Permissions clear, in plain sight,
Our functions now feel so light. 🌟
A cleaner path for all to see,
More straightforward, as it should be! 🐇✨


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.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jun 18, 2024
@sharat87 sharat87 added the ok-to-test Required label for CI label Jun 18, 2024
@sharat87 sharat87 marked this pull request as ready for review June 18, 2024 11:47
Copy link
Contributor

@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: 0

Outside diff range and nitpick comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/WorkspaceServiceCEImpl.java (1)

[!TIP]
Codebase Verification

The search results indicate that the method findById with AclPermission is still present in the codebase, including in the WorkspaceServiceCEImpl class. This confirms that the method signature change was not consistently applied.

  • Files to be updated:
    • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/WorkspaceServiceCEImpl.java

Please ensure that the method signature change is applied consistently throughout the codebase.

Analysis chain

Line range hint 193-193: The updated method signature for findById improves readability and aligns with the codebase's handling of null values.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all calls to `findById` in the WorkspaceServiceCEImpl class have been updated across the codebase.

# Test: Search for the method usage with the old signature. Expect: No occurrences.
rg --type java $'findById\([^,]+,\s*Optional<'

Length of output: 47



Script:

#!/bin/bash
# Description: Verify that all calls to `findById` in the WorkspaceServiceCEImpl class have been updated across the codebase.

# Test: Search for the method usage with the new signature. Expect: Occurrences of the new method signature.
rg --type java $'findById\\([^,]+,\\s*AclPermission\\)'

Length of output: 53



Script:

#!/bin/bash
# Description: Verify all method signatures of `findById` in the codebase.

# Test: Search for all occurrences of `findById` method signatures. Expect: Occurrences of various signatures.
rg --type java $'findById\\('

Length of output: 76916

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f2a6341 and 02f6031.

Files selected for processing (5)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCEImpl.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/AppsmithRepository.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/WorkspaceServiceCE.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/WorkspaceServiceCEImpl.java (2 hunks)
Additional context used
Learnings (6)
Common learnings
User: sharat87
PR: appsmithorg/appsmith#33602
File: app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java:462-473
Timestamp: 2024-06-03T11:56:24.442Z
Learning: The codebase has mechanisms to gracefully handle `null` values, making the use of `Optional` for `AclPermission` unnecessary in certain contexts. This is leveraged by replacing `Optional.empty()` with `null` in method signatures where `null` is already handled gracefully.
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/WorkspaceServiceCE.java (1)
User: sharat87
PR: appsmithorg/appsmith#33602
File: app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java:462-473
Timestamp: 2024-06-03T11:56:24.442Z
Learning: The codebase has mechanisms to gracefully handle `null` values, making the use of `Optional` for `AclPermission` unnecessary in certain contexts. This is leveraged by replacing `Optional.empty()` with `null` in method signatures where `null` is already handled gracefully.
app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/AppsmithRepository.java (2)
User: sharat87
PR: appsmithorg/appsmith#33602
File: app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java:462-473
Timestamp: 2024-06-03T11:56:24.442Z
Learning: The codebase has mechanisms to gracefully handle `null` values, making the use of `Optional` for `AclPermission` unnecessary in certain contexts. This is leveraged by replacing `Optional.empty()` with `null` in method signatures where `null` is already handled gracefully.
User: sharat87
PR: appsmithorg/appsmith#33602
File: app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/AppsmithRepository.java:29-29
Timestamp: 2024-06-03T11:52:27.242Z
Learning: The codebase has mechanisms to gracefully handle `null` values, making the use of `Optional` for `AclPermission` unnecessary in certain contexts.
app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java (2)
User: sharat87
PR: appsmithorg/appsmith#33602
File: app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java:462-473
Timestamp: 2024-06-03T11:56:24.442Z
Learning: The codebase has mechanisms to gracefully handle `null` values, making the use of `Optional` for `AclPermission` unnecessary in certain contexts. This is leveraged by replacing `Optional.empty()` with `null` in method signatures where `null` is already handled gracefully.
User: sharat87
PR: appsmithorg/appsmith#33602
File: app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/AppsmithRepository.java:29-29
Timestamp: 2024-06-03T11:52:27.242Z
Learning: The codebase has mechanisms to gracefully handle `null` values, making the use of `Optional` for `AclPermission` unnecessary in certain contexts.
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/WorkspaceServiceCEImpl.java (1)
User: sharat87
PR: appsmithorg/appsmith#33602
File: app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java:462-473
Timestamp: 2024-06-03T11:56:24.442Z
Learning: The codebase has mechanisms to gracefully handle `null` values, making the use of `Optional` for `AclPermission` unnecessary in certain contexts. This is leveraged by replacing `Optional.empty()` with `null` in method signatures where `null` is already handled gracefully.
app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCEImpl.java (1)
User: sharat87
PR: appsmithorg/appsmith#33602
File: app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java:462-473
Timestamp: 2024-06-03T11:56:24.442Z
Learning: The codebase has mechanisms to gracefully handle `null` values, making the use of `Optional` for `AclPermission` unnecessary in certain contexts. This is leveraged by replacing `Optional.empty()` with `null` in method signatures where `null` is already handled gracefully.
Additional comments not posted (7)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/WorkspaceServiceCE.java (1)

Line range hint 17-17: The updated method signature for findById improves readability and aligns with the codebase's handling of null values.

Verification successful

The method signature for findById in the WorkspaceServiceCE interface is already using AclPermission as expected. This aligns with the changes mentioned in the review comment, and no issues were found regarding the method signature.

  • WorkspaceServiceCE.java contains the method signature for findById using AclPermission.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all calls to `findById` in the WorkspaceServiceCE interface have been updated across the codebase.

# Test: Search for the method usage with the old signature. Expect: No occurrences.
rg --type java $'findById\([^,]+,\s*Optional<'

Length of output: 47



Script:

#!/bin/bash
# Description: Verify that the new method signature for `findById` in the WorkspaceServiceCE interface is used correctly across the codebase.

# Test: Search for the method usage with the new signature. Expect: Occurrences with the new signature.
rg --type java 'findById\([^,]+,\s*AclPermission\)'

Length of output: 53



Script:

#!/bin/bash
# Description: Verify the `findById` method signature within the `WorkspaceServiceCE` interface.

# Test: Search for the method definition within the `WorkspaceServiceCE` interface. Expect: The method definition with the new signature.
ast-grep --lang java --pattern 'interface WorkspaceServiceCE {
  $_
  Mono<Workspace> findById($_, AclPermission $_);
  $_
}'

Length of output: 127



Script:

#!/bin/bash
# Description: Display the content of the `WorkspaceServiceCE` interface file to verify its method signatures.

# Test: Output the content of the `WorkspaceServiceCE` interface file.
fd 'WorkspaceServiceCE.java' -x cat

Length of output: 2480

app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/AppsmithRepository.java (1)

11-11: The updated method signature for findById improves readability and aligns with the codebase's handling of null values.

Verification successful

The verification confirms that the findById method signature has been updated to use AclPermission across various files in the codebase.

  • app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/AppsmithRepository.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/WorkspaceServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/WorkspaceServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/TenantServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/TenantServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/PermissionGroupRepositoryCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java

This indicates that the changes have been consistently applied throughout the codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all calls to `findById` in the AppsmithRepository interface have been updated across the codebase.

# Test: Search for the method usage with the old signature. Expect: No occurrences.
rg --type java $'findById\([^,]+,\s*Optional<'

Length of output: 47



Script:

#!/bin/bash
# Description: Verify that all calls to `findById` in the AppsmithRepository interface have been updated across the codebase.

# Test: Search for the method usage with the new signature. Expect: Occurrences of the new method signature.
rg --type java $'findById\([^,]+,\s*AclPermission'

Length of output: 3823

app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java (1)

Line range hint 104-104: The updated method signature for findById improves readability and aligns with the codebase's handling of null values.

Verification successful

The updated method signature for findById with AclPermission is used consistently across the codebase, as evidenced by the search results. There are no instances of the old signature (findById with Optional), confirming that the codebase has been updated correctly.

  • app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/TenantServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/WorkspaceServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/TenantServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/WorkspaceServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/AppsmithRepository.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/BaseAppsmithRepositoryCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/PermissionGroupRepositoryCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCE.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/applications/base/ApplicationServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/actioncollections/base/ActionCollectionServiceCE.java
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all calls to `findById` in the BaseAppsmithRepositoryCEImpl class have been updated across the codebase.

# Test: Search for the method usage with the old signature. Expect: No occurrences.
rg --type java $'findById\([^,]+,\s*Optional<'

Length of output: 47



Script:

#!/bin/bash
# Description: Verify that the updated method signature for `findById` is used consistently across the codebase.

# Test: Search for the method usage with the updated signature. Expect: Multiple occurrences.
rg --type java $'findById\([^,]+,\s*AclPermission'

Length of output: 3823

app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCEImpl.java (4)

143-143: The method signature and the call to createEx have been updated to use AclPermission directly instead of Optional<AclPermission>. This aligns with the PR's objective to simplify method signatures by removing unnecessary usage of Optional. Good to see consistency in implementation across different methods.


149-149: The method createWithoutPermissions now passes null directly to createEx, reflecting the removal of Optional. This change is consistent with the learning that the codebase handles null values gracefully. This simplifies the code by avoiding unnecessary wrapping and unwrapping of Optional.


265-265: The method generateAndSetDatasourcePolicies now accepts AclPermission directly. This is a good improvement, as it simplifies the code by removing the unnecessary use of Optional. The change should make the codebase cleaner and more straightforward.


152-152: The updated createEx method now directly accepts AclPermission instead of Optional<AclPermission>. This change simplifies the method signature and avoids the need for null checks associated with Optional. Ensure that all callers of this method are updated to pass AclPermission directly or null where appropriate.

Verification successful

The rg output shows that the calls to createEx in the DatasourceServiceCEImpl class are consistent with the new method signature. Specifically, the calls are made with either a valid AclPermission or null, which aligns with the updated method.

  • app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCEImpl.java: return createEx(datasource, workspacePermission.getDatasourceCreatePermission());
  • app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCEImpl.java: return createEx(datasource, null);
  • app/server/appsmith-server/src/main/java/com/appsmith/server/datasources/base/DatasourceServiceCEImpl.java: private Mono<Datasource> createEx(@NotNull Datasource datasource, AclPermission permission);

These lines confirm that the method calls have been updated to match the new signature.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all function calls to `createEx` match the new signature.
# Test: Search for the function usage. Expect: Only occurances of the new signature.
rg --type java $'createEx'

Length of output: 5869

@sharat87 sharat87 merged commit ef01ab5 into release Jun 20, 2024
51 of 52 checks passed
@sharat87 sharat87 deleted the chore/no-find-by-id-optional branch June 20, 2024 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants