<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;

using Microsoft.Extensions.DependencyModel;

using NuGet.Protocol.Core.Types;

using NuGetPe.AssemblyMetadata;

namespace NuGetPe
{
    public class SymbolValidator
    {
        private readonly IPackage _package;
        private readonly string _packagePath;
        private readonly IFolder _rootFolder;
        private readonly HttpClient _httpClient = new();

        public SymbolValidator(IPackage package, string packagePath, IFolder? rootFolder = null)
            : this(package, packagePath, rootFolder, httpClient: null)
        {
        }

        public SymbolValidator(IPackage package, string packagePath, IFolder? rootFolder = null, HttpClient? httpClient = null)
        {
            _package = package ?? throw new ArgumentNullException(nameof(package));
            _packagePath = packagePath ?? throw new ArgumentNullException(nameof(packagePath));
            _rootFolder = rootFolder ?? PathToTreeConverter.Convert(package.GetFiles().ToList());
            _httpClient = httpClient ?? new();

            if (httpClient == null)
            {
                UserAgent.SetUserAgent(_httpClient);
            }
        }

        public async Task<SymbolValidatorResult> Validate(CancellationToken cancellationToken = default)<commit_msg>Don't initialize in the field<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;

using Microsoft.Extensions.DependencyModel;

using NuGet.Protocol.Core.Types;

using NuGetPe.AssemblyMetadata;

namespace NuGetPe
{
    public class SymbolValidator
    {
        private readonly IPackage _package;
        private readonly string _packagePath;
        private readonly IFolder _rootFolder;
        private readonly HttpClient _httpClient;

        public SymbolValidator(IPackage package, string packagePath, IFolder? rootFolder = null)
            : this(package, packagePath, rootFolder, httpClient: null)
        {
        }

        public SymbolValidator(IPackage package, string packagePath, IFolder? rootFolder = null, HttpClient? httpClient = null)
        {
            _package = package ?? throw new ArgumentNullException(nameof(package));
            _packagePath = packagePath ?? throw new ArgumentNullException(nameof(packagePath));
            _rootFolder = rootFolder ?? PathToTreeConverter.Convert(package.GetFiles().ToList());
            _httpClient = httpClient ?? new();

            if (httpClient == null)
            {
                UserAgent.SetUserAgent(_httpClient);
            }
        }

        public async Task<SymbolValidatorResult> Validate(CancellationToken cancellationToken = default)
{'fraction_non_alphanumeric': 0.07861425716189208, 'fraction_numerical': 0.0, 'mean_word_length': 3.2, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '237470', 'n_tokens_mistral': 743, 'n_tokens_neox': 736, 'n_words': 194}