Skip to content

Commit

Permalink
Merge pull request EduardoPires#165 from EduardoPires/CodeImprovements
Browse files Browse the repository at this point in the history
Sonarqube improvements
  • Loading branch information
EduardoPires authored Jun 10, 2020
2 parents 53d5908 + 3130094 commit 0a27d8d
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Equinox.Application.EventSourcedNormalizers
{
public class CustomerHistory
public static class CustomerHistory
{
public static IList<CustomerHistoryData> HistoryData { get; set; }

Expand Down Expand Up @@ -67,6 +67,11 @@ private static void CustomerHistoryDeserializer(IEnumerable<StoredEvent> storedE
historyData.Action = "Removed";
historyData.Who = e.User;
break;
default:
historyData.Action = "Unrecognized";
historyData.Who = e.User ?? "Anonymous";
break;

}
HistoryData.Add(historyData);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Equinox.Domain.Core/Models/ValueObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public abstract class ValueObject<T> where T : ValueObject<T>
public override bool Equals(object obj)
{
var valueObject = obj as T;
return !ReferenceEquals(valueObject, null) && EqualsCore(valueObject);
return EqualsCore(valueObject);
}

protected abstract bool EqualsCore(T other);
Expand All @@ -19,10 +19,10 @@ public override int GetHashCode()

public static bool operator ==(ValueObject<T> a, ValueObject<T> b)
{
if (ReferenceEquals(a, null) && ReferenceEquals(b, null))
if (a is null && b is null)
return true;

if (ReferenceEquals(a, null) || ReferenceEquals(b, null))
if (a is null || b is null)
return false;

return a.Equals(b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace Equinox.Infra.CrossCutting.IoC
{
public class NativeInjectorBootStrapper
public static class NativeInjectorBootStrapper
{
public static void RegisterServices(IServiceCollection services)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Equinox.Infra.Data/Context/EquinoxContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task<bool> Commit()
// side effects from the domain event handlers which are using the same DbContext with "InstancePerLifetimeScope" or "scoped" lifetime
// B) Right AFTER committing data (EF SaveChanges) into the DB will make multiple transactions.
// You will need to handle eventual consistency and compensatory actions in case of failures in any of the Handlers.
await _mediatorHandler.PublishDomainEvents(this);
await _mediatorHandler.PublishDomainEvents(this).ConfigureAwait(false);

// After executing this line all the changes (from the Command Handler and Domain Event Handlers)
// performed through the DbContext will be committed
Expand Down
2 changes: 1 addition & 1 deletion src/Equinox.Services.Api/Configurations/SwaggerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void AddSwaggerConfiguration(this IServiceCollection services)
Title = "Equinox Project",
Description = "Equinox API Swagger surface",
Contact = new OpenApiContact { Name = "Eduardo Pires", Email = "[email protected]", Url = new Uri("http://www.eduardopires.net.br") },
License = new OpenApiLicense() { Name = "MIT", Url = new Uri("https://github.com/EduardoPires/EquinoxProject/blob/master/LICENSE") }
License = new OpenApiLicense { Name = "MIT", Url = new Uri("https://github.com/EduardoPires/EquinoxProject/blob/master/LICENSE") }
});

s.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
Expand Down
10 changes: 5 additions & 5 deletions src/Equinox.Services.Api/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Equinox.Services.Api.Controllers
[ApiController]
public abstract class ApiController : ControllerBase
{
public ICollection<string> Errors = new List<string>();
private readonly ICollection<string> _errors = new List<string>();

protected ActionResult CustomResponse(object result = null)
{
Expand All @@ -20,7 +20,7 @@ protected ActionResult CustomResponse(object result = null)

return BadRequest(new ValidationProblemDetails(new Dictionary<string, string[]>
{
{ "Messages", Errors.ToArray() }
{ "Messages", _errors.ToArray() }
}));
}

Expand All @@ -47,17 +47,17 @@ protected ActionResult CustomResponse(ValidationResult validationResult)

protected bool IsOperationValid()
{
return !Errors.Any();
return !_errors.Any();
}

protected void AddError(string erro)
{
Errors.Add(erro);
_errors.Add(erro);
}

protected void ClearErrors()
{
Errors.Clear();
_errors.Clear();
}
}
}
2 changes: 1 addition & 1 deletion src/Equinox.Services.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Equinox.Services.API
{
public class Program
public static class Program
{
public static void Main(string[] args)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Equinox.Services.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddDependencyInjectionConfiguration();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
Expand Down
3 changes: 1 addition & 2 deletions src/Equinox.UI.Web/Areas/Identity/IdentityHostingStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ public class IdentityHostingStartup : IHostingStartup
{
public void Configure(IWebHostBuilder builder)
{
builder.ConfigureServices((context, services) => {
});
builder.ConfigureServices((context, services) => {});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public async Task<IActionResult> OnPostAsync(string returnUrl = null)
var callbackUrl = Url.Page(
"/Account/ConfirmEmail",
pageHandler: null,
values: new { area = "Identity", userId = user.Id, code = code },
values: new { area = "Identity", userId = user.Id, code },
protocol: Request.Scheme);

await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
Expand Down
6 changes: 3 additions & 3 deletions src/Equinox.UI.Web/Controllers/BaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Equinox.UI.Web.Controllers
{
public class BaseController : Controller
{
public ICollection<string> Errors = new List<string>();
private readonly ICollection<string> _errors = new List<string>();

protected bool ResponseHasErrors(ValidationResult result)
{
Expand All @@ -23,12 +23,12 @@ protected bool ResponseHasErrors(ValidationResult result)

protected void AddProcessError(string erro)
{
Errors.Add(erro);
_errors.Add(erro);
}

public bool IsValidOperation()
{
return !Errors.Any();
return !_errors.Any();
}
}
}
2 changes: 1 addition & 1 deletion src/Equinox.UI.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Equinox.UI.Web
{
public class Program
public static class Program
{
public static void Main(string[] args)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Equinox.UI.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddDependencyInjectionConfiguration();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
Expand Down

0 comments on commit 0a27d8d

Please sign in to comment.