Skip to content

Apply frozen string literals and constant extraction to high-frequency knife commands #120

@nikhil2611

Description

@nikhil2611

Epic

Part of Crawl Track backlog epic.

Background

Ex6 (Performance) added PARTIAL_SEARCH_FIELDS as a frozen constant in knife status. The same pattern (frozen string literals, extracted field arrays) should be applied to the highest-frequency commands to reduce GC pressure in large Chef environments.

Code Paths

  • lib/chef/knife/status.rb:37PARTIAL_SEARCH_FIELDS reference implementation
  • lib/chef/knife/search.rb — repeated string construction in #run
  • lib/chef/knife/node_list.rb — inline string arrays per invocation
  • lib/chef/knife/cookbook_list.rb — similar pattern

Acceptance Criteria

  • # frozen_string_literal: true magic comment added to at least 3 commands
  • Repeated literal arrays/hashes extracted to named frozen constants
  • bundle exec rake spec passes with 0 failures after changes
  • No behavior change — pure refactor

Dependencies

Estimated Size

Small–Medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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