skyrim-community-shaders icon indicating copy to clipboard operation
skyrim-community-shaders copied to clipboard

Centralize feature category names to avoid hard-coded string literals

Open coderabbitai[bot] opened this issue 4 months ago • 0 comments
trafficstars

Problem

Currently, feature categories are defined as hard-coded string literals in each feature's GetCategory() method. This approach has several drawbacks:

  • Risk of typos and inconsistencies
  • Difficult to maintain and update category names
  • No central location to manage available categories

Current Implementation

Features like ExtendedTranslucency define categories inline:

virtual std::string_view GetCategory() const override { return "Lighting"; }

Proposed Solution

  1. Create a centralized location for category definitions, either:

    • An enum class for category types
    • Static constexpr string_view constants
    • A dedicated CategoryNames namespace/class
  2. Update all features to use the centralized category definitions instead of string literals

  3. Benefits:

    • Eliminates typo risks
    • Centralizes category management
    • Makes it easier to add/rename categories
    • Improves code maintainability

Implementation Ideas

Option 1 - Enum approach:

enum class FeatureCategory {
    Lighting,
    PostProcessing,
    Rendering,
    // ... other categories
};

Option 2 - Constants approach:

namespace CategoryNames {
    static constexpr std::string_view Lighting = "Lighting";
    static constexpr std::string_view PostProcessing = "PostProcessing";
    // ... other categories
}

Scope

Based on the codebase analysis, this change would affect multiple feature implementations that currently use hard-coded category strings.

References

  • Original suggestion: https://github.com/doodlum/skyrim-community-shaders/pull/1264#discussion_r2206719306
  • PR: https://github.com/doodlum/skyrim-community-shaders/pull/1264

coderabbitai[bot] avatar Jul 15 '25 08:07 coderabbitai[bot]