Skip to content

Fix core: harden config and fullwidth paths#300

Open
PeterDaveHello wants to merge 1 commit intohuacnlee:mainfrom
PeterDaveHello:fix/core-stability
Open

Fix core: harden config and fullwidth paths#300
PeterDaveHello wants to merge 1 commit intohuacnlee:mainfrom
PeterDaveHello:fix/core-stability

Conversation

@PeterDaveHello
Copy link
Contributor

Improve error context on config lock failures.
Handle empty filenames safely in get_file_extension. Inline fullwidth mapping to keep behavior explicit and predictable. No behavior change expected in normal cases; adds clearer diagnostics and edge-case guards.

GitHub Copilot summary:

This pull request focuses on improving code safety, clarity, and maintainability by refining error handling, removing unnecessary data structures, and making code more robust against edge cases. The most significant changes are grouped below:

Error Handling Improvements

  • Replaced all unwrap() calls on lock acquisition for CURRENT_CONFIG with expect() calls that provide explicit error messages, making failures easier to debug. (autocorrect/src/config/mod.rs) [1] [2]

Code Robustness

  • Updated the get_file_extension function to use unwrap_or instead of unwrap when splitting filenames and extracting extensions, which prevents panics on unexpected input. (autocorrect/src/code/types.rs)

Code Simplification and Performance

  • Removed the FULLWIDTH_MAPS HashMap and replaced it with a direct match statement in fullwidth_replace_part, reducing overhead and improving code clarity. (autocorrect/src/rule/fullwidth.rs) [1] [2]

Minor Refactoring

  • Changed the merge method in Config to iterate over references and clone keys/values as needed, improving efficiency and code readability. (autocorrect/src/config/mod.rs)

Improve error context on config lock failures.
Handle empty filenames safely in get_file_extension.
Inline fullwidth mapping to keep behavior explicit and predictable.
No behavior change expected in normal cases; adds clearer diagnostics
and edge-case guards.
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