chore: simplify logic expressions - Merge after #3272#3273
chore: simplify logic expressions - Merge after #3272#3273ogzhanolguncu wants to merge 2 commits intomainfrom
Conversation
|
📝 WalkthroughWalkthroughThis change refactors numerous conditional expressions across the codebase, replacing patterns like Changes
Sequence Diagram(s)No sequence diagrams generated as the changes are limited to condition refactoring and do not affect control flow or introduce new features. Possibly related PRs
Suggested reviewers
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Thank you for following the naming conventions for pull request titles! 🙏 |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (57)
apps/api/src/routes/v1_identities_getIdentity.ts(1 hunks)apps/api/src/routes/v1_identities_updateIdentity.ts(1 hunks)apps/api/src/routes/v1_keys_getVerifications.ts(1 hunks)apps/api/src/routes/v1_migrations_createKey.ts(1 hunks)apps/api/src/routes/v1_ratelimits_deleteOverride.ts(1 hunks)apps/api/src/routes/v1_ratelimits_getOverride.ts(1 hunks)apps/api/src/routes/v1_ratelimits_listOverrides.ts(1 hunks)apps/api/src/routes/v1_ratelimits_setOverride.ts(1 hunks)apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/expiration-setup.tsx(1 hunks)apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/metadata-setup.tsx(1 hunks)apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.schema.ts(1 hunks)apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.utils.ts(1 hunks)apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-datetime/index.tsx(1 hunks)apps/dashboard/app/(app)/apis/[apiId]/_overview/hooks/use-filters.ts(1 hunks)apps/dashboard/app/(app)/apis/[apiId]/actions.ts(1 hunks)apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-datetime/index.tsx(1 hunks)apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-external-id/index.tsx(2 hunks)apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx(1 hunks)apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/hooks/use-keys-list-query.ts(1 hunks)apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx(2 hunks)apps/dashboard/app/(app)/authorization/roles/[roleId]/page.tsx(1 hunks)apps/dashboard/app/(app)/settings/billing/client.tsx(1 hunks)apps/dashboard/app/(app)/settings/team/client.tsx(1 hunks)apps/dashboard/app/(app)/settings/team/invite.tsx(1 hunks)apps/dashboard/app/integrations/vercel/callback/client.tsx(1 hunks)apps/dashboard/app/new/create-ratelimit.tsx(1 hunks)apps/dashboard/components/logs/chart/index.tsx(2 hunks)apps/dashboard/components/logs/details/resizable-panel.tsx(1 hunks)apps/dashboard/components/logs/hooks/use-bookmarked-filters.ts(1 hunks)apps/dashboard/components/logs/overview-charts/overview-area-chart.tsx(3 hunks)apps/dashboard/components/logs/overview-charts/overview-bar-chart.tsx(2 hunks)apps/dashboard/components/logs/overview-charts/utils.tsx(1 hunks)apps/dashboard/components/logs/queries/queries-popover.tsx(1 hunks)apps/dashboard/components/logs/validation/utils/nuqs-parsers.ts(1 hunks)apps/dashboard/components/navigation/sidebar/app-sidebar/components/nav-items/nested-nav-item.tsx(1 hunks)apps/dashboard/components/stats-card/components/chart/stats-chart.tsx(1 hunks)apps/dashboard/components/ui/chart.tsx(2 hunks)apps/dashboard/components/virtual-table/hooks/useVirtualData.ts(2 hunks)apps/dashboard/components/virtual-table/index.tsx(1 hunks)apps/dashboard/hooks/use-keyboard-shortcut.tsx(1 hunks)apps/dashboard/lib/auth.ts(1 hunks)apps/dashboard/lib/auth/local.ts(4 hunks)apps/dashboard/lib/auth/server.ts(1 hunks)apps/dashboard/lib/auth/workos.ts(5 hunks)apps/dashboard/lib/posthog.ts(1 hunks)apps/dashboard/lib/trpc/routers/api/keys/api-query.ts(1 hunks)apps/dashboard/lib/trpc/routers/api/keys/query-active-keys-timeseries/index.ts(1 hunks)apps/dashboard/lib/trpc/routers/api/keys/query-overview-logs/index.ts(1 hunks)apps/dashboard/lib/trpc/routers/api/keys/query-overview-timeseries/index.ts(1 hunks)apps/dashboard/lib/trpc/routers/utils/granularity.ts(1 hunks)apps/dashboard/lib/zod-helper.ts(1 hunks)apps/dashboard/pages/api/v1/github/verify.ts(2 hunks)apps/dashboard/pages/api/v1/workos/webhooks.ts(1 hunks)apps/engineering/app/components/render.tsx(1 hunks)biome.json(2 hunks)tools/artillery/main.ts(1 hunks)tools/local/src/main.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (6)
apps/dashboard/lib/trpc/routers/api/keys/query-overview-logs/index.ts (1)
internal/clickhouse/src/index.ts (1)
api(191-213)
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-datetime/index.tsx (1)
apps/dashboard/components/logs/datetime/constants.ts (1)
DEFAULT_OPTIONS(3-94)
apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-datetime/index.tsx (1)
apps/dashboard/components/logs/datetime/constants.ts (1)
DEFAULT_OPTIONS(3-94)
apps/dashboard/lib/trpc/routers/api/keys/query-overview-timeseries/index.ts (1)
internal/clickhouse/src/index.ts (1)
api(191-213)
apps/dashboard/components/logs/hooks/use-bookmarked-filters.ts (1)
apps/dashboard/lib/utils.ts (1)
isBrowser(8-8)
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/hooks/use-keys-list-query.ts (1)
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/filters.schema.ts (1)
keysListFilterFieldNames(44-44)
⏰ Context from checks skipped due to timeout of 90000ms (11)
- GitHub Check: Test Go API Local / Test (Shard 8/8)
- GitHub Check: Test Go API Local / Test (Shard 7/8)
- GitHub Check: Test Go API Local / Test (Shard 4/8)
- GitHub Check: Test Go API Local / Test (Shard 6/8)
- GitHub Check: Test Go API Local / Test (Shard 1/8)
- GitHub Check: Build / Build
- GitHub Check: Test API / API Test Local
- GitHub Check: Test Packages / Test ./packages/nextjs
- GitHub Check: Test Packages / Test ./internal/clickhouse
- GitHub Check: autofix
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (71)
apps/dashboard/app/(app)/apis/[apiId]/actions.ts (1)
23-23: LGTM! Logic simplification follows De Morgan's law correctly.The transformation from
!apiId || !orgIdto!(apiId && orgId)is logically equivalent and improves consistency with the codebase-wide refactoring pattern.apps/api/src/routes/v1_keys_getVerifications.ts (1)
306-306: LGTM! Optional chaining simplifies the null check elegantly.The change from
!data || !data.lengthto!data?.lengthmaintains the same logic while being more concise. Optional chaining handles both the null/undefined check and the length check in a single expression.apps/api/src/routes/v1_ratelimits_deleteOverride.ts (1)
69-69: LGTM! Logic refactoring is mathematically sound.The transformation from
!namespaceId && !namespaceNameto!(namespaceId || namespaceName)follows De Morgan's law (!(A || B) = !A && !B) and maintains identical validation behavior while improving consistency.apps/dashboard/lib/trpc/routers/utils/granularity.ts (1)
65-65: LGTM! Boolean expression simplification is logically correct.The change from
!startTime && !endTimeto!(startTime || endTime)applies De Morgan's law correctly, ensuring both conditions must be falsy for the default granularity logic to execute.apps/dashboard/lib/trpc/routers/api/keys/query-overview-logs/index.ts (1)
32-32: LGTM! Valid simplification using optional chaining.The change from
!api || !api.keyAuth?.idto!api?.keyAuth?.idis a valid simplification. The optional chaining operator?.already handles the case whereapiis null/undefined, making the explicit!apicheck redundant.apps/dashboard/components/navigation/sidebar/app-sidebar/components/nav-items/nested-nav-item.tsx (1)
46-46: LGTM! Logically equivalent transformation following De Morgan's law.The change from
!hasChildren || !pathnameto!(hasChildren && pathname)is logically equivalent by De Morgan's law:!(A && B) = !A || !B. This maintains the same behavior while following the consistent pattern of using negated conjunctions throughout the codebase.apps/dashboard/components/logs/validation/utils/nuqs-parsers.ts (1)
77-77: LGTM! Logically equivalent transformation maintaining validation logic.The change from
!column || !directionto!(column && direction)is logically equivalent by De Morgan's law. This ensures bothcolumnanddirectionare truthy before proceeding, maintaining the same validation behavior while following the consistent pattern of using negated conjunctions.apps/dashboard/components/virtual-table/index.tsx (1)
415-415: LGTM! Logically equivalent transformation maintaining guard clause behavior.The change from
!sortable || !onSortto!(sortable && onSort)is logically equivalent by De Morgan's law. This maintains the guard clause that prevents sorting when eithersortableoronSortis falsy, while following the consistent pattern of using negated conjunctions throughout the codebase.apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.schema.ts (1)
212-212: Excellent simplification using Date.now().This change from
new Date().getTime()toDate.now()is a great improvement that:
- Eliminates unnecessary Date object creation
- Improves performance slightly
- Makes the code more readable and conventional
- Aligns with the broader codebase simplification effort
apps/dashboard/lib/trpc/routers/api/keys/api-query.ts (1)
227-227: Clean simplification using optional chaining.The refactoring from explicit null checks to optional chaining (
!combinedResults?.keyAuth?.id) maintains the same logical behavior while being more concise and readable. The error handling remains intact for all cases where the API is not found or lacks key authentication.apps/dashboard/lib/trpc/routers/api/keys/query-overview-timeseries/index.ts (1)
16-16: Consistent simplification with optional chaining.This change follows the same beneficial pattern as other files in this PR, using optional chaining to simplify the condition while maintaining identical error handling behavior. The consistency across the codebase improves maintainability.
apps/dashboard/app/(app)/settings/team/invite.tsx (1)
62-62: Proper application of De Morgan's law for consistency.The transformation from
!user!.orgId || !organizationto!(user!.orgId && organization)is logically equivalent and aligns with the PR's goal of standardizing boolean expressions. This change makes the requirement more explicit: bothuser!.orgIdandorganizationmust be truthy for the component to render.apps/dashboard/components/logs/details/resizable-panel.tsx (1)
41-41: LGTM! Logical expression simplified using De Morgan's law.The condition change from
!isDragging || !panelRef.currentto!(isDragging && panelRef.current)is logically equivalent and follows the standardization pattern outlined in the PR objectives.apps/dashboard/app/(app)/authorization/roles/[roleId]/page.tsx (1)
67-67: LGTM! Simplified using optional chaining.The change from
!role || !role.workspaceto!role?.workspacemaintains the same logical behavior while being more concise and readable. This aligns with modern JavaScript/TypeScript best practices.apps/api/src/routes/v1_identities_updateIdentity.ts (1)
143-143: LGTM! Applied De Morgan's law to simplify the condition.The transformation from
!req.identityId && !req.externalIdto!(req.identityId || req.externalId)is logically equivalent and ensures that at least one identifier (identityId or externalId) is provided. This follows the PR's pattern of standardizing logical expressions.apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-datetime/index.tsx (1)
70-70: LGTM! Simplified filtering logic with optional chaining.The change to
!option.value?.endsWith("m")maintains the same filtering behavior while being more concise. This correctly filters out minute-based time options (like "1m", "5m", etc.) from theDEFAULT_OPTIONSwhile preserving options with undefined values.apps/dashboard/lib/trpc/routers/api/keys/query-active-keys-timeseries/index.ts (1)
15-15: Excellent simplification using optional chaining.The change from explicit null checks to
!api?.keyAuth?.idmaintains the same logical behavior while improving readability. The optional chaining handles all the same edge cases (nullapi, missingkeyAuth, or missingid) more elegantly.apps/api/src/routes/v1_identities_getIdentity.ts (1)
83-83: Logic simplification follows De Morgan's law correctly.The transformation from
!identityId && !externalIdto!(identityId || externalId)is logically equivalent and improves readability. Both expressions evaluate to true when neither parameter is provided, maintaining the same validation behavior.tools/artillery/main.ts (1)
26-26: Environment variable validation simplified correctly.The change from
!ARTILLERY_CLOUD_API_KEY || !UNKEY_KEYto!(ARTILLERY_CLOUD_API_KEY && UNKEY_KEY)applies De Morgan's law correctly. Both expressions exit the process when either environment variable is missing, maintaining the same validation behavior while improving readability.apps/api/src/routes/v1_ratelimits_listOverrides.ts (1)
77-77: Parameter validation logic simplified correctly.The transformation from
!namespaceId && !namespaceNameto!(namespaceId || namespaceName)is logically equivalent and follows De Morgan's law. Both expressions throw aBAD_REQUESTerror when neither parameter is provided, maintaining the same API validation behavior while improving code consistency.apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/expiration-setup.tsx (1)
126-126: LGTM! Performance improvement withDate.now().Replacing
new Date().getTime()withDate.now()is a good optimization that maintains identical functionality while being more performant and readable. This aligns well with the overall code improvement goals of this PR.apps/api/src/routes/v1_ratelimits_setOverride.ts (1)
84-84: LGTM! Clean logical expression simplification.The refactoring from
!req.namespaceId && !req.namespaceNameto!(req.namespaceId || req.namespaceName)is a perfect example of applying De Morgan's law to improve readability. The new form more clearly expresses the intent: "if neither namespaceId nor namespaceName is provided."apps/dashboard/app/(app)/apis/[apiId]/_overview/hooks/use-filters.ts (1)
49-51: LGTM! Logical expression simplification improves clarity.The refactoring to
!(Array.isArray(value) && ["keyIds", "names", "identities", "outcomes"].includes(field))makes the condition more explicit. It clearly states that processing should continue unless BOTH conditions are met (value is an array AND field is in the specified list), which aligns with the PR's goal of simplifying logical expressions.apps/api/src/routes/v1_ratelimits_getOverride.ts (1)
75-75: LGTM! Consistent logical expression simplification.The refactoring from
!namespaceId && !namespaceNameto!(namespaceId || namespaceName)applies the same De Morgan's law transformation as in the setOverride route. This consistency across similar API endpoints is excellent and improves the overall codebase readability.apps/dashboard/lib/zod-helper.ts (1)
67-67: LGTM! Nice performance and readability improvement.Using
Date.now()instead ofnew Date().getTime()is a good refactor as it's more direct, slightly more performant (avoids object creation), and more readable while maintaining identical functionality.apps/dashboard/components/ui/chart.tsx (2)
76-76: Good lint suppression with clear justification.The biome-ignore comment appropriately suppresses the
noDangerouslySetInnerHtmlwarning with a clear explanation of why it's necessary for dynamic CSS generation.
158-158: LGTM! Clean logic expression simplification.The transformation from
!active || !payload?.lengthto!(active && payload?.length)follows De Morgan's law and aligns with the new linting rules. The logic remains identical while improving readability.apps/dashboard/lib/auth/server.ts (1)
41-41: LGTM! Logic expression simplification improves readability.The transformation from
!WORKOS_API_KEY || !WORKOS_CLIENT_IDto!(WORKOS_API_KEY && WORKOS_CLIENT_ID)follows De Morgan's law and is more readable as it directly expresses "if not both are present". This aligns with the PR's goal of simplifying logic expressions.apps/dashboard/app/(app)/settings/billing/client.tsx (1)
80-82: LGTM! Logic expression simplified effectively.The refactored boolean expression using De Morgan's law improves readability by clearly expressing "not (has active or trialing subscription)" which aligns perfectly with the
isFreeTiervariable name. The logical behavior remains unchanged.apps/api/src/routes/v1_migrations_createKey.ts (1)
405-405: LGTM! Clear application of De Morgan's law.The simplified expression
!(key.hash || key.plaintext)is more intuitive to read as "not (has hash or plaintext)" and maintains the same validation logic. This change improves consistency with the broader codebase refactoring effort.apps/dashboard/components/logs/queries/queries-popover.tsx (1)
43-43: LGTM! Keyboard shortcut logic simplified effectively.The refactored condition
!(open || isDisabled)clearly expresses the intent to only allow popover opening when it's "not (open or disabled)". This maintains the correct keyboard shortcut behavior while improving readability.apps/engineering/app/components/render.tsx (1)
33-33: LGTM! Props filtering logic simplified nicely.The refactored expression
!(key.startsWith("_") || key.startsWith("$"))is more intuitive to read as "not (internal React prop)" and maintains the same filtering behavior for excluding props starting with "_" or "$". This aligns well with the PR's goal of standardizing boolean expressions.apps/dashboard/app/(app)/settings/team/client.tsx (1)
55-55: Logic simplification looks good!The refactoring from
!user || !organization || !userMemberships || !currentOrgMembershipto!(user && organization && userMemberships && currentOrgMembership)correctly applies De Morgan's law and improves readability by expressing "if not all required values are present" rather than "if any required value is missing".apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-datetime/index.tsx (1)
70-70: Nice simplification with optional chaining!The filter condition has been improved by using optional chaining (
option.value?.endsWith("m")) which elegantly handles the case whereoption.valueis undefined (as seen in the "Custom" option fromDEFAULT_OPTIONS). This maintains the same filtering logic while being more concise.apps/dashboard/lib/auth/workos.ts (5)
177-177: Consistent logic simplification in createTenant.The refactoring correctly applies De Morgan's law:
!name || !userId≡!(name && userId). This improves readability and aligns with the PR's standardization effort.
224-224: Consistent logic simplification in updateOrg.The transformation from
!id || !nameto!(id && name)maintains the same validation logic while improving consistency with other parameter checks in the codebase.
259-259: Logical simplification in switchOrg method.The change from
!refreshResult.authenticated || !refreshResult.sessionto!(refreshResult.authenticated && refreshResult.session)correctly applies De Morgan's law and makes the condition more readable.
369-369: Consistent parameter validation simplification.The refactoring from
!membershipId || !roleto!(membershipId && role)follows the same pattern applied throughout this file and improves logical expression consistency.
418-418: Logic simplification in inviteMember method.The transformation from
!orgId || !emailto!(orgId && email)completes the consistent refactoring pattern across all parameter validation checks in this file.apps/dashboard/components/virtual-table/hooks/useVirtualData.ts (2)
43-43: Logic simplification for early return condition.The refactoring from
!lastItem || !onLoadMoreto!(lastItem && onLoadMore)correctly applies De Morgan's law and makes the early return condition more readable by expressing "if not both conditions are met".
56-56: Consistent boolean expression simplification.The transformation from
!isLoading && !isFetchingNextPageto!(isLoading || isFetchingNextPage)maintains the same logic while aligning with the PR's standardization of boolean expressions across the codebase.apps/dashboard/lib/posthog.ts (1)
10-10: LGTM! Logical expression simplification is correct.The refactoring from
!process.env.NEXT_PUBLIC_POSTHOG_KEY || !process.env.NEXT_PUBLIC_POSTHOG_HOSTto!(process.env.NEXT_PUBLIC_POSTHOG_KEY && process.env.NEXT_PUBLIC_POSTHOG_HOST)is logically equivalent by De Morgan's law and improves readability by expressing the intent more clearly: "if NOT (both environment variables are present)".apps/dashboard/app/new/create-ratelimit.tsx (1)
18-18: LGTM! Logical expression simplification improves readability.The transformation from
!user?.orgId || !user.roleto!(user?.orgId && user.role)is logically equivalent and expresses the intent more clearly: "if NOT (both user.orgId and user.role exist)". The consistent optional chaining pattern also improves code clarity.apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx (2)
101-101: LGTM! UI rendering logic simplification is correct.The change from
!isSelected && !isHoveredto!(isSelected || isHovered)is logically equivalent and more readable. It clearly expresses the intent: "show the icon when the row is NOT (selected OR hovered)".
282-282: LGTM! Early exit condition simplification is correct.The transformation from
!allEnabled && !allDisabledto!(allEnabled || allDisabled)maintains logical equivalence while improving readability. It clearly expresses the mixed state condition: "if NOT (all enabled OR all disabled)".apps/dashboard/components/logs/overview-charts/utils.tsx (1)
26-26: Logic transformation correctly applied.The change from
!currentTimestamp || !data?.lengthto!(currentTimestamp && data?.length)is logically equivalent by De Morgan's law. The new form explicitly requires both conditions to be truthy for the main formatting logic to proceed.apps/dashboard/lib/auth.ts (1)
35-35: Logic transformation correctly applied.The change from
!authResult.orgId && !authResult.roleto!(authResult.orgId || authResult.role)is logically equivalent by De Morgan's law. The new form reads more naturally as "if neither orgId nor role is present".apps/dashboard/hooks/use-keyboard-shortcut.tsx (1)
201-201: Logic transformation correctly applied.The change from
!keyAssigned || !combo.key || !combo.codeto!(keyAssigned && combo.key && combo.code)is logically equivalent by De Morgan's law. The new form better expresses the requirement that all three conditions must be satisfied for validation to pass.apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/metadata-setup.tsx (1)
103-103: Logic transformation correctly applied.The change from
!value || !validateJSON(value)to!(value && validateJSON(value))is logically equivalent by De Morgan's law. The new form better expresses that both a truthy value AND valid JSON are required for the validation to pass.apps/dashboard/lib/auth/local.ts (1)
152-152: LGTM! Excellent boolean logic simplification.The refactoring from
!param1 || !param2to!(param1 && param2)using De Morgan's laws improves readability by directly expressing the requirement that both parameters must be present. The logic is mathematically equivalent and maintains the same validation behavior.Also applies to: 185-185, 265-265, 292-292
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx (1)
50-50: LGTM! Clear boolean logic improvement.The transformation from
!isConfirmPopoverOpen && !opento!(isConfirmPopoverOpen || open)correctly applies De Morgan's law and makes the condition more readable by directly expressing "if neither condition is true".apps/dashboard/components/logs/hooks/use-bookmarked-filters.ts (1)
34-34: LGTM! Logical simplification enhances clarity.The refactoring from
!filters.length || !isBrowserto!(filters.length && isBrowser)is mathematically equivalent and more clearly expresses the requirement that both conditions must be met to proceed with the effect logic.apps/dashboard/components/stats-card/components/chart/stats-chart.tsx (1)
70-70: LGTM! Partial boolean logic improvement.The refactoring of the first part of the condition from
!active || !payload?.lengthto!(active && payload?.length)correctly applies De Morgan's law and improves readability by directly expressing that bothactiveandpayload?.lengthmust be truthy for the tooltip to render.apps/dashboard/app/integrations/vercel/callback/client.tsx (1)
50-53: LGTM! Logical expression correctly simplified.The transformation from
!projectId || !(selectedApis.development || selectedApis.preview || selectedApis.production)to!(projectId && (selectedApis.development || selectedApis.preview || selectedApis.production))correctly applies De Morgan's law while maintaining the same logical behavior. The button remains disabled when either no project is selected or no APIs are configured.apps/dashboard/pages/api/v1/workos/webhooks.ts (2)
12-12: LGTM! Environment variable validation correctly simplified.The transformation correctly applies De Morgan's law, changing from checking if any individual environment variable is missing to checking if not all variables are present. The logic remains equivalent.
16-16: LGTM! Payload validation correctly simplified.The transformation from
!payload || !sigHeaderto!(payload && sigHeader)correctly applies De Morgan's law while maintaining the same validation logic - the request fails if either the payload or signature header is missing.apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-external-id/index.tsx (2)
54-54: LGTM! Dialog state logic correctly simplified.The transformation from
!isConfirmPopoverOpen && !opento!(isConfirmPopoverOpen || open)correctly applies De Morgan's law. The dialog will close when neither the confirm popover nor the dialog itself should be open.
102-102: LGTM! Button disabled state correctly simplified.The transformation from
!originalIdentityId && !selectedIdentityIdto!(originalIdentityId || selectedIdentityId)correctly applies De Morgan's law. The button remains disabled when neither an original nor selected identity ID is available.apps/dashboard/components/logs/overview-charts/overview-area-chart.tsx (3)
82-82: LGTM! Mouse move logic correctly simplified.The transformation from
!enableSelection || !selection.startto!(enableSelection && selection.start)correctly applies De Morgan's law. The function will still return early when selection is disabled or no selection start point exists.
98-98: LGTM! Timestamp validation correctly simplified.The transformation from
!selection.startTimestamp || !selection.endTimestampto!(selection.startTimestamp && selection.endTimestamp)correctly applies De Morgan's law. The validation logic remains the same - requiring both timestamps to be present.
233-233: LGTM! Tooltip condition correctly simplified.The transformation from
!active || !payload?.lengthto!(active && payload?.length)correctly applies De Morgan's law. The tooltip will still only render when both the tooltip is active and payload data exists.apps/dashboard/pages/api/v1/github/verify.ts (1)
55-55: LGTM! Logical expression correctly simplified.The transformation from
!RESEND_API_KEY || !GITHUB_KEYS_URIto!(RESEND_API_KEY && GITHUB_KEYS_URI)correctly applies De Morgan's law while maintaining the same logic.apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/hooks/use-keys-list-query.ts (1)
27-27: LGTM! Logical expression correctly simplified.The transformation correctly applies De Morgan's law:
!A || !B≡!(A && B). The filter validation logic remains functionally identical while improving code consistency.apps/dashboard/components/logs/chart/index.tsx (2)
97-97: LGTM! Timestamp validation logic correctly simplified.The transformation from
!selection.startTimestamp || !selection.endTimestampto!(selection.startTimestamp && selection.endTimestamp)correctly applies De Morgan's law while maintaining the same validation logic.
157-157: LGTM! Tooltip condition logic correctly refactored.The transformation correctly applies De Morgan's law to the first part of the condition while preserving the additional
payload?.[0]?.payload.total === 0check. The tooltip display logic remains functionally identical.apps/dashboard/components/logs/overview-charts/overview-bar-chart.tsx (2)
99-99: LGTM! Selection validation logic correctly simplified.The transformation correctly applies De Morgan's law, maintaining the same timestamp validation behavior while improving code consistency with the broader refactoring effort.
191-191: LGTM! Tooltip rendering condition correctly refactored.The logical expression transformation maintains the same tooltip display behavior while following the consistent boolean expression style adopted throughout the codebase.
biome.json (4)
18-21: Enable stricter correctness lint rules
Raising these rules to error will help catch unused imports and enforce safer JSX key usage and optional chaining patterns. Please confirm that disablingnoChildrenPropis intentional for your components that rely on passingchildrenexplicitly.
24-24: DisallowdangerouslySetInnerHTMLfor security
Turning onnoDangerouslySetInnerHtmlas an error guards against XSS vulnerabilities. Ensure that any existingdangerouslySetInnerHTMLusages have been migrated to safer rendering approaches.
34-36: Enforce strict type and comparison checks
ElevatingnoDoubleEquals,useIsArray, andnoFallthroughSwitchClauseto errors promotes safer equality checks, array detection, and clearer switch logic.
41-48: Tighten complexity and logic rules
The new complexity rules (noExtraBooleanCast,noUselessTernary,useOptionalChain,useSimplifiedLogicExpression, etc.) will streamline conditional expressions and reduce boilerplate. Please verify that keepingnoForEachdisabled is intentional since banningforEachcan enforce functional patterns.
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.utils.ts
Show resolved
Hide resolved
| const [key, _value] = arg.split("="); | ||
| passedOptions[key.replace("--", "")] = true; |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Verify that removing value parsing is intentional.
This change fundamentally alters the argument parsing behavior from supporting --key=value pairs to treating all arguments as boolean flags. Any code expecting string values from command line arguments will be affected.
For example:
- Before:
--service=apiwould setpassedOptions.service = "api" - After:
--service=apisetspassedOptions.service = true
Looking at line 22, passedOptions.service is still used as a string value, which suggests this change may introduce bugs.
🏁 Script executed:
#!/bin/bash
# Check how passedOptions.service is used in the codebase
rg -A 3 -B 3 "passedOptions\.service" --type ts --type jsLength of output: 393
Restore value parsing for CLI arguments
The change at tools/local/src/main.ts (lines 15–16) now ignores any --key=value syntax and always sets flags to true, but later code treats passedOptions.service as a string:
- Location: tools/local/src/main.ts
- Usage:
let app = passedOptions.service; // expects a string service name if (!app) { … }
This breaks passing a service name via --service=api. Please revert to preserving values when provided:
Suggested diff:
- const [key, _value] = arg.split("=");
- passedOptions[key.replace("--", "")] = true;
+ const [key, value] = arg.split("=");
+ passedOptions[key.replace("--", "")] = value ?? true;🤖 Prompt for AI Agents
In tools/local/src/main.ts around lines 15 to 16, the current code sets all CLI
arguments as boolean flags by assigning true to passedOptions[key], which breaks
the expected behavior of parsing --key=value pairs as key-value strings. To fix
this, modify the code to check if a value exists after splitting on '=', and if
so, assign that value to passedOptions[key]; otherwise, assign true for flags
without values. This will restore proper parsing of string values for options
like --service=api.
| const data = JSON.parse(Buffer.from(rawBody).toString("utf8")); | ||
|
|
||
| if (!signature || !signature || !keyId || !data) { | ||
| if (!(signature && signature && keyId && data)) { |
There was a problem hiding this comment.
Fix duplicate condition in logical expression.
There's a duplicate signature && in the condition, which appears to be a refactoring error.
Apply this diff to fix the duplicate condition:
- if (!(signature && signature && keyId && data)) {
+ if (!(signature && keyId && data)) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!(signature && signature && keyId && data)) { | |
| if (!(signature && keyId && data)) { |
🤖 Prompt for AI Agents
In apps/dashboard/pages/api/v1/github/verify.ts at line 67, the condition
contains a duplicate check for 'signature' (signature && signature && keyId &&
data). Remove the redundant 'signature &&' so the condition reads 'if
(!(signature && keyId && data))' to correctly validate the presence of all
required variables without duplication.
|
aah shit I actually fixed some of these probably forgot to push |
|
i'll do it in 5min |
What does this PR do?
Simplifies logic expressions and adds lint rule.
Fixes # (issue)
If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists
Type of change
How should this be tested?
Checklist
Required
pnpm buildpnpm fmtconsole.logsgit pull origin mainAppreciated
Summary by CodeRabbit