refactor: Remove redundant code and consolidate JsonSerializerOptions

- Remove unused GetRepoLanguagesAsync method from GitHubClient
- Remove unused IsFakeAccreditor and FakeAccreditors from DiplomaMills
- Remove unused CompanyVerificationFlagPenalty constant from ProcessCVCheckJob
- Remove unused SkillVerification properties (TotalLinesOfCode, FirstUsed, LastUsed)
- Remove unused CompanyMatchRequest record from SemanticMatchResult
- Add JsonDefaults.ApiClient and consolidate duplicate JsonSerializerOptions across API clients
- Remove ApiTester tool containing hardcoded API credentials (security fix)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-25 04:16:51 +00:00
parent f775164212
commit a132efd907
10 changed files with 24 additions and 226 deletions

View File

@@ -1,8 +1,8 @@
using System.Net.Http.Json;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using RealCV.Application.Helpers;
namespace RealCV.Infrastructure.Clients;
@@ -44,7 +44,7 @@ public sealed class FcaRegisterClient
return null;
}
return await response.Content.ReadFromJsonAsync<FcaIndividualResponse>(JsonOptions);
return await response.Content.ReadFromJsonAsync<FcaIndividualResponse>(JsonDefaults.ApiClient);
}
catch (Exception ex)
{
@@ -70,7 +70,7 @@ public sealed class FcaRegisterClient
return null;
}
var wrapper = await response.Content.ReadFromJsonAsync<FcaIndividualDetailsWrapper>(JsonOptions);
var wrapper = await response.Content.ReadFromJsonAsync<FcaIndividualDetailsWrapper>(JsonDefaults.ApiClient);
return wrapper?.Data?.FirstOrDefault();
}
catch (Exception ex)
@@ -94,7 +94,7 @@ public sealed class FcaRegisterClient
return null;
}
return await response.Content.ReadFromJsonAsync<FcaFirmResponse>(JsonOptions);
return await response.Content.ReadFromJsonAsync<FcaFirmResponse>(JsonDefaults.ApiClient);
}
catch (Exception ex)
{
@@ -102,12 +102,6 @@ public sealed class FcaRegisterClient
return null;
}
}
private static readonly JsonSerializerOptions JsonOptions = new()
{
PropertyNameCaseInsensitive = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
}
public class FcaOptions

View File

@@ -1,9 +1,9 @@
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using RealCV.Application.Helpers;
namespace RealCV.Infrastructure.Clients;
@@ -49,7 +49,7 @@ public sealed class GitHubApiClient
return null;
}
return await response.Content.ReadFromJsonAsync<GitHubUser>(JsonOptions);
return await response.Content.ReadFromJsonAsync<GitHubUser>(JsonDefaults.ApiClient);
}
catch (Exception ex)
{
@@ -76,7 +76,7 @@ public sealed class GitHubApiClient
break;
}
var pageRepos = await response.Content.ReadFromJsonAsync<List<GitHubRepo>>(JsonOptions);
var pageRepos = await response.Content.ReadFromJsonAsync<List<GitHubRepo>>(JsonDefaults.ApiClient);
if (pageRepos == null || pageRepos.Count == 0)
{
@@ -107,28 +107,6 @@ public sealed class GitHubApiClient
return repos;
}
public async Task<Dictionary<string, int>?> GetRepoLanguagesAsync(string owner, string repo)
{
try
{
var url = $"repos/{Uri.EscapeDataString(owner)}/{Uri.EscapeDataString(repo)}/languages";
var response = await _httpClient.GetAsync(url);
if (!response.IsSuccessStatusCode)
{
return null;
}
return await response.Content.ReadFromJsonAsync<Dictionary<string, int>>(JsonOptions);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error getting languages for repo: {Owner}/{Repo}", owner, repo);
return null;
}
}
public async Task<GitHubUserSearchResponse?> SearchUsersAsync(string query, int perPage = 30)
{
try
@@ -143,7 +121,7 @@ public sealed class GitHubApiClient
return null;
}
return await response.Content.ReadFromJsonAsync<GitHubUserSearchResponse>(JsonOptions);
return await response.Content.ReadFromJsonAsync<GitHubUserSearchResponse>(JsonDefaults.ApiClient);
}
catch (Exception ex)
{
@@ -151,12 +129,6 @@ public sealed class GitHubApiClient
return null;
}
}
private static readonly JsonSerializerOptions JsonOptions = new()
{
PropertyNameCaseInsensitive = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
}
public class GitHubOptions

View File

@@ -1,8 +1,8 @@
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.Extensions.Logging;
using RealCV.Application.Helpers;
namespace RealCV.Infrastructure.Clients;
@@ -40,7 +40,7 @@ public sealed class OrcidClient
return null;
}
return await response.Content.ReadFromJsonAsync<OrcidSearchResponse>(JsonOptions);
return await response.Content.ReadFromJsonAsync<OrcidSearchResponse>(JsonDefaults.ApiClient);
}
catch (Exception ex)
{
@@ -69,7 +69,7 @@ public sealed class OrcidClient
return null;
}
return await response.Content.ReadFromJsonAsync<OrcidRecord>(JsonOptions);
return await response.Content.ReadFromJsonAsync<OrcidRecord>(JsonDefaults.ApiClient);
}
catch (Exception ex)
{
@@ -92,7 +92,7 @@ public sealed class OrcidClient
return null;
}
return await response.Content.ReadFromJsonAsync<OrcidWorks>(JsonOptions);
return await response.Content.ReadFromJsonAsync<OrcidWorks>(JsonDefaults.ApiClient);
}
catch (Exception ex)
{
@@ -115,7 +115,7 @@ public sealed class OrcidClient
return null;
}
return await response.Content.ReadFromJsonAsync<OrcidEmployments>(JsonOptions);
return await response.Content.ReadFromJsonAsync<OrcidEmployments>(JsonDefaults.ApiClient);
}
catch (Exception ex)
{
@@ -138,7 +138,7 @@ public sealed class OrcidClient
return null;
}
return await response.Content.ReadFromJsonAsync<OrcidEducations>(JsonOptions);
return await response.Content.ReadFromJsonAsync<OrcidEducations>(JsonDefaults.ApiClient);
}
catch (Exception ex)
{
@@ -155,12 +155,6 @@ public sealed class OrcidClient
.Trim();
return orcidId;
}
private static readonly JsonSerializerOptions JsonOptions = new()
{
PropertyNameCaseInsensitive = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
}
// Response models

View File

@@ -24,7 +24,6 @@ public sealed class ProcessCVCheckJob
private const int BaseScore = 100;
private const int UnverifiedCompanyPenalty = 10;
private const int ImplausibleJobTitlePenalty = 15;
private const int CompanyVerificationFlagPenalty = 5; // Base penalty for company flags, actual from flag.ScoreImpact
private const int RapidProgressionPenalty = 10;
private const int EarlyCareerSeniorRolePenalty = 10;
private const int GapMonthPenalty = 1;