Skip to content

refactor: implement self-registration pattern for language support#4

Merged
soumyaray merged 1 commit intomainfrom
refactor-language-support
Nov 30, 2025
Merged

refactor: implement self-registration pattern for language support#4
soumyaray merged 1 commit intomainfrom
refactor-language-support

Conversation

@soumyaray
Copy link
Contributor

Refactor language filtering architecture to use self-registration pattern, eliminating hardcoded constants and improving maintainability.

Domain layer changes:

  • CodeLanguage: Add self-registration system with @registry

    • Each language class declares extension (e.g., extension 'rb')
    • Auto-registers via ClassMethods.extension hook
    • Remove hardcoded LANGUAGE_EXTENSION hash
    • Add wanted_extensions public interface
  • Streamline wanted?/unwanted? predicates

    • Single source of truth in ClassMethods
    • Instance methods delegate to class methods
    • Remove WANTED_LANGUAGES constant from FileContributions
  • FilePath improvements

    • Add wanted? method for domain-level file filtering
    • Fix extension method with safe navigation for files without extensions
    • Add guard in language method to return Unknown for missing extensions

Infrastructure layer changes:

  • LocalGitRepo: Remove utility function code smell
    • Remove hardcoded TEXT_FILES constant
    • Replace wanted_code_file? with Value::FilePath#wanted?
    • Infrastructure now queries domain for language support

Benefits:

  • Single source of truth for language definitions
  • Self-documenting: languages declare their own extensions
  • Infrastructure automatically stays in sync with domain
  • Eliminates utility function smell (reek clean)
  • Domain logic properly encapsulated in domain layer

Tests: All passing (35 runs, 132 assertions, 0 failures)
Code quality: RuboCop and Reek clean

🤖 Generated with Claude Code

Refactor language filtering architecture to use self-registration pattern,
eliminating hardcoded constants and improving maintainability.

Domain layer changes:
* CodeLanguage: Add self-registration system with @registry
  - Each language class declares extension (e.g., extension 'rb')
  - Auto-registers via ClassMethods.extension hook
  - Remove hardcoded LANGUAGE_EXTENSION hash
  - Add wanted_extensions public interface

* Streamline wanted?/unwanted? predicates
  - Single source of truth in ClassMethods
  - Instance methods delegate to class methods
  - Remove WANTED_LANGUAGES constant from FileContributions

* FilePath improvements
  - Add wanted? method for domain-level file filtering
  - Fix extension method with safe navigation for files without extensions
  - Add guard in language method to return Unknown for missing extensions

Infrastructure layer changes:
* LocalGitRepo: Remove utility function code smell
  - Remove hardcoded TEXT_FILES constant
  - Replace wanted_code_file? with Value::FilePath#wanted?
  - Infrastructure now queries domain for language support

Benefits:
- Single source of truth for language definitions
- Self-documenting: languages declare their own extensions
- Infrastructure automatically stays in sync with domain
- Eliminates utility function smell (reek clean)
- Domain logic properly encapsulated in domain layer

Tests: All passing (35 runs, 132 assertions, 0 failures)
Code quality: RuboCop and Reek clean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@soumyaray soumyaray force-pushed the refactor-language-support branch from 23b0159 to 7110f7b Compare November 30, 2025 03:38
@soumyaray soumyaray merged commit 53eee8f into main Nov 30, 2025
2 checks passed
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.

1 participant

Comments