Skip to content

Walk Track: Extend test_mandatory_field refactor to remaining knife commands #140

@nikhil2611

Description

@nikhil2611

Context

Walk Ex3 replaced duplicate inline nil-guard blocks in node_show.rb, client_show.rb, and role_show.rb with calls to the existing test_mandatory_field helper. At least 15 other knife commands still use the inline pattern.

Code Paths

  • lib/chef/knife/node_edit.rb:43
  • lib/chef/knife/role_create.rb:42
  • lib/chef/knife/client_edit.rb:36
  • lib/chef/knife/cookbook_download.rb:60
  • lib/chef/knife/environment_show.rb:38
  • lib/chef/knife/ssh.rb:612
  • lib/chef/knife/tag_list.rb:38
  • lib/chef/knife/role_delete.rb:37
  • lib/chef/knife/user_reregister.rb:41
  • (and ~6 more — grep -rn 'ui.fatal.*must specify' lib/)

Acceptance Criteria

  • All inline if @name_args[0].nil? ... ui.fatal ... exit 1 blocks in lib/chef/knife/*.rb replaced with test_mandatory_field
  • No change in behavior — existing specs remain green
  • Net line reduction ≥ 30 lines

Dependencies

None — safe to start immediately.

Size

Medium — one PR, no logic changes, pure refactor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions