Browse Source

Code cleanup

pull/169/head
Sebastian Stehle 9 years ago
parent
commit
192b73a28b
  1. 22
      Squidex.sln.DotSettings
  2. 4
      src/Squidex.Domain.Apps.Core.Model/Apps/AppClient.cs
  3. 2
      src/Squidex.Domain.Apps.Core.Model/Apps/LanguagesConfig.cs
  4. 2
      src/Squidex.Domain.Apps.Core.Model/Rules/IRuleActionVisitor.cs
  5. 2
      src/Squidex.Domain.Apps.Core.Model/Rules/IRuleTriggerVisitor.cs
  6. 4
      src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/ReferencesExtractor.cs
  7. 2
      src/Squidex.Domain.Apps.Core.Operations/HandleRules/Actions/WebhookActionHandler.cs
  8. 6
      src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs
  9. 2
      src/Squidex.Domain.Apps.Read.MongoDb/MongoCollectionExtensions.cs
  10. 2
      src/Squidex.Infrastructure/CQRS/Events/RetrySubscription.cs
  11. 2
      src/Squidex.Infrastructure/Cloneable{T}.cs
  12. 2
      src/Squidex.Infrastructure/Reflection/SimpleCopier.cs
  13. 2
      src/Squidex.Infrastructure/StringExtensions.cs
  14. 4
      src/Squidex/Config/Orleans/CustomJsonSerializer.cs
  15. 2
      src/Squidex/Config/ServiceExtensions.cs
  16. 2
      tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionTests.cs
  17. 2
      tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/Triggers/ContentChangedTriggerTests.cs
  18. 2
      tests/Squidex.Domain.Apps.Write.Tests/Schemas/Guards/GuardSchemaFieldTests.cs
  19. 4
      tests/Squidex.Domain.Apps.Write.Tests/Schemas/Guards/GuardSchemaTests.cs
  20. 2
      tests/Squidex.Infrastructure.Tests/CQRS/Events/Grains/EventConsumerGrainTests.cs
  21. 4
      tests/Squidex.Infrastructure.Tests/Json/ClaimsPrincipalConverterTests.cs

22
Squidex.sln.DotSettings

@ -3,18 +3,24 @@
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Djs/@EntryIndexRemoved">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ecshtml/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ecshtml/@EntryIndexRemoved">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ecss/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ecss/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ecss/@EntryIndexRemoved">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ehtml/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ejs/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ehtml/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ehtml/@EntryIndexRemoved">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ejs/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ejs/@EntryIndexRemoved">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ejson/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Escss/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ejson/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ejson/@EntryIndexRemoved">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Escss/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Escss/@EntryIndexRemoved">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ets/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ets/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ets/@EntryIndexRemoved">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002E_002A/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002E_002A/@EntryIndexedValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002E_002A/@EntryIndexRemoved">True</s:Boolean>

4
src/Squidex.Domain.Apps.Core.Model/Apps/AppClient.cs

@ -13,8 +13,8 @@ namespace Squidex.Domain.Apps.Core.Apps
public sealed class AppClient
{
private readonly string secret;
private string name;
private AppClientPermission permission;
private readonly string name;
private readonly AppClientPermission permission;
public string Name
{

2
src/Squidex.Domain.Apps.Core.Model/Apps/LanguagesConfig.cs

@ -85,7 +85,7 @@ namespace Squidex.Domain.Apps.Core.Apps
public static LanguagesConfig Build(params Language[] languages)
{
return Build(languages?.Select(x => new LanguageConfig(x, false))?.ToList());
return Build(languages?.Select(x => new LanguageConfig(x)).ToList());
}
public LanguagesConfig MakeMaster(Language language)

2
src/Squidex.Domain.Apps.Core.Model/Rules/IRuleActionVisitor.cs

@ -10,7 +10,7 @@ using Squidex.Domain.Apps.Core.Rules.Actions;
namespace Squidex.Domain.Apps.Core.Rules
{
public interface IRuleActionVisitor<T>
public interface IRuleActionVisitor<out T>
{
T Visit(WebhookAction action);
}

2
src/Squidex.Domain.Apps.Core.Model/Rules/IRuleTriggerVisitor.cs

@ -10,7 +10,7 @@ using Squidex.Domain.Apps.Core.Rules.Triggers;
namespace Squidex.Domain.Apps.Core.Rules
{
public interface IRuleTriggerVisitor<T>
public interface IRuleTriggerVisitor<out T>
{
T Visit(ContentChangedTrigger trigger);
}

4
src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/ReferencesExtractor.cs

@ -32,7 +32,7 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds
public static IEnumerable<Guid> Visit(AssetsField field, JToken value)
{
IEnumerable<Guid> result = null;
IEnumerable<Guid> result;
try
{
result = value?.ToObject<List<Guid>>();
@ -47,7 +47,7 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds
private static IEnumerable<Guid> Visit(ReferencesField field, JToken value)
{
IEnumerable<Guid> result = null;
IEnumerable<Guid> result;
try
{
result = value?.ToObject<List<Guid>>() ?? Enumerable.Empty<Guid>();

2
src/Squidex.Domain.Apps.Core.Operations/HandleRules/Actions/WebhookActionHandler.cs

@ -20,7 +20,7 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS.Events;
using Squidex.Infrastructure.Http;
namespace Squidex.Domain.Apps.Core.HandleRules.ActionHandlers
namespace Squidex.Domain.Apps.Core.HandleRules.Actions
{
public sealed class WebhookActionHandler : RuleActionHandler<WebhookAction>
{

6
src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs

@ -116,11 +116,11 @@ namespace Squidex.Domain.Apps.Core.Scripting
}
catch (ParserException ex)
{
throw new ValidationException($"Failed to execute script with javascript syntaxs error.", new ValidationError(ex.Message));
throw new ValidationException("Failed to execute script with javascript syntaxs error.", new ValidationError(ex.Message));
}
catch (JavaScriptException ex)
{
throw new ValidationException($"Failed to execute script with javascript error.", new ValidationError(ex.Message));
throw new ValidationException("Failed to execute script with javascript error.", new ValidationError(ex.Message));
}
}
@ -171,7 +171,7 @@ namespace Squidex.Domain.Apps.Core.Scripting
{
var errors = !string.IsNullOrWhiteSpace(message) ? new[] { new ValidationError(message) } : null;
throw new ValidationException($"Script rejected the operation.", errors);
throw new ValidationException("Script rejected the operation.", errors);
}));
}
}

2
src/Squidex.Domain.Apps.Read.MongoDb/MongoCollectionExtensions.cs

@ -20,7 +20,7 @@ namespace Squidex.Domain.Apps.Read.MongoDb
{
public static Task CreateAsync<T>(this IMongoCollection<T> collection, SquidexEvent @event, EnvelopeHeaders headers, Action<T> updater) where T : class, IEntity, new()
{
var entity = EntityMapper.Create<T>(@event, headers, updater);
var entity = EntityMapper.Create(@event, headers, updater);
return collection.InsertOneIfNotExistsAsync(entity);
}

2
src/Squidex.Infrastructure/CQRS/Events/RetrySubscription.cs

@ -15,7 +15,7 @@ namespace Squidex.Infrastructure.CQRS.Events
{
public sealed class RetrySubscription : IEventSubscription, IEventSubscriber
{
private readonly SingleThreadedDispatcher dispatcher = new SingleThreadedDispatcher(10);
private readonly SingleThreadedDispatcher dispatcher = new SingleThreadedDispatcher();
private readonly CancellationTokenSource disposeCts = new CancellationTokenSource();
private readonly RetryWindow retryWindow = new RetryWindow(TimeSpan.FromMinutes(5), 5);
private readonly IEventStore eventStore;

2
src/Squidex.Infrastructure/Cloneable{T}.cs

@ -14,7 +14,7 @@ namespace Squidex.Infrastructure
{
protected T Clone(Action<T> updater)
{
return base.Clone<T>(updater);
return base.Clone(updater);
}
}
}

2
src/Squidex.Infrastructure/Reflection/SimpleCopier.cs

@ -53,7 +53,7 @@ namespace Squidex.Infrastructure.Reflection
if (property.PropertyType.Implements<ICloneable>())
{
Mappers.Add(new PropertyMapper(accessor, x => x == null ? x : ((ICloneable)x).Clone()));
Mappers.Add(new PropertyMapper(accessor, x => ((ICloneable)x)?.Clone()));
}
else
{

2
src/Squidex.Infrastructure/StringExtensions.cs

@ -328,7 +328,7 @@ namespace Squidex.Infrastructure
{
var sb = new StringBuilder();
foreach (var part in value.Split(new[] { '-', '_', ' ' }))
foreach (var part in value.Split('-', '_', ' '))
{
if (part.Length < 2)
{

4
src/Squidex/Config/Orleans/CustomJsonSerializer.cs

@ -8,6 +8,7 @@
using Newtonsoft.Json;
using Squidex.Config.Domain;
using Squidex.Infrastructure.CQRS.Events;
using Squidex.Infrastructure.Json.Orleans;
namespace Squidex.Config.Orleans
@ -15,7 +16,8 @@ namespace Squidex.Config.Orleans
public class CustomJsonSerializer : JsonExternalSerializer
{
public CustomJsonSerializer()
: base(JsonSerializer.Create(SerializationServices.DefaultJsonSettings))
: base(JsonSerializer.Create(SerializationServices.DefaultJsonSettings),
typeof(Envelope<IEvent>))
{
}
}

2
src/Squidex/Config/ServiceExtensions.cs

@ -62,7 +62,7 @@ namespace Squidex.Config
public static T GetOptionalValue<T>(this IConfiguration config, string path, T defaultValue = default(T))
{
var value = config.GetValue<T>(path, defaultValue);
var value = config.GetValue(path, defaultValue);
return value;
}

2
tests/Squidex.Domain.Apps.Core.Tests/Operations/ConvertContent/ContentConversionTests.cs

@ -351,7 +351,7 @@ namespace Squidex.Domain.Apps.Core.Operations.ConvertContent
var fallbackConfig =
LanguagesConfig.Build(
new LanguageConfig(Language.EN),
new LanguageConfig(Language.DE, false, new[] { Language.EN }));
new LanguageConfig(Language.DE, false, Language.EN));
var output = (Dictionary<string, JToken>)data.ToLanguageModel(fallbackConfig, new List<Language> { Language.DE });

2
tests/Squidex.Domain.Apps.Core.Tests/Operations/HandleRules/Triggers/ContentChangedTriggerTests.cs

@ -68,7 +68,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules.Triggers
{
var trigger = new ContentChangedTrigger
{
Schemas = ImmutableList.Create<ContentChangedTriggerSchema>(
Schemas = ImmutableList.Create(
new ContentChangedTriggerSchema
{
SendCreate = sendCreate == 1,

2
tests/Squidex.Domain.Apps.Write.Tests/Schemas/Guards/GuardSchemaFieldTests.cs

@ -15,7 +15,7 @@ using Xunit;
#pragma warning disable SA1310 // Field names must not contain underscore
namespace Squidex.Domain.Apps.Write.Schemas
namespace Squidex.Domain.Apps.Write.Schemas.Guards
{
public class GuardSchemaFieldTests
{

4
tests/Squidex.Domain.Apps.Write.Tests/Schemas/Guards/GuardSchemaTests.cs

@ -70,13 +70,13 @@ namespace Squidex.Domain.Apps.Write.Schemas.Guards
{
Name = null,
Properties = null,
Partitioning = "invalid",
Partitioning = "invalid"
},
new CreateSchemaField
{
Name = null,
Properties = InvalidProperties(),
Partitioning = "invalid",
Partitioning = "invalid"
}
},
Name = "new-schema"

2
tests/Squidex.Infrastructure.Tests/CQRS/Events/Grains/EventConsumerGrainTests.cs

@ -59,7 +59,7 @@ namespace Squidex.Infrastructure.CQRS.Events.Grains
public EventConsumerGrainTests()
{
factory = new EventConsumerFactory(x => eventConsumer);
factory = x => eventConsumer;
state.Position = Guid.NewGuid().ToString();
consumerName = eventConsumer.GetType().Name;

4
tests/Squidex.Infrastructure.Tests/Json/ClaimsPrincipalConverterTests.cs

@ -25,14 +25,14 @@ namespace Squidex.Infrastructure.Json
new[]
{
new Claim("email", "me@email.de"),
new Claim("username", "me@email.de"),
new Claim("username", "me@email.de")
},
"Cookie"),
new ClaimsIdentity(
new[]
{
new Claim("user_id", "12345"),
new Claim("login", "me"),
new Claim("login", "me")
},
"Google")
});

Loading…
Cancel
Save