Skip to content

fix(editor): drop the unreachable uppercase .R extension key - #11322

Merged
Jinwoo-H merged 1 commit into
stablyai:mainfrom
taehwanis:fix/unreachable-uppercase-r-extension
Jul 31, 2026
Merged

Jinwoo-H merged 1 commit into
stablyai:mainfrom
taehwanis:fix/unreachable-uppercase-r-extension

Conversation

@taehwanis

Copy link
Copy Markdown
Contributor

Summary

EXT_TO_LANGUAGE has both '.r' and '.R' mapped to r, but the lookup key is lowercased first:

const ext = extname(filename).toLowerCase()
return EXT_TO_LANGUAGE[ext] ?? 'plaintext'

No input can ever reach the '.R' entry — '.r' already covers model.R, MODEL.R and every other casing. Removing it changes no behaviour.

It is worth removing rather than leaving alone: as written, the entry reads like uppercase extensions need their own row, which invites the same addition for .SVG, .JSON and so on. '.R' is currently the only key in the table with an uppercase character, so this keeps that property true.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

The two unchecked boxes are explained under Notes.

AI Review Report

Reviewed with an AI coding agent. The check that mattered was whether the entry is genuinely unreachable rather than merely redundant: detectLanguage lowercases the extension before the lookup (language-detect.ts:123), and FILENAME_TO_LANGUAGE — which is consulted first and is not lowercased — contains no key ending in .R, so there is no path that bypasses the normalization. A scan of the table confirmed '.R' is the only key containing an uppercase character, so no sibling entry has the same problem.

The added test asserts both model.r and MODEL.R resolve to r, so if the lowercasing in detectLanguage were ever removed, this deletion would surface as a failing test rather than as silently broken highlighting for uppercase .R files.

Cross-platform compatibility (macOS, Linux, Windows) was explicitly checked. This is the removal of one entry from a lookup table; no platform branch, path handling, shortcut, label, shell behavior or Electron-specific code is involved. Case-insensitive filesystems are the reason the lowercasing exists in the first place, and that behaviour is unchanged and now covered by a test.

Security Audit

No risk surface. One line is removed from a static lookup table and a test is added. No input handling, command execution, path resolution, auth, secrets, IPC or dependency changes.

Notes

  • pnpm lint: oxlint and the code-quality audits pass. The chain stops later at verify:skill-bundle-manifest, which reports stale generated artifacts under resources/skills/ — a pre-existing state unrelated to this change, and those files are not part of this diff.
  • pnpm test: the full suite on a Windows machine fails a set of pre-existing tests that require a POSIX shell (spawn /bin/sh ENOENT); the count is unchanged by this PR. language-detect.test.ts passes 11/11.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR removes the unreachable '.R': 'r' entry from EXT_TO_LANGUAGE in language-detect.ts and adds a regression test to confirm case-insensitive R file detection. The entry was dead code: detectLanguage lowercases the extension before the map lookup (extname(filename).toLowerCase()), so '.R' could never be reached — '.r' already handles every casing.

  • Dead entry removed: '.R': 'r' is dropped from EXT_TO_LANGUAGE; no behaviour changes since the lookup key is always lowercased first.
  • Test added: language-detect.test.ts gains a case covering both model.r and MODEL.R, ensuring any future removal of the lowercase normalization would surface as a test failure rather than silent broken highlighting.

Confidence Score: 5/5

Safe to merge — removes one dead map entry that was provably unreachable and adds a test to guard the normalization behaviour.

The deletion is of a single lookup-table entry that detectLanguage could never reach due to the toLowerCase() call that precedes every map access. The added test directly exercises both lowercase and uppercase R file paths, so any future regression in the normalization step would be caught immediately. The change has no runtime-visible effect and no coupling to any other code path.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/renderer/src/lib/language-detect.ts Removes the unreachable '.R': 'r' map entry; detectLanguage lowercases the extension before lookup so this key could never be matched.
src/renderer/src/lib/language-detect.test.ts Adds a test asserting both model.r and MODEL.R resolve to 'r', providing a regression guard for the lowercasing behaviour in detectLanguage.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["detectLanguage(filePath)"] --> B["Split path, extract filename"]
    B --> C{"FILENAME_TO_LANGUAGE\nhas exact filename?"}
    C -- Yes --> D["Return language"]
    C -- No --> E["extname(filename).toLowerCase()"]
    E --> F{"EXT_TO_LANGUAGE\nhas lowercased ext?"}
    F -- Yes --> G["Return language"]
    F -- No --> H["Return 'plaintext'"]

    subgraph "EXT_TO_LANGUAGE (after PR)"
        I["'.r' → 'r'"]
        J["❌ '.R' removed (was unreachable)"]
    end

    E -->|"'.R' → '.r' after toLowerCase"| F
    style J fill:#f88,stroke:#c00,color:#000
    style I fill:#8f8,stroke:#090,color:#000
Loading

Reviews (3): Last reviewed commit: "fix(editor): drop the unreachable upperc..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ff9a3a5a-008f-4b62-a42e-13473ecac638

📥 Commits

Reviewing files that changed from the base of the PR and between e549dd3 and 6192b53fa91af6ccd43446047bf96561bf31b97a.

📒 Files selected for processing (2)
  • src/renderer/src/lib/language-detect.test.ts
  • src/renderer/src/lib/language-detect.ts
💤 Files with no reviewable changes (1)
  • src/renderer/src/lib/language-detect.ts

📝 Walkthrough

Walkthrough

Updated language detection to rely on lowercasing before mapping the .r extension, removing the explicit .R entry. Added tests confirming both lowercase and uppercase R filenames resolve to the r language identifier.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: removing the unreachable uppercase .R lookup key.
Description check ✅ Passed The description follows the required template and includes summary, screenshots, testing, AI review, security audit, and notes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

Comment @coderabbitai help to get the list of available commands.

@Jinwoo-H
Jinwoo-H force-pushed the fix/unreachable-uppercase-r-extension branch from 6192b53 to 4c8b7a0 Compare July 31, 2026 00:00
detectLanguage lowercases the extension before the table lookup, so the
'.R' entry can never be reached — '.r' already covers every casing. It is
also the only key in the table with an uppercase character, and leaving it
suggests uppercase extensions need their own rows.
@Jinwoo-H
Jinwoo-H force-pushed the fix/unreachable-uppercase-r-extension branch from 4c8b7a0 to 9bcf121 Compare July 31, 2026 00:05
@Jinwoo-H
Jinwoo-H merged commit 7ad7f6a into stablyai:main Jul 31, 2026
41 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…i#11322)

detectLanguage lowercases the extension before the table lookup, so the
'.R' entry can never be reached — '.r' already covers every casing. It is
also the only key in the table with an uppercase character, and leaving it
suggests uppercase extensions need their own rows.
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.

3 participants