Skip to content

refactor: rename codemod_permissions functions for discoverability#22658

Merged
pelikhan merged 2 commits intomainfrom
copilot/rename-codemod-permissions-functions
Mar 24, 2026
Merged

refactor: rename codemod_permissions functions for discoverability#22658
pelikhan merged 2 commits intomainfrom
copilot/rename-codemod-permissions-functions

Conversation

Copy link
Contributor

Copilot AI commented Mar 24, 2026

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

  • getPermissionsReadCodemodgetExpandPermissionsShorthandCodemod
    Handled both readread-all and writewrite-all expansion; old name implied read-only scope.

  • getWritePermissionsCodemodgetMigrateWritePermissionsToReadCodemod
    Downgrades write permissions to read; old name described the subject, not the action.

Affected files

  • codemod_permissions_read.go / codemod_permissions_write.go — definitions
  • fix_codemods.go — call sites
  • codemod_permissions_test.go — 18 call sites updated

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

…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
Copilot AI changed the title [WIP] Rename functions in codemod_permissions_read and codemod_permissions_write refactor: rename codemod_permissions functions for discoverability Mar 24, 2026
Copilot AI requested a review from pelikhan March 24, 2026 11:34
@pelikhan pelikhan marked this pull request as ready for review March 24, 2026 11:34
Copilot AI review requested due to automatic review settings March 24, 2026 11:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 calling getMigrateWritePermissionsToReadCodemod. 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
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The inline comment still describes only the read shorthand, but this codemod also expands permissions: writepermissions: 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.

Suggested change
getExpandPermissionsShorthandCodemod(), // Fix permissions: read -> permissions: read-all
getExpandPermissionsShorthandCodemod(), // Expand invalid permissions shorthands (e.g., read -> read-all, write -> write-all)

Copilot uses AI. Check for mistakes.
Comment on lines 12 to +13
func TestGetPermissionsReadCodemod(t *testing.T) {
codemod := getPermissionsReadCodemod()
codemod := getExpandPermissionsShorthandCodemod()
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit edc30d6 into main Mar 24, 2026
62 checks passed
@pelikhan pelikhan deleted the copilot/rename-codemod-permissions-functions branch March 24, 2026 11:48
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.

[function-namer] Go function rename plan: codemod_permissions_read.go, codemod_permissions_write.go

3 participants