refactor: rename codemod_permissions functions for discoverability#22658
refactor: rename codemod_permissions functions for discoverability#22658
Conversation
…emod - getPermissionsReadCodemod → getExpandPermissionsShorthandCodemod - getWritePermissionsCodemod → getMigrateWritePermissionsToReadCodemod Updates all call sites in fix_codemods.go and codemod_permissions_test.go. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/gh-aw/sessions/7dda4363-4312-4289-9955-49f389e1aaec
There was a problem hiding this comment.
Pull request overview
Refactors two codemod factory function names to better reflect their behavior and improve search/discoverability across the CLI codemod registry and tests.
Changes:
- Renamed the “permissions shorthand expansion” codemod constructor to
getExpandPermissionsShorthandCodemod. - Renamed the “write → read permissions downgrade” codemod constructor to
getMigrateWritePermissionsToReadCodemod. - Updated codemod registry and test call sites to use the new function names.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/cli/fix_codemods.go | Updates codemod registry call sites to the renamed constructors. |
| pkg/cli/codemod_permissions_write.go | Renames the write-permissions codemod constructor function. |
| pkg/cli/codemod_permissions_read.go | Renames the permissions shorthand expansion codemod constructor function. |
| pkg/cli/codemod_permissions_test.go | Updates test call sites to use the renamed constructors. |
Comments suppressed due to low confidence (1)
pkg/cli/codemod_permissions_test.go:187
- Similarly, these write-permissions tests still use the old naming (
TestGetWritePermissionsCodemod/TestWritePermissionsCodemod_*) while callinggetMigrateWritePermissionsToReadCodemod. Consider renaming the test functions to match the new codemod name for consistency and searchability.
func TestGetWritePermissionsCodemod(t *testing.T) {
codemod := getMigrateWritePermissionsToReadCodemod()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| getWritePermissionsCodemod(), | ||
| getPermissionsReadCodemod(), // Fix permissions: read -> permissions: read-all | ||
| getMigrateWritePermissionsToReadCodemod(), | ||
| getExpandPermissionsShorthandCodemod(), // Fix permissions: read -> permissions: read-all |
There was a problem hiding this comment.
The inline comment still describes only the read shorthand, but this codemod also expands permissions: write → permissions: write-all (per its description). Update the comment to reflect both cases (or describe it generically as expanding invalid permissions shorthands) to avoid misleading future readers/searches.
| getExpandPermissionsShorthandCodemod(), // Fix permissions: read -> permissions: read-all | |
| getExpandPermissionsShorthandCodemod(), // Expand invalid permissions shorthands (e.g., read -> read-all, write -> write-all) |
| func TestGetPermissionsReadCodemod(t *testing.T) { | ||
| codemod := getPermissionsReadCodemod() | ||
| codemod := getExpandPermissionsShorthandCodemod() |
There was a problem hiding this comment.
These test names still refer to the old codemod name (e.g., TestGetPermissionsReadCodemod / TestPermissionsReadCodemod_*) even though they now exercise getExpandPermissionsShorthandCodemod. Renaming the test functions to match the new codemod name will keep grep/search-based discoverability consistent with the refactor goal.
This issue also appears on line 186 of the same file.
Two codemod functions had names that obscured their actual behavior, making them hard for agents (and humans) to find when searching for relevant logic.
Renames
getPermissionsReadCodemod→getExpandPermissionsShorthandCodemodHandled both
read→read-allandwrite→write-allexpansion; old name implied read-only scope.getWritePermissionsCodemod→getMigrateWritePermissionsToReadCodemodDowngrades write permissions to read; old name described the subject, not the action.
Affected files
codemod_permissions_read.go/codemod_permissions_write.go— definitionsfix_codemods.go— call sitescodemod_permissions_test.go— 18 call sites updated⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.