-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Conversation
WalkthroughThe changes across multiple files focus on refining the method signatures by removing the usage of Changes
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this 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 VerificationThe search results indicate that the method
findById
withAclPermission
is still present in the codebase, including in theWorkspaceServiceCEImpl
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 forfindById
improves readability and aligns with the codebase's handling ofnull
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
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 forfindById
improves readability and aligns with the codebase's handling ofnull
values.Verification successful
The method signature for
findById
in theWorkspaceServiceCE
interface is already usingAclPermission
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 forfindById
usingAclPermission
.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 catLength of output: 2480
app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/AppsmithRepository.java (1)
11-11
: The updated method signature forfindById
improves readability and aligns with the codebase's handling ofnull
values.Verification successful
The verification confirms that the
findById
method signature has been updated to useAclPermission
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 forfindById
improves readability and aligns with the codebase's handling ofnull
values.Verification successful
The updated method signature for
findById
withAclPermission
is used consistently across the codebase, as evidenced by the search results. There are no instances of the old signature (findById
withOptional
), 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 tocreateEx
have been updated to useAclPermission
directly instead ofOptional<AclPermission>
. This aligns with the PR's objective to simplify method signatures by removing unnecessary usage ofOptional
. Good to see consistency in implementation across different methods.
149-149
: The methodcreateWithoutPermissions
now passesnull
directly tocreateEx
, reflecting the removal ofOptional
. This change is consistent with the learning that the codebase handlesnull
values gracefully. This simplifies the code by avoiding unnecessary wrapping and unwrapping ofOptional
.
265-265
: The methodgenerateAndSetDatasourcePolicies
now acceptsAclPermission
directly. This is a good improvement, as it simplifies the code by removing the unnecessary use ofOptional
. The change should make the codebase cleaner and more straightforward.
152-152
: The updatedcreateEx
method now directly acceptsAclPermission
instead ofOptional<AclPermission>
. This change simplifies the method signature and avoids the need for null checks associated withOptional
. Ensure that all callers of this method are updated to passAclPermission
directly ornull
where appropriate.Verification successful
The
rg
output shows that the calls tocreateEx
in theDatasourceServiceCEImpl
class are consistent with the new method signature. Specifically, the calls are made with either a validAclPermission
ornull
, 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
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
Optional
for permissions, simplifying method signatures and improving readability.