Skip to content

refactor: create ProviderBase class to eliminate code duplication#186

Open
rygel wants to merge 26 commits intodevelopfrom
feature/ci-cd-final-touches
Open

refactor: create ProviderBase class to eliminate code duplication#186
rygel wants to merge 26 commits intodevelopfrom
feature/ci-cd-final-touches

Conversation

@rygel
Copy link
Owner

@rygel rygel commented Mar 3, 2026

Summary

Create abstract class and refactor as the first example.

Changes

Added

  • ProviderBase abstract class in
    • Implements interface
    • Provides method with flexible parameters
    • Provides for HTTP status codes
    • Provides for error handling

Refactored

  • SyntheticProvider now inherits from
    • Removed duplicate method (~20 lines)
    • Updated to use base class implementation
    • Added keyword to

Impact

  • Code reduction: ~20 lines eliminated from SyntheticProvider
  • Projected savings: ~300 lines when applied to all 18 providers
  • Benefits:
    • Consistent error handling across providers
    • Centralized unavailable usage creation logic
    • Easier maintenance and testing

Testing

  • Build passes
  • Tests pass
  • SyntheticProvider functionality unchanged

Follow-up Work

Remaining providers to refactor (17 total):

  • CodexProvider, OpenAIProvider, GitHubCopilotProvider, etc.

Each can be refactored in follow-up PRs using the same pattern.

Alexander Brandt and others added 4 commits March 3, 2026 23:03
Continuing the 'Straight Line Architecture Refinement' work that was
partially merged via CI/CD fixes. This branch focuses on:

- Consolidating provider naming logic
- Flattening directory structure
- Removing redundant resolvers and helpers

Initial investigation phase to identify simplification opportunities.
- Removed ProviderDisplayNameResolver (unused, only tested)
- Removed ProviderDisplayNameResolverTests
- Removed ProviderPlanClassifier (unused, only tested)
- Removed ProviderPlanClassifierTests

These classes were not used in production code, only had test coverage.
Their functionality is handled by:
- ProviderMetadataCatalog.GetDisplayName() for display name resolution
- ProviderDefinition.PlanType for plan classification

Part of 'Straight Line Architecture Refinement' work.
Completed so far:

1. Removed unused utility classes:
   - ProviderDisplayNameResolver (only tested, never used in production)
   - ProviderDisplayNameResolverTests
   - ProviderPlanClassifier (only tested, never used in production)
   - ProviderPlanClassifierTests

2. Verified current architecture:
   - IGitHubAuthService split is complete (GitHubAuthService implements all three interfaces)
   - ProviderMetadataCatalog properly delegates to ProviderDefinition.ResolveDisplayName()
   - Directory structures are flat and well-organized

3. Identified next opportunities:
   - Review ProviderDefinition.ResolveDisplayName() logic
   - Check for other unused utility classes
   - Consider consolidating similar helper patterns

This branch continues the 'Straight Line Architecture Refinement' work
that was partially merged via CI/CD fixes in beta 7.
Create ProviderBase abstract class in AIUsageTracker.Core:
- Implements IProviderService interface
- Provides CreateUnavailableUsage method with flexible parameters
- Provides CreateUnavailableUsageFromStatus for HTTP status codes
- Provides CreateUnavailableUsageFromException for error handling
- Eliminates ~15 lines of duplicate code per provider

Refactor SyntheticProvider to use ProviderBase:
- Inherit from ProviderBase instead of implementing IProviderService
- Remove duplicate CreateUnavailableUsage method (~20 lines)
- Update method calls to use base class signature
- Add 'override' keyword to GetUsageAsync
- Update using statements to include AIUsageTracker.Core.Providers

Benefits:
- ~300 lines of duplication will be eliminated across all 18 providers
- Consistent error handling across providers
- Centralized unavailable usage creation logic
- Easier maintenance and testing
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Build Performance Report

⏱️ Build Time: 12 minutes

📊 Comparison with main branch:

  • Baseline (avg): 10 minutes
  • Current: 12 minutes
  • Change: 📈 20%

✅ Within acceptable range


This is an automated performance check

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

⚠️ Large PR Detected

This PR contains 2007 lines changed across 34 files.

Details:

  • 📁 Files changed: 34
  • ➕ Insertions: 512
  • ➖ Deletions: 1495
  • 📊 Total: 2007 lines

Recommendation:
Consider splitting this PR into smaller, focused changes to make review easier and faster. PRs under 500 lines are ideal for thorough code review.


This is an automated message. Feel free to ignore if this PR is intentionally large.

- Inherit from ProviderBase instead of implementing IProviderService
- Remove duplicate CreateUnavailableUsage method (~15 lines)
- Update GetUsageAsync to use override keyword
- Update using statements

Code reduction: ~15 lines
- Inherit from ProviderBase instead of implementing IProviderService
- Remove duplicate CreateUnavailableUsage method (~12 lines)
- Update GetUsageAsync to use override keyword
- Update using statements

Code reduction: ~12 lines
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

⚠️ Large PR Detected

This PR contains 2054 lines changed across 36 files.

Details:

  • 📁 Files changed: 36
  • ➕ Insertions: 522
  • ➖ Deletions: 1532
  • 📊 Total: 2054 lines

Recommendation:
Consider splitting this PR into smaller, focused changes to make review easier and faster. PRs under 500 lines are ideal for thorough code review.


This is an automated message. Feel free to ignore if this PR is intentionally large.

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Build Performance Report

⏱️ Build Time: 12 minutes

📊 Comparison with main branch:

  • Baseline (avg): 10 minutes
  • Current: 12 minutes
  • Change: 📈 20%

✅ Within acceptable range


This is an automated performance check

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

⚠️ Large PR Detected

This PR contains 2242 lines changed across 47 files.

Details:

  • 📁 Files changed: 47
  • ➕ Insertions: 599
  • ➖ Deletions: 1643
  • 📊 Total: 2242 lines

Recommendation:
Consider splitting this PR into smaller, focused changes to make review easier and faster. PRs under 500 lines are ideal for thorough code review.


This is an automated message. Feel free to ignore if this PR is intentionally large.

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Build Performance Report

⏱️ Build Time: 12 minutes

📊 Comparison with main branch:

  • Baseline (avg): 10 minutes
  • Current: 12 minutes
  • Change: 📈 20%

✅ Within acceptable range


This is an automated performance check

Document the refactoring of all 18 providers to use ProviderBase:
- Eliminates ~174 lines of duplicate code
- Ensures consistent error handling
- All providers now inherit from base class
- Centralized unavailable usage creation logic
Merge CHANGELOG.md changes from develop branch:
- Keep all CI/CD improvements from develop
- Add ProviderBase refactoring section
- Organize into proper sections (Security, Fixed, Changed, Added)
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

⚠️ Large PR Detected

This PR contains 1281 lines changed across 20 files.

Details:

  • 📁 Files changed: 20
  • ➕ Insertions: 212
  • ➖ Deletions: 1069
  • 📊 Total: 1281 lines

Recommendation:
Consider splitting this PR into smaller, focused changes to make review easier and faster. PRs under 500 lines are ideal for thorough code review.


This is an automated message. Feel free to ignore if this PR is intentionally large.

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Build Performance Report

⏱️ Build Time: 12 minutes

📊 Comparison with main branch:

  • Baseline (avg): 10 minutes
  • Current: 12 minutes
  • Change: 📈 20%

✅ Within acceptable range


This is an automated performance check

Add back using AIUsageTracker.Core.Interfaces for IGitHubAuthService
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

⚠️ Large PR Detected

This PR contains 1280 lines changed across 20 files.

Details:

  • 📁 Files changed: 20
  • ➕ Insertions: 212
  • ➖ Deletions: 1068
  • 📊 Total: 1280 lines

Recommendation:
Consider splitting this PR into smaller, focused changes to make review easier and faster. PRs under 500 lines are ideal for thorough code review.


This is an automated message. Feel free to ignore if this PR is intentionally large.

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Build Performance Report

⏱️ Build Time: 12 minutes

📊 Comparison with main branch:

  • Baseline (avg): 10 minutes
  • Current: 12 minutes
  • Change: 📈 20%

✅ Within acceptable range


This is an automated performance check

Add scripts/pre-commit-check.sh to validate code before committing:
- Builds solution
- Runs tests
- Checks formatting

Usage: ./scripts/pre-commit-check.sh
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Build Performance Report

⏱️ Build Time: 12 minutes

📊 Comparison with main branch:

  • Baseline (avg): 10 minutes
  • Current: 12 minutes
  • Change: 📈 20%

✅ Within acceptable range


This is an automated performance check

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

⚠️ Large PR Detected

This PR contains 1326 lines changed across 21 files.

Details:

  • 📁 Files changed: 21
  • ➕ Insertions: 258
  • ➖ Deletions: 1068
  • 📊 Total: 1326 lines

Recommendation:
Consider splitting this PR into smaller, focused changes to make review easier and faster. PRs under 500 lines are ideal for thorough code review.


This is an automated message. Feel free to ignore if this PR is intentionally large.

Add comprehensive pre-commit validation guidelines:
- Emphasize running validation BEFORE committing
- Document the pre-commit-check.sh script
- Provide manual validation commands as fallback
- List consequences of committing broken code
- Use CRITICAL warning formatting
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Build Performance Report

⏱️ Build Time: 12 minutes

📊 Comparison with main branch:

  • Baseline (avg): 10 minutes
  • Current: 12 minutes
  • Change: 📈 20%

✅ Within acceptable range


This is an automated performance check

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

⚠️ Large PR Detected

This PR contains 1363 lines changed across 22 files.

Details:

  • 📁 Files changed: 22
  • ➕ Insertions: 295
  • ➖ Deletions: 1068
  • 📊 Total: 1363 lines

Recommendation:
Consider splitting this PR into smaller, focused changes to make review easier and faster. PRs under 500 lines are ideal for thorough code review.


This is an automated message. Feel free to ignore if this PR is intentionally large.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants