Skip to content

📜 Scribe: Replace magic numbers in boolean sorting - #445

Open
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
scribe-boolean-sort-14208946221117725518
Open

📜 Scribe: Replace magic numbers in boolean sorting#445
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
scribe-boolean-sort-14208946221117725518

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

💡 What: Replaced a ternary operator ? 0 : 1 in AppItemGroup.cs with OrderByDescending.
🎯 Why: Boolean values evaluate to false < true, so OrderByDescending naturally puts true values first, eliminating the need for magic numbers 0 and 1.
📖 Readability: Extracted magic numbers to boolean OrderByDescending sort.


PR created automatically by Jules for task 14208946221117725518 started by @mikekthx

@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@google-labs-jules
google-labs-jules Bot requested a review from mikekthx as a code owner July 28, 2026 11:23
@github-actions github-actions Bot added the core-logic Changes to primary application logic, backend services, or models. label Jul 28, 2026
@mikekthx

Copy link
Copy Markdown
Owner

Code Review

What this PR does: Replaces .OrderBy(a => a.Name.StartsWith(filterText, ...) ? 0 : 1) with .OrderByDescending(a => a.Name.StartsWith(filterText, ...)) in AppItemGroup.GetFilteredItems.

Overall assessment: Correct, minimal refactor. No blocking issues.


Correctness

The two forms are semantically equivalent. In .NET, bool comparison follows false < true, so OrderByDescending(bool) puts true values first — identical to OrderBy(x => x ? 0 : 1). No behavioral change.

Test coverage

AppItemGroupTests.ApplyFilter_PrefixMatchRanksBeforeSubstringMatch (line 131) directly exercises this code path and will catch any regression. No new tests are needed for a pure refactor.

Readability

Eliminating the magic numbers 0 and 1 is a net improvement. OrderByDescending on a boolean is idiomatic LINQ and clearly communicates intent.

One minor note (pre-existing, not introduced here)

The test at line 131–139 verifies that Studio (prefix match) lands at index 0 and that all 3 items are present, but it does not assert the relative order of VisualStudio vs AnotherStudio (both substring-only matches). The secondary ordering within the "contains but does not start with" bucket is not pinned. This is a pre-existing gap and the existing assertion is sufficient to protect the feature intent — flagging only for awareness.


No blocking issues. This is a clean, correct improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-logic Changes to primary application logic, backend services, or models.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant