Skip to content

Commit

Permalink
fix sonarcloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
snixtho committed Jun 1, 2024
1 parent 2408dcc commit bff967d
Show file tree
Hide file tree
Showing 21 changed files with 26 additions and 84 deletions.
1 change: 0 additions & 1 deletion src/EvoSC.Common/Database/DbConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using EvoSC.Common.Database.Extensions;
using EvoSC.Common.Interfaces.Database;
using LinqToDB;
using LinqToDB.Configuration;
using LinqToDB.Data;
using Microsoft.Extensions.Logging;

Expand Down
3 changes: 1 addition & 2 deletions src/EvoSC.Common/Database/Repository/DbRepository.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

using EvoSC.Common.Interfaces.Database;
using EvoSC.Common.Interfaces.Database;
using LinqToDB;

namespace EvoSC.Common.Database.Repository;
Expand Down
7 changes: 3 additions & 4 deletions src/EvoSC.Common/Database/Repository/Maps/MapRepository.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using EvoSC.Common.Database.Models.Maps;
using System.Globalization;
using EvoSC.Common.Database.Models.Maps;
using EvoSC.Common.Database.Models.Player;
using EvoSC.Common.Exceptions.DatabaseExceptions;
using EvoSC.Common.Interfaces.Database;
using EvoSC.Common.Interfaces.Database.Repository;
using EvoSC.Common.Interfaces.Models;
using EvoSC.Common.Models.Maps;
using LinqToDB;
using LinqToDB.DataProvider.MySql;
using LinqToDB.Tools;
using Microsoft.Extensions.Logging;

namespace EvoSC.Common.Database.Repository.Maps;
Expand Down Expand Up @@ -58,7 +57,7 @@ public async Task<IMap> AddMapAsync(MapMetadata map, IPlayer author, string file
{
var id = await Database.InsertWithIdentityAsync(dbMap);
await transaction.CommitTransactionAsync();
dbMap.Id = Convert.ToInt64(id);
dbMap.Id = Convert.ToInt64(id, CultureInfo.InvariantCulture);
}
catch (Exception e)
{
Expand Down
21 changes: 2 additions & 19 deletions src/EvoSC.Common/Interfaces/Models/IParsedMap.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
using EvoSC.Common.Interfaces.Util;
namespace EvoSC.Common.Interfaces.Models;

namespace EvoSC.Common.Interfaces.Models;

public interface IParsedMap : IMapDetails
{
/* public IRaceTime AuthorTime { get; }
public IRaceTime GoldTime { get; }
public IRaceTime SilverTime { get; }
public IRaceTime BronzeTime { get; }
public string Environment { get; }
public string Mood { get; }
public int Cost { get; }
public bool MultiLap { get; }
public int LapCount { get; }
public string MapStyle { get; }
public string MapType { get; }
public int CheckpointCount { get; } */
}
public interface IParsedMap : IMapDetails;
30 changes: 0 additions & 30 deletions src/EvoSC.Common/Interfaces/Themes/DefaultThemeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,6 @@ public interface DefaultThemeOptions
public static readonly string UITextSecondary = "UI.TextSecondary";
public static readonly string UITextMuted = "UI.TextMuted";

/* /// <summary>
/// Primary text color.
/// </summary>
public static readonly string UITextPrimary = "UI.TextPrimary";
/// <summary>
/// Secondary text color.
/// </summary>
public static readonly string UITextSecondary = "UI.TextSecondary";
/// <summary>
/// Primary background color.
/// </summary>
public static readonly string UIBgPrimary = "UI.BgPrimary";
/// <summary>
/// Secondary background color.
/// </summary>
public static readonly string UIBgSecondary = "UI.BgSecondary";
/// <summary>
/// Primary border color.
/// </summary>
public static readonly string UIBorderPrimary = "UI.BorderPrimary";
/// <summary>
/// Secondary border color.
/// </summary>
public static readonly string UIBorderSecondary = "UI.BorderSecondary"; */

/// <summary>
/// Dark version of the logo.
/// </summary>
Expand Down
2 changes: 0 additions & 2 deletions src/EvoSC.Common/Services/MatchSettingsService.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using EvoSC.Common.Config.Models;
using EvoSC.Common.Database.Repository.Maps;
using EvoSC.Common.Interfaces;
using EvoSC.Common.Interfaces.Models;
using EvoSC.Common.Interfaces.Services;
using EvoSC.Common.Interfaces.Util;
using EvoSC.Common.Models.Maps;
using EvoSC.Common.Util;
using EvoSC.Common.Util.MatchSettings;
using EvoSC.Common.Util.MatchSettings.Builders;
Expand Down
19 changes: 15 additions & 4 deletions src/EvoSC.Common/Util/ColorUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace EvoSC.Common.Util;

public class ColorUtils
{
/// <summary>
/// Renders a color code in ManiaScript.
/// </summary>
/// <param name="hexColor">Color to render.</param>
/// <returns></returns>
public string ToMlColor(string hexColor)
{
var color = new Hex(hexColor).ToRgb();
Expand All @@ -17,14 +22,20 @@ public string ToMlColor(string hexColor)
return $"<{r}, {g}, {b}>";
}

/// <summary>
/// Set the opacity of a color using the alpha channel (4th byte).
/// </summary>
/// <param name="hexColor">Color to set opacity to</param>
/// <param name="opacity">Opacity from 0-100</param>
/// <returns></returns>
public string Opacity(string hexColor, double opacity)
{
var color = new Hex(hexColor).ToRgb();

var r = ((int)Math.Floor(color.R)).ToString("X2");
var g = ((int)Math.Floor(color.G)).ToString("X2");
var b = ((int)Math.Floor(color.B)).ToString("X2");
var a = ((int)Math.Floor(opacity / 100.0 * 255.0)).ToString("X2");
var r = ((int)Math.Floor(color.R)).ToString("X2", CultureInfo.InvariantCulture);
var g = ((int)Math.Floor(color.G)).ToString("X2", CultureInfo.InvariantCulture);
var b = ((int)Math.Floor(color.B)).ToString("X2", CultureInfo.InvariantCulture);
var a = ((int)Math.Floor(opacity / 100.0 * 255.0)).ToString("X2", CultureInfo.InvariantCulture);

return $"{r}{g}{b}{a}";
}
Expand Down
1 change: 0 additions & 1 deletion src/EvoSC.Manialinks/Themes/DefaultDialogTheme.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using EvoSC.Common.Interfaces.Themes;
using EvoSC.Common.Themes;
using EvoSC.Common.Themes.Attributes;
using EvoSC.Common.Util;

namespace EvoSC.Manialinks.Themes;

Expand Down
1 change: 0 additions & 1 deletion src/EvoSC.Manialinks/Themes/DefaultSelectTheme.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using EvoSC.Common.Interfaces.Themes;
using EvoSC.Common.Themes;
using EvoSC.Common.Themes.Attributes;
using EvoSC.Common.Util;

namespace EvoSC.Manialinks.Themes;

Expand Down
6 changes: 2 additions & 4 deletions src/EvoSC.Manialinks/Util/GlobalManialinkUtils.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Globalization;
using System.Text;
using ColorMine.ColorSpaces;
using EvoSC.Common.Interfaces.Themes;
using EvoSC.Common.Util;

Expand Down Expand Up @@ -57,10 +55,10 @@ public string TypeToColorText(string type)
_ => _icons.ExclamationCircle
};

public string RandomId(string id) => $"{id}_{new Guid().ToString()}";
public string RandomId(string id) => $"{id}_{Guid.NewGuid().ToString()}";

public string DefaultOrRandomId(string defaultId, string id) =>
id == defaultId ? $"{id}_{new Guid().ToString()}" : id;
id == defaultId ? $"{id}_{Guid.NewGuid().ToString()}" : id;

public double ColorOpacity(string color)
{
Expand Down
1 change: 0 additions & 1 deletion src/EvoSC.Testing/Database/TestDbConnectionFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using EvoSC.Common.Interfaces.Database;
using LinqToDB;
using LinqToDB.Configuration;

namespace EvoSC.Testing.Database;

Expand Down
3 changes: 1 addition & 2 deletions src/EvoSC/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

using EvoSC;
using EvoSC;
using EvoSC.CLI;

return await new CliManager()
Expand Down
1 change: 0 additions & 1 deletion src/Modules/LiveRankingModule/Models/LiveRankingStore.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Concurrent;
using EvoSC.Common.Interfaces.Services;
using Microsoft.Extensions.Logging;

namespace EvoSC.Modules.Official.LiveRankingModule.Models;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using EvoSC.Commands.Interfaces;
using EvoSC.Common.Controllers;
using EvoSC.Common.Controllers.Attributes;
using EvoSC.Manialinks.Interfaces;
using EvoSC.Modules.Official.MapListModule.Interfaces;

namespace EvoSC.Modules.Official.MapListModule.Controllers;
Expand Down
3 changes: 1 addition & 2 deletions src/Modules/MapListModule/Database/Models/DbMapTag.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using EvoSC.Common.Database.Models.Maps;
using EvoSC.Common.Interfaces.Models;
using EvoSC.Common.Interfaces.Models;
using EvoSC.Modules.Official.MapListModule.Interfaces.Models;
using LinqToDB.Mapping;

Expand Down
1 change: 0 additions & 1 deletion src/Modules/MapListModule/Interfaces/IMapListService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using EvoSC.Common.Interfaces.Models;
using EvoSC.Modules.Official.MapListModule.Interfaces.Models;
using EvoSC.Modules.Official.MapListModule.Models;

namespace EvoSC.Modules.Official.MapListModule.Interfaces;

Expand Down
1 change: 0 additions & 1 deletion src/Modules/MapQueueModule/Utils/AsyncDeque/AsyncDeque.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections;
using System.Configuration;
using EvoSC.Modules.Official.MapQueueModule.Interfaces.Utils.AsyncDeque;

namespace EvoSC.Modules.Official.MapQueueModule.Utils.AsyncDeque;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using EvoSC.Commands.Interfaces;
using EvoSC.Common.Controllers;
using EvoSC.Common.Controllers.Attributes;
using EvoSC.Common.Interfaces.Controllers;
using EvoSC.Modules.Official.MotdModule.Interfaces;

namespace EvoSC.Modules.Official.MotdModule.Controllers;
Expand Down
3 changes: 1 addition & 2 deletions src/Modules/PlayerRecords/Database/Models/DbPlayerRecord.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

using EvoSC.Common.Database.Models.Maps;
using EvoSC.Common.Database.Models.Maps;
using EvoSC.Common.Database.Models.Player;
using EvoSC.Common.Interfaces.Models;
using EvoSC.Modules.Official.PlayerRecords.Interfaces.Models;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using EvoSC.Common.Interfaces.Models;
using EvoSC.Common.Interfaces.Services;
using EvoSC.Common.Models.Maps;
using EvoSC.Common.Util.ServerUtils;
using EvoSC.Common.Util.TextFormatting;
using EvoSC.Modules.Official.MapQueueModule.Controllers;
using EvoSC.Modules.Official.MapQueueModule.Interfaces;
using EvoSC.Testing;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using EvoSC.Common.Interfaces;
using EvoSC.Common.Interfaces.Models;
using EvoSC.Common.Interfaces.Services;
using EvoSC.Common.Models.Maps;
using EvoSC.Modules.Official.MapQueueModule.Events;
using EvoSC.Modules.Official.MapQueueModule.Events.Args;
using EvoSC.Modules.Official.MapQueueModule.Interfaces;
using EvoSC.Modules.Official.MapQueueModule.Services;
using EvoSC.Testing;
using Moq;

namespace EvoSC.Modules.Official.MapQueueModuleTests.Tests.Services;
Expand Down

0 comments on commit bff967d

Please sign in to comment.