Skip to content

Commit

Permalink
General cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Jul 22, 2024
1 parent 0a75988 commit 62701fe
Show file tree
Hide file tree
Showing 58 changed files with 317 additions and 308 deletions.
18 changes: 12 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[*.cs]

# IDE0290: Utiliser le constructeur principal
dotnet_diagnostic.IDE0290.severity = suggestion
dotnet_diagnostic.IDE0290.severity = silent

# IDE0300: Simplifier l'initialisation des collections
dotnet_diagnostic.IDE0300.severity = suggestion
Expand Down Expand Up @@ -37,22 +37,28 @@ dotnet_diagnostic.CA1861.severity = suggestion
dotnet_analyzer_diagnostic.category-Style.severity = suggestion

# CA1716: Les identificateurs ne doivent pas correspondre à des mots clés
dotnet_diagnostic.CA1716.severity = suggestion
dotnet_diagnostic.CA1716.severity = silent

# CA1711: Les identificateurs ne doivent pas avoir un suffixe incorrect
dotnet_diagnostic.CA1711.severity = suggestion
dotnet_diagnostic.CA1711.severity = silent

# CA1305: Spécifier IFormatProvider
dotnet_diagnostic.CA1305.severity = suggestion
dotnet_diagnostic.CA1305.severity = silent

# CA1513: Utiliser l’assistance de levée ObjectDisposedException
dotnet_diagnostic.CA1513.severity = suggestion

# CA2201: Ne pas lever de types d'exception réservés
dotnet_diagnostic.CA2201.severity = suggestion
dotnet_diagnostic.CA2201.severity = silent

# CA1001: Les types qui ont des champs supprimables doivent être supprimables
dotnet_diagnostic.CA1001.severity = suggestion

# CA1707: Les identificateurs ne doivent pas contenir de traits de soulignement
dotnet_diagnostic.CA1707.severity = suggestion
dotnet_diagnostic.CA1707.severity = silent

dotnet_diagnostic.IDE0160.severity = silent

dotnet_diagnostic.IDE0022.severity = silent

dotnet_diagnostic.CA1310.severity = silent
2 changes: 2 additions & 0 deletions src/net/Wexflow.Clients.CommandLine/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ private static void Main(string[] args)
}
client.RejectWorkflow(o.WorkflowId, Guid.Parse(o.JobId), username, password);
break;
default:
break;
}
});

Expand Down
6 changes: 6 additions & 0 deletions src/net/Wexflow.Core.Db.Firebird/Db.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ public override void DeleteWorkflows(string[] ids)

_ = sqlBuilder.Append(Entry.COLUMN_NAME_STATUS).Append(" DESC");
break;

default:
break;
}

_ = sqlBuilder.Append(';');
Expand Down Expand Up @@ -848,6 +851,9 @@ public override DateTime GetEntryStatusDateMin()

_ = sqlBuilder.Append(HistoryEntry.COLUMN_NAME_STATUS).Append(" DESC");
break;

default:
break;
}

_ = sqlBuilder.Append(';');
Expand Down
12 changes: 12 additions & 0 deletions src/net/Wexflow.Core.Db.LiteDB/Db.cs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,9 @@ public override string GetPassword(string username)
{
return col.Find(Query.All("Username", Query.Descending));
}

default:
break;
}

return Array.Empty<User>();
Expand Down Expand Up @@ -626,6 +629,9 @@ public override string GetPassword(string username)
q.Where.Add(Query.EQ("UserProfile", UserProfile.Administrator.ToString()));
return col.Find(q);
}

default:
break;
}

return Array.Empty<User>();
Expand Down Expand Up @@ -962,6 +968,9 @@ public void DeleteHistoryEntries(int workflowId)
, skip
, entriesCount
);

default:
break;
}

return Array.Empty<HistoryEntry>();
Expand Down Expand Up @@ -1220,6 +1229,9 @@ public void DeleteHistoryEntries(int workflowId)
, skip
, entriesCount
);

default:
break;
}

return Array.Empty<Entry>();
Expand Down
10 changes: 8 additions & 2 deletions src/net/Wexflow.Core.Db.MariaDB/Db.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Db(string connectionString) : base(connectionString)
var password = string.Empty;
var database = string.Empty;

var connectionStringParts = Db._connectionString.Split(';');
var connectionStringParts = _connectionString.Split(';');

foreach (var part in connectionStringParts)
{
Expand Down Expand Up @@ -52,7 +52,7 @@ public Db(string connectionString) : base(connectionString)
}
}

var helper = new Helper(Db._connectionString);
var helper = new Helper(_connectionString);
Helper.CreateDatabaseIfNotExists(server, port, user, password, database);
helper.CreateTableIfNotExists(Core.Db.Entry.DOCUMENT_NAME, Entry.TABLE_STRUCT);
helper.CreateTableIfNotExists(Core.Db.HistoryEntry.DOCUMENT_NAME, HistoryEntry.TABLE_STRUCT);
Expand Down Expand Up @@ -459,6 +459,9 @@ public override void DeleteWorkflows(string[] ids)

_ = sqlBuilder.Append(Entry.COLUMN_NAME_STATUS).Append(" DESC");
break;

default:
break;
}

_ = sqlBuilder.Append(" LIMIT ").Append(entriesCount).Append(" OFFSET ").Append((page - 1) * entriesCount).Append(';');
Expand Down Expand Up @@ -888,6 +891,9 @@ public override DateTime GetEntryStatusDateMin()

_ = sqlBuilder.Append(HistoryEntry.COLUMN_NAME_STATUS).Append(" DESC");
break;

default:
break;
}

_ = sqlBuilder.Append(" LIMIT ").Append(entriesCount).Append(" OFFSET ").Append((page - 1) * entriesCount).Append(';');
Expand Down
11 changes: 11 additions & 0 deletions src/net/Wexflow.Core.Db.RavenDB/Db.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ public override void DeleteWorkflows(string[] ids)
.Where(u => u.UserProfile == UserProfile.Administrator)
.OrderByDescending(u => u.Username)
.ToArray();

default:
break;
}

return Array.Empty<User>();
Expand Down Expand Up @@ -491,6 +494,9 @@ public override void DeleteWorkflows(string[] ids)
.Skip(skip)
.Take(entriesCount)
.ToArray();

default:
break;
}

return Array.Empty<Entry>();
Expand Down Expand Up @@ -814,6 +820,9 @@ public override DateTime GetEntryStatusDateMin()
.Skip(skip)
.Take(entriesCount)
.ToArray();

default:
break;
}

return Array.Empty<HistoryEntry>();
Expand Down Expand Up @@ -1029,6 +1038,8 @@ public override Core.Db.User GetUserById(string userId)
return col.Search(u => u.Username, keywordToLower).OrderBy(u => u.Username).ToArray();
case UserOrderBy.UsernameDescending:
return col.Search(u => u.Username, keywordToLower).OrderByDescending(u => u.Username).ToArray();
default:
break;
}

return Array.Empty<User>();
Expand Down
6 changes: 6 additions & 0 deletions src/net/Wexflow.Core.Db.SQLite/Db.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ public override void DeleteWorkflows(string[] ids)

_ = sqlBuilder.Append(Entry.COLUMN_NAME_STATUS).Append(" DESC");
break;

default:
break;
}

_ = sqlBuilder.Append(" LIMIT ").Append(entriesCount).Append(" OFFSET ").Append((page - 1) * entriesCount).Append(';');
Expand Down Expand Up @@ -868,6 +871,9 @@ public override DateTime GetEntryStatusDateMin()

_ = sqlBuilder.Append(HistoryEntry.COLUMN_NAME_STATUS).Append(" DESC");
break;

default:
break;
}

_ = sqlBuilder.Append(" LIMIT ").Append(entriesCount).Append(" OFFSET ").Append((page - 1) * entriesCount).Append(';');
Expand Down
2 changes: 2 additions & 0 deletions src/net/Wexflow.Core/WexflowEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ public WexflowEngine(string settingsFile
case DbType.MariaDB:
Database = new Db.MariaDB.Db(ConnectionString);
break;
default:
break;
}

Database?.Init();
Expand Down
6 changes: 4 additions & 2 deletions src/net/Wexflow.Core/Workflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,8 @@ public bool StartSync(string startedBy, Guid instanceId, ref bool resultWarning)
Database.UpdateEntry(entry.GetDbId(), entry);
_historyEntry.Status = Db.Status.Rejected;
break;
default:
break;
}
}
}
Expand Down Expand Up @@ -1511,7 +1513,7 @@ private void RunIf(Task[] tasks, Node[] nodes, If @if, bool force, ref bool succ
}
}
}
else if (status.Condition == false)
else if (!status.Condition)
{
if (@if.ElseNodes != null && @if.ElseNodes.Length > 0)
{
Expand Down Expand Up @@ -1573,7 +1575,7 @@ private void RunWhile(Task[] tasks, Node[] nodes, While @while, bool force, ref
RunTasks(doWhileTasks, @while.Nodes, doWhileStartNode, force, ref success, ref warning, ref atLeastOneSucceed);
}
}
else if (status.Condition == false)
else if (!status.Condition)
{
break;
}
Expand Down
2 changes: 2 additions & 0 deletions src/net/Wexflow.Tasks.Sql/Sql.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ private void ExecuteSql(string sql)
ExecSql(conn, comm);
}
break;
default:
break;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/net/Wexflow.Tasks.SqlToCsv/SqlToCsv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ private void ExecuteSql(string sql)
ConvertToCsv(connection, command);
}
break;
default:
break;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/net/Wexflow.Tasks.SqlToXml/SqlToXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ private void ExecuteSql(string sql)
ConvertToXml(connenction, command);
}
break;
default:
break;
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/net/Wexflow.Tasks.SubWorkflow/SubWorkflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public override TaskStatus Run()
case KickOffMode.Async:
_ = workflow.StartAsync(Workflow.StartedBy);
break;
default:
break;
}
break;
case KickOffAction.Stop:
Expand Down Expand Up @@ -98,6 +100,8 @@ public override TaskStatus Run()
ErrorFormat("The workflow {0} is not waiting for approval to be rejected.", WorkflowId);
}
break;
default:
break;
}
}
else
Expand Down
2 changes: 2 additions & 0 deletions src/net/Wexflow.Tasks.Workflow/Workflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ public override TaskStatus Run()
ErrorFormat("Can't reject the workflow {0} because it's not waiting for approval.", id);
}
break;
default:
break;
}
}
catch (Exception e)
Expand Down
2 changes: 2 additions & 0 deletions src/netcore/Wexflow.Clients.CommandLine/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ async Task<int> ExecuteCommand(Options o)

await client.RejectWorkflow(o.WorkflowId, Guid.Parse(o.JobId), username, password);
break;
default:
break;
}

return await Task.FromResult(0);
Expand Down
10 changes: 8 additions & 2 deletions src/netcore/Wexflow.Core.Db.Firebird/Db.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ public override void DeleteWorkflows(string[] ids)

_ = sqlBuilder.Append(Entry.COLUMN_NAME_STATUS).Append(" DESC");
break;

default:
break;
}

_ = sqlBuilder.Append(';');
Expand Down Expand Up @@ -769,6 +772,9 @@ public override DateTime GetEntryStatusDateMin()

_ = sqlBuilder.Append(HistoryEntry.COLUMN_NAME_STATUS).Append(" DESC");
break;

default:
break;
}

_ = sqlBuilder.Append(';');
Expand Down Expand Up @@ -989,7 +995,7 @@ public override Core.Db.User GetUser(string username)
}
}

public override Core.Db.User GetUserById(string userId)
public override Core.Db.User GetUserById(string id)
{
lock (Padlock)
{
Expand All @@ -1004,7 +1010,7 @@ public override Core.Db.User GetUserById(string userId)
+ User.COLUMN_NAME_CREATED_ON + ", "
+ User.COLUMN_NAME_MODIFIED_ON
+ " FROM " + Core.Db.User.DOCUMENT_NAME
+ " WHERE " + User.COLUMN_NAME_ID + " = '" + int.Parse(userId) + "'"
+ " WHERE " + User.COLUMN_NAME_ID + " = '" + int.Parse(id) + "'"
+ ";", conn);

using var reader = command.ExecuteReader();
Expand Down
9 changes: 2 additions & 7 deletions src/netcore/Wexflow.Core.Db.Firebird/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@

namespace Wexflow.Core.Db.Firebird
{
public class Helper
public class Helper(string connectionString)
{
private readonly string _connectionString;

public Helper(string connectionString)
{
_connectionString = connectionString;
}
private readonly string _connectionString = connectionString;

public void CreateTableIfNotExists(string tableName, string tableStruct)
{
Expand Down
Loading

0 comments on commit 62701fe

Please sign in to comment.