Skip to content

chore: simplify logic expressions - Merge after #3272#3273

Closed
ogzhanolguncu wants to merge 2 commits intomainfrom
linter-logical-fix
Closed

chore: simplify logic expressions - Merge after #3272#3273
ogzhanolguncu wants to merge 2 commits intomainfrom
linter-logical-fix

Conversation

@ogzhanolguncu
Copy link
Contributor

@ogzhanolguncu ogzhanolguncu commented May 28, 2025

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

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Make sure billing is still working
  • Make sure auth is still working
  • Make sure root key creation works

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

Summary by CodeRabbit

  • Refactor
    • Updated conditional logic throughout the application to use simplified and unified boolean expressions, improving code clarity and consistency. No changes to user-facing functionality or behavior.
  • Chores
    • Enhanced linting rules for stricter code quality and security enforcement.
  • Style
    • Minor code style adjustments for improved readability and maintainability.
  • Bug Fixes
    • Corrected command-line argument parsing in local tooling to treat all options as boolean flags.

@changeset-bot
Copy link

changeset-bot bot commented May 28, 2025

⚠️ No Changeset found

Latest commit: d1699d7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 28, 2025

📝 Walkthrough

Walkthrough

This change refactors numerous conditional expressions across the codebase, replacing patterns like !a || !b and !a && !b with logically equivalent forms such as !(a && b) or !(a || b). The update also introduces stricter linting rules and minor code style improvements without altering public APIs or functional behavior.

Changes

File(s) / Path(s) Change Summary
apps/api/src/routes/v1_identities_getIdentity.ts, v1_identities_updateIdentity.ts, v1_migrations_createKey.ts, v1_ratelimits_deleteOverride.ts, v1_ratelimits_getOverride.ts, v1_ratelimits_listOverrides.ts, v1_ratelimits_setOverride.ts, v1_keys_getVerifications.ts Refactored conditional checks for parameter presence to use negated OR/AND expressions for clarity and consistency.
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/expiration-setup.tsx, create-key.schema.ts Replaced new Date().getTime() with Date.now() for current timestamp calculations.
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/metadata-setup.tsx Simplified validation logic for JSON metadata using a single negated conjunction.
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.utils.ts Removed fallback `
apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-datetime/index.tsx, keys/[keyAuthId]/[keyId]/components/controls/components/logs-datetime/index.tsx Simplified filtering logic for options using optional chaining.
apps/dashboard/app/(app)/apis/[apiId]/_overview/hooks/use-filters.ts, keys/[keyAuthId]/_components/components/table/hooks/use-keys-list-query.ts Refined filter processing logic to use positive conjunctions.
apps/dashboard/app/(app)/apis/[apiId]/actions.ts, settings/team/client.tsx, settings/team/invite.tsx, authorization/roles/[roleId]/page.ts, new/create-ratelimit.tsx Refactored presence checks for required data using negated AND expressions.
apps/dashboard/app/integrations/vercel/callback/client.tsx, settings/billing/client.tsx Refactored boolean flag logic for clarity.
apps/dashboard/components/logs/chart/index.tsx, overview-charts/overview-area-chart.tsx, overview-charts/overview-bar-chart.tsx, overview-charts/utils.tsx, details/resizable-panel.tsx, stats-card/components/chart/stats-chart.tsx, ui/chart.tsx Unified tooltip and event handler conditional logic using negated conjunctions.
apps/dashboard/components/logs/hooks/use-bookmarked-filters.ts Changed early return in effect to require both conditions using negated AND.
apps/dashboard/components/logs/queries/queries-popover.ts Refactored keyboard shortcut handler condition to negated OR.
apps/dashboard/components/navigation/sidebar/app-sidebar/components/nav-items/nested-nav-item.tsx Simplified effect early return using negated AND.
apps/dashboard/components/virtual-table/hooks/useVirtualData.ts, virtual-table/index.tsx Unified conditional checks in data loading and sorting functions.
apps/dashboard/hooks/use-keyboard-shortcut.tsx Refined shortcut validation using negated AND.
apps/dashboard/lib/auth.ts, lib/auth/local.ts, lib/auth/server.ts, lib/auth/workos.ts, lib/posthog.ts Standardized environment and parameter checks using negated AND/OR.
apps/dashboard/lib/trpc/routers/api/keys/api-query.ts, query-active-keys-timeseries/index.ts, query-overview-logs/index.ts, query-overview-timeseries/index.ts Simplified nested object existence checks using optional chaining.
apps/dashboard/lib/trpc/routers/utils/granularity.ts Refactored time parameter check using negated OR.
apps/dashboard/lib/zod-helper.ts Used Date.now() for future date calculation in schema validation.
apps/dashboard/pages/api/v1/github/verify.ts, pages/api/v1/workos/webhooks.ts Unified environment and request data validation using negated AND.
apps/engineering/app/components/render.tsx Changed prop filtering logic to use negated OR for exclusion.
biome.json Enforced stricter linting rules for correctness, security, suspicious code, and complexity.
tools/artillery/main.ts Corrected environment variable check to require both variables.
tools/local/src/main.ts Changed argument parsing to treat all CLI options as boolean flags.

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

  • unkeyed/unkey#3254: Refactors the early-return condition in useBookmarkedFilters to use a logically equivalent negated AND, similar to the change in this PR.

Suggested reviewers

  • perkinsjr
  • mcstepp
  • chronark
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @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.

Support

Need 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)

  • @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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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
Copy link
Contributor

github-actions bot commented May 28, 2025

Thank you for following the naming conventions for pull request titles! 🙏

@vercel
Copy link

vercel bot commented May 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 28, 2025 11:49am
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 28, 2025 11:49am

@vercel vercel bot temporarily deployed to Preview – engineering May 28, 2025 11:49 Inactive
@vercel vercel bot temporarily deployed to Preview – dashboard May 28, 2025 11:49 Inactive
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: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2d5fe4 and d1699d7.

📒 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 || !orgId to !(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.length to !data?.length maintains 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 && !namespaceName to !(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 && !endTime to !(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?.id to !api?.keyAuth?.id is a valid simplification. The optional chaining operator ?. already handles the case where api is null/undefined, making the explicit !api check 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 || !pathname to !(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 || !direction to !(column && direction) is logically equivalent by De Morgan's law. This ensures both column and direction are 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 || !onSort to !(sortable && onSort) is logically equivalent by De Morgan's law. This maintains the guard clause that prevents sorting when either sortable or onSort is 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() to Date.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 || !organization to !(user!.orgId && organization) is logically equivalent and aligns with the PR's goal of standardizing boolean expressions. This change makes the requirement more explicit: both user!.orgId and organization must 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.current to !(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.workspace to !role?.workspace maintains 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.externalId to !(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 the DEFAULT_OPTIONS while 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?.id maintains the same logical behavior while improving readability. The optional chaining handles all the same edge cases (null api, missing keyAuth, or missing id) 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 && !externalId to !(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_KEY to !(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 && !namespaceName to !(namespaceId || namespaceName) is logically equivalent and follows De Morgan's law. Both expressions throw a BAD_REQUEST error 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 with Date.now().

Replacing new Date().getTime() with Date.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.namespaceName to !(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 && !namespaceName to !(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 of new 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 noDangerouslySetInnerHtml warning 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?.length to !(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_ID to !(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 isFreeTier variable 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 || !currentOrgMembership to !(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 where option.value is undefined (as seen in the "Custom" option from DEFAULT_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 || !name to !(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.session to !(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 || !role to !(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 || !email to !(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 || !onLoadMore to !(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 && !isFetchingNextPage to !(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_HOST to !(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.role to !(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 && !isHovered to !(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 && !allDisabled to !(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?.length to !(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.role to !(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.code to !(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 || !param2 to !(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 && !open to !(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 || !isBrowser to !(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?.length to !(active && payload?.length) correctly applies De Morgan's law and improves readability by directly expressing that both active and payload?.length must 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 || !sigHeader to !(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 && !open to !(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 && !selectedIdentityId to !(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.start to !(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.endTimestamp to !(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?.length to !(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_URI to !(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.endTimestamp to !(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 === 0 check. 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 disabling noChildrenProp is intentional for your components that rely on passing children explicitly.


24-24: Disallow dangerouslySetInnerHTML for security
Turning on noDangerouslySetInnerHtml as an error guards against XSS vulnerabilities. Ensure that any existing dangerouslySetInnerHTML usages have been migrated to safer rendering approaches.


34-36: Enforce strict type and comparison checks
Elevating noDoubleEquals, useIsArray, and noFallthroughSwitchClause to 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 keeping noForEach disabled is intentional since banning forEach can enforce functional patterns.

Comment on lines +15 to +16
const [key, _value] = arg.split("=");
passedOptions[key.replace("--", "")] = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 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=api would set passedOptions.service = "api"
  • After: --service=api sets passedOptions.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 js

Length 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)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Suggested change
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.

Copy link
Contributor Author

aah shit I actually fixed some of these probably forgot to push

Copy link
Contributor Author

i'll do it in 5min

@chronark chronark deleted the linter-logical-fix branch September 29, 2025 15:16
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