Skip to content

Commit

Permalink
refactor(sln): minor lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
seangwright committed Aug 1, 2023
1 parent c9225ff commit 50b2070
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 21 deletions.
9 changes: 6 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ dotnet_diagnostic.IDE0079.severity = warn
dotnet_style_prefer_simplified_interpolation = true : error
dotnet_diagnostic.IDE0071.severity = error

csharp_style_namespace_declarations = file_scoped : error
dotnet_diagnostic.IDE0161.severity = error

## Rules without Style Options

# IDE0010: Add missing cases
Expand Down Expand Up @@ -271,6 +268,12 @@ dotnet_diagnostic.IDE0056.severity = warn
csharp_style_prefer_range_operator = true : warning
dotnet_diagnostic.IDE0057.severity = warning

csharp_style_namespace_declarations = file_scoped : error
dotnet_diagnostic.IDE0161.severity = error

csharp_style_prefer_null_check_over_type_check = true : warning
dotnet_diagnostic.IDE0150.severity = error

## Rules without Style Options

# IDE0050: Convert anonymous type to tuple
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class KBankNewsLuceneIndexingStrategy : DefaultLuceneIndexingStrategy
object? result = foundValue;
if (propertyName == nameof(KBankNewsSearchModel.AllContent))
{
var htmlSanitizer = Service.Resolve<HtmlSanitizer>();
var htmlSanitizer = Service.Resolve<WebScraperHtmlSanitizer>();
result = string.Join(" ", contentFields
.Select(f => node.GetStringValue(f, ""))
.Select(s => htmlSanitizer.SanitizeHtmlFragment(s))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
using AngleSharp.Dom;
using AngleSharp.Html.Parser;
using CMS;
using CMS.Core;
using CMS.Helpers;
using Kentico.Xperience.Lucene.Examples.Utils;

[assembly: RegisterImplementation(typeof(WebScraperHtmlSanitizer), typeof(WebScraperHtmlSanitizer), Lifestyle = Lifestyle.Singleton, Priority = RegistrationPriority.SystemDefault)]

namespace Kentico.Xperience.Lucene.Examples.Utils;

public class HtmlSanitizer
public class WebScraperHtmlSanitizer
{
public static string SanitizeHtmlFragment(string htmlContent)
public virtual string SanitizeHtmlFragment(string htmlContent)
{

var parser = new HtmlParser();
Expand Down
2 changes: 0 additions & 2 deletions src/Kentico.Xperience.Lucene/CmsRegistrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
using Kentico.Xperience.Lucene.Services;
using Kentico.Xperience.Lucene.Services.Implementations;

[assembly: AssemblyDiscoverable]

// Allows the Lucene test project to read internal members
[assembly: InternalsVisibleTo("Kentico.Xperience.Lucene.Tests")]

Expand Down
2 changes: 1 addition & 1 deletion src/Kentico.Xperience.Lucene/IndexStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void AddIndex(LuceneIndex index)
throw new ArgumentNullException(nameof(index));
}

if (registeredIndexes.Any(i => i.IndexName.Equals(index.IndexName, StringComparison.OrdinalIgnoreCase)))
if (registeredIndexes.Exists(i => i.IndexName.Equals(index.IndexName, StringComparison.OrdinalIgnoreCase)))
{
throw new InvalidOperationException($"Attempted to register Lucene index with name '{index.IndexName},' but it is already registered.");
}
Expand Down
6 changes: 3 additions & 3 deletions src/Kentico.Xperience.Lucene/Services/ILuceneTaskLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace Kentico.Xperience.Lucene.Services;

/// <summary>
/// Contains methods for logging <see cref="LuceneQueueItem"/>s and <see cref="LuceneCrawlerQueueItem"/>s
/// for processing by <see cref="LuceneQueueWorker"/> and <see cref="LuceneCrawlerQueueWorker"/>.
/// Contains methods for logging <see cref="LuceneQueueItem"/>s and <see cref="LuceneQueueItem"/>s
/// for processing by <see cref="LuceneQueueWorker"/> and <see cref="LuceneQueueWorker"/>.
/// </summary>
public interface ILuceneTaskLogger
{
/// <summary>
/// Logs an <see cref="LuceneCrawlerQueueItem"/> for each registered crawler. Then, loops
/// Logs an <see cref="LuceneQueueItem"/> for each registered crawler. Then, loops
/// through all registered Lucene indexes and logs a task if the passed <paramref name="node"/> is indexed.
/// </summary>
/// <param name="node">The <see cref="TreeNode"/> that triggered the event.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,16 @@ public Task<int> DeleteRecords(IEnumerable<string> objectIds, string indexName)


/// <inheritdoc/>
public async Task<ICollection<LuceneIndexStatisticsViewModel>> GetStatistics(CancellationToken cancellationToken) => IndexStore.Instance.GetAllIndexes().Select(i =>
{
var statistics = luceneIndexService.UseSearcher(i, s => new LuceneIndexStatisticsViewModel()
{
Name = i.IndexName,
Entries = s.IndexReader.NumDocs,
});
return statistics;
}).ToList();
public async Task<ICollection<LuceneIndexStatisticsViewModel>> GetStatistics(CancellationToken cancellationToken) =>

Check warning on line 67 in src/Kentico.Xperience.Lucene/Services/Implementations/DefaultLuceneClient.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
IndexStore.Instance.GetAllIndexes().Select(i =>
{
var statistics = luceneIndexService.UseSearcher(i, s => new LuceneIndexStatisticsViewModel()
{
Name = i.IndexName,
Entries = s.IndexReader.NumDocs,
});
return statistics;
}).ToList();


/// <inheritdoc />
Expand Down

0 comments on commit 50b2070

Please sign in to comment.