diff --git a/.editorconfig b/.editorconfig index 3e0b7bd9..c32da1c3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -62,3 +62,132 @@ dotnet_diagnostic.IDE0160.severity = silent dotnet_diagnostic.IDE0022.severity = silent dotnet_diagnostic.CA1310.severity = silent + +dotnet_diagnostic.CA1720.severity = silent + +dotnet_diagnostic.IDE0210.severity = silent + +dotnet_diagnostic.CA1307.severity = silent + +dotnet_diagnostic.CA1863.severity = silent + +dotnet_diagnostic.CA1859.severity = silent + +[*.cs] +#### Styles de nommage #### + +# Règles de nommage + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Spécifications de symboles + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Styles de nommage + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_prefer_switch_expression = true:suggestion +csharp_style_prefer_pattern_matching = true:silent +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_extended_property_pattern = true:suggestion +csharp_prefer_simple_using_statement = true:suggestion +csharp_prefer_braces = true:silent +csharp_style_namespace_declarations = block_scoped:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = true:silent + +[*.vb] +#### Styles de nommage #### + +# Règles de nommage + +dotnet_naming_rule.interface_should_be_commence_par_i.severity = suggestion +dotnet_naming_rule.interface_should_be_commence_par_i.symbols = interface +dotnet_naming_rule.interface_should_be_commence_par_i.style = commence_par_i + +dotnet_naming_rule.types_should_be_casse_pascal.severity = suggestion +dotnet_naming_rule.types_should_be_casse_pascal.symbols = types +dotnet_naming_rule.types_should_be_casse_pascal.style = casse_pascal + +dotnet_naming_rule.membres_autres_que_des_champs_should_be_casse_pascal.severity = suggestion +dotnet_naming_rule.membres_autres_que_des_champs_should_be_casse_pascal.symbols = membres_autres_que_des_champs +dotnet_naming_rule.membres_autres_que_des_champs_should_be_casse_pascal.style = casse_pascal + +# Spécifications de symboles + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.membres_autres_que_des_champs.applicable_kinds = property, event, method +dotnet_naming_symbols.membres_autres_que_des_champs.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected +dotnet_naming_symbols.membres_autres_que_des_champs.required_modifiers = + +# Styles de nommage + +dotnet_naming_style.commence_par_i.required_prefix = I +dotnet_naming_style.commence_par_i.required_suffix = +dotnet_naming_style.commence_par_i.word_separator = +dotnet_naming_style.commence_par_i.capitalization = pascal_case + +dotnet_naming_style.casse_pascal.required_prefix = +dotnet_naming_style.casse_pascal.required_suffix = +dotnet_naming_style.casse_pascal.word_separator = +dotnet_naming_style.casse_pascal.capitalization = pascal_case + +dotnet_naming_style.casse_pascal.required_prefix = +dotnet_naming_style.casse_pascal.required_suffix = +dotnet_naming_style.casse_pascal.word_separator = +dotnet_naming_style.casse_pascal.capitalization = pascal_case + +[*.{cs,vb}] +tab_width = 4 +indent_size = 4 \ No newline at end of file diff --git a/Wexflow.sln b/Wexflow.sln index ee60139c..9272b6cd 100644 --- a/Wexflow.sln +++ b/Wexflow.sln @@ -572,6 +572,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wexflow.Scripts.LiteDB", "s EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{CBF733C9-E197-44FA-837B-1FE4F5923FD9}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig .github\azure-pipelines.yml = .github\azure-pipelines.yml EndProjectSection EndProject diff --git a/src/net/Wexflow.Scripts.RunAllWorkflows/Program.cs b/src/net/Wexflow.Scripts.RunAllWorkflows/Program.cs index 42f1104a..c15eeb46 100644 --- a/src/net/Wexflow.Scripts.RunAllWorkflows/Program.cs +++ b/src/net/Wexflow.Scripts.RunAllWorkflows/Program.cs @@ -4,9 +4,9 @@ namespace Wexflow.Scripts.RunAllWorkflows { - internal class Program + internal sealed class Program { - static void Main() + private static void Main() { try { diff --git a/src/net/Wexflow.Tasks.FilesDiff/FilesDiff.cs b/src/net/Wexflow.Tasks.FilesDiff/FilesDiff.cs index 52a96219..b65ac2d2 100644 --- a/src/net/Wexflow.Tasks.FilesDiff/FilesDiff.cs +++ b/src/net/Wexflow.Tasks.FilesDiff/FilesDiff.cs @@ -88,6 +88,8 @@ private void CheckFiles() case ChangeType.Modified: sw.Write("~ "); break; + case ChangeType.Unchanged: + case ChangeType.Imaginary: default: sw.Write(" "); break; diff --git a/src/net/Wexflow.Tasks.Ftp/Ftp.cs b/src/net/Wexflow.Tasks.Ftp/Ftp.cs index d9c6d6c3..e5d4538c 100644 --- a/src/net/Wexflow.Tasks.Ftp/Ftp.cs +++ b/src/net/Wexflow.Tasks.Ftp/Ftp.cs @@ -53,6 +53,8 @@ public Ftp(XElement xe, Workflow wf) : base(xe, wf) var passphrase = GetSetting("passphrase", string.Empty); _plugin = new PluginSftp(this, server, port, user, password, path, privateKeyPath, passphrase); break; + default: + break; } _cmd = (FtpCommad)Enum.Parse(typeof(FtpCommad), GetSetting("command"), true); _retryCount = int.Parse(GetSetting("retryCount", "3")); @@ -173,6 +175,7 @@ private bool DoWork(ref bool atLeastOneSuccess) _plugin.Delete(file); _ = Workflow.FilesPerTask[file.TaskId].Remove(file); break; + case FtpCommad.List: default: break; } diff --git a/src/netcore/Wexflow.Clients.CommandLine/Program.cs b/src/netcore/Wexflow.Clients.CommandLine/Program.cs index cecfd7e4..2c6d62d6 100644 --- a/src/netcore/Wexflow.Clients.CommandLine/Program.cs +++ b/src/netcore/Wexflow.Clients.CommandLine/Program.cs @@ -9,7 +9,7 @@ namespace Wexflow.Clients.CommandLine { - internal class Program + internal sealed class Program { private enum Operation { @@ -22,7 +22,7 @@ private enum Operation } // ReSharper disable once ClassNeverInstantiated.Local - private class Options + private sealed class Options { [Option('o', "operation", Required = true, HelpText = "start|suspend|resume|stop|approve|reject")] // ReSharper disable once UnusedAutoPropertyAccessor.Local diff --git a/src/netcore/Wexflow.Core.Service.Contracts/WorkflowInfo.cs b/src/netcore/Wexflow.Core.Service.Contracts/WorkflowInfo.cs index d86153a8..85a37b36 100644 --- a/src/netcore/Wexflow.Core.Service.Contracts/WorkflowInfo.cs +++ b/src/netcore/Wexflow.Core.Service.Contracts/WorkflowInfo.cs @@ -66,5 +66,45 @@ public int CompareTo(object obj) var wfi = (WorkflowInfo)obj; return wfi.Id.CompareTo(Id); } + + public override bool Equals(object obj) + { + return ReferenceEquals(this, obj) || (obj is null ? false : throw new NotImplementedException()); + } + + public override int GetHashCode() + { + throw new NotImplementedException(); + } + + public static bool operator ==(WorkflowInfo left, WorkflowInfo right) + { + return left is null ? right is null : left.Equals(right); + } + + public static bool operator !=(WorkflowInfo left, WorkflowInfo right) + { + return !(left == right); + } + + public static bool operator <(WorkflowInfo left, WorkflowInfo right) + { + return left is null ? right is not null : left.CompareTo(right) < 0; + } + + public static bool operator <=(WorkflowInfo left, WorkflowInfo right) + { + return left is null || left.CompareTo(right) <= 0; + } + + public static bool operator >(WorkflowInfo left, WorkflowInfo right) + { + return left is not null && left.CompareTo(right) > 0; + } + + public static bool operator >=(WorkflowInfo left, WorkflowInfo right) + { + return left is null ? right is null : left.CompareTo(right) >= 0; + } } } diff --git a/src/netcore/Wexflow.Core/PollingFileSystemWatcher/FileChangeList.cs b/src/netcore/Wexflow.Core/PollingFileSystemWatcher/FileChangeList.cs index 4d98ec3c..c49c7445 100644 --- a/src/netcore/Wexflow.Core/PollingFileSystemWatcher/FileChangeList.cs +++ b/src/netcore/Wexflow.Core/PollingFileSystemWatcher/FileChangeList.cs @@ -70,7 +70,7 @@ public readonly FileChange[] ToArray() return result; } - private class Comparer : IComparer + private sealed class Comparer : IComparer { public static readonly IComparer ColumnDefault = new Comparer(); diff --git a/src/netcore/Wexflow.Core/PollingFileSystemWatcher/FileSystemChangesEnumerator.cs b/src/netcore/Wexflow.Core/PollingFileSystemWatcher/FileSystemChangesEnumerator.cs index ef3bb400..010ab428 100644 --- a/src/netcore/Wexflow.Core/PollingFileSystemWatcher/FileSystemChangesEnumerator.cs +++ b/src/netcore/Wexflow.Core/PollingFileSystemWatcher/FileSystemChangesEnumerator.cs @@ -8,7 +8,7 @@ namespace Wexflow.Core.PollingFileSystemWatcher { - internal class FileSystemChangeEnumerator : FileSystemEnumerator + internal sealed class FileSystemChangeEnumerator : FileSystemEnumerator { private FileChangeList _changes; private string _currentDirectory; diff --git a/src/netcore/Wexflow.Core/PollingFileSystemWatcher/PathToFileStateHashtable.cs b/src/netcore/Wexflow.Core/PollingFileSystemWatcher/PathToFileStateHashtable.cs index a1007e41..494b631a 100644 --- a/src/netcore/Wexflow.Core/PollingFileSystemWatcher/PathToFileStateHashtable.cs +++ b/src/netcore/Wexflow.Core/PollingFileSystemWatcher/PathToFileStateHashtable.cs @@ -13,7 +13,7 @@ namespace Wexflow.Core.PollingFileSystemWatcher // It has optimized Equals and GetHasCode // It implements removals by marking values as "removed" (Path==null) and then garbage collecting them when table is resized [Serializable] - internal class PathToFileStateHashtable(int capacity = 4) + internal sealed class PathToFileStateHashtable(int capacity = 4) { private int _nextValuesIndex = 1; // the first Values slot is reserved so that default(Bucket) knows that it is not pointing to any value. public FileState[] Values { get; private set; } = new FileState[capacity]; diff --git a/src/netcore/Wexflow.Core/PollingFileSystemWatcher/PollingFileSystemWatcher.cs b/src/netcore/Wexflow.Core/PollingFileSystemWatcher/PollingFileSystemWatcher.cs index 318de0b2..b4288400 100644 --- a/src/netcore/Wexflow.Core/PollingFileSystemWatcher/PollingFileSystemWatcher.cs +++ b/src/netcore/Wexflow.Core/PollingFileSystemWatcher/PollingFileSystemWatcher.cs @@ -90,10 +90,7 @@ public long PollingInterval public void Start() { - if (_disposed) - { - throw new ObjectDisposedException(nameof(PollingFileSystemWatcher)); - } + ObjectDisposedException.ThrowIf(_disposed, nameof(PollingFileSystemWatcher)); if (_started) { diff --git a/src/netcore/Wexflow.Scripts.Firebird/Program.cs b/src/netcore/Wexflow.Scripts.Firebird/Program.cs index bbe23c5d..2d256f3a 100644 --- a/src/netcore/Wexflow.Scripts.Firebird/Program.cs +++ b/src/netcore/Wexflow.Scripts.Firebird/Program.cs @@ -4,7 +4,7 @@ namespace Wexflow.Scripts.Firebird { - internal class Program + internal sealed class Program { private static void Main() { diff --git a/src/netcore/Wexflow.Scripts.LiteDB/Program.cs b/src/netcore/Wexflow.Scripts.LiteDB/Program.cs index 3ff5d7fb..bab4f6b4 100644 --- a/src/netcore/Wexflow.Scripts.LiteDB/Program.cs +++ b/src/netcore/Wexflow.Scripts.LiteDB/Program.cs @@ -4,7 +4,7 @@ namespace Wexflow.Scripts.LiteDB { - internal class Program + internal sealed class Program { private static IConfiguration? _config; diff --git a/src/netcore/Wexflow.Scripts.MariaDB/Program.cs b/src/netcore/Wexflow.Scripts.MariaDB/Program.cs index c0ac16c8..f815a39d 100644 --- a/src/netcore/Wexflow.Scripts.MariaDB/Program.cs +++ b/src/netcore/Wexflow.Scripts.MariaDB/Program.cs @@ -4,7 +4,7 @@ namespace Wexflow.Scripts.MariaDB { - internal class Program + internal sealed class Program { private static void Main() { diff --git a/src/netcore/Wexflow.Scripts.MongoDB/Program.cs b/src/netcore/Wexflow.Scripts.MongoDB/Program.cs index b2bac614..f4a42a45 100644 --- a/src/netcore/Wexflow.Scripts.MongoDB/Program.cs +++ b/src/netcore/Wexflow.Scripts.MongoDB/Program.cs @@ -5,7 +5,7 @@ namespace Wexflow.Scripts.MongoDB { - internal class Program + internal sealed class Program { private static void Main() { diff --git a/src/netcore/Wexflow.Scripts.MySQL/Program.cs b/src/netcore/Wexflow.Scripts.MySQL/Program.cs index cf55cd61..740f938e 100644 --- a/src/netcore/Wexflow.Scripts.MySQL/Program.cs +++ b/src/netcore/Wexflow.Scripts.MySQL/Program.cs @@ -4,7 +4,7 @@ namespace Wexflow.Scripts.MySQL { - internal class Program + internal sealed class Program { private static void Main() { diff --git a/src/netcore/Wexflow.Scripts.Oracle/Program.cs b/src/netcore/Wexflow.Scripts.Oracle/Program.cs index 14ccdbdf..83cd3154 100644 --- a/src/netcore/Wexflow.Scripts.Oracle/Program.cs +++ b/src/netcore/Wexflow.Scripts.Oracle/Program.cs @@ -4,7 +4,7 @@ namespace Wexflow.Scripts.Oracle { - internal class Program + internal sealed class Program { private static void Main() { diff --git a/src/netcore/Wexflow.Scripts.PostgreSQL/Program.cs b/src/netcore/Wexflow.Scripts.PostgreSQL/Program.cs index 86163756..710c492a 100644 --- a/src/netcore/Wexflow.Scripts.PostgreSQL/Program.cs +++ b/src/netcore/Wexflow.Scripts.PostgreSQL/Program.cs @@ -4,7 +4,7 @@ namespace Wexflow.Scripts.PostgreSQL { - internal class Program + internal sealed class Program { private static void Main() { diff --git a/src/netcore/Wexflow.Scripts.RavenDB/Program.cs b/src/netcore/Wexflow.Scripts.RavenDB/Program.cs index 530f071e..6c6f3581 100644 --- a/src/netcore/Wexflow.Scripts.RavenDB/Program.cs +++ b/src/netcore/Wexflow.Scripts.RavenDB/Program.cs @@ -5,7 +5,7 @@ namespace Wexflow.Scripts.RavenDB { - internal class Program + internal sealed class Program { private static void Main() { diff --git a/src/netcore/Wexflow.Scripts.SQLServer/Program.cs b/src/netcore/Wexflow.Scripts.SQLServer/Program.cs index b0f20d3b..e5900517 100644 --- a/src/netcore/Wexflow.Scripts.SQLServer/Program.cs +++ b/src/netcore/Wexflow.Scripts.SQLServer/Program.cs @@ -4,7 +4,7 @@ namespace Wexflow.Scripts.SQLServer { - internal class Program + internal sealed class Program { private static void Main() { diff --git a/src/netcore/Wexflow.Scripts.SQLite/Program.cs b/src/netcore/Wexflow.Scripts.SQLite/Program.cs index 36ae7c35..d8388333 100644 --- a/src/netcore/Wexflow.Scripts.SQLite/Program.cs +++ b/src/netcore/Wexflow.Scripts.SQLite/Program.cs @@ -5,7 +5,7 @@ namespace Wexflow.Scripts.SQLite { - internal class Program + internal sealed class Program { private static IConfiguration _config; diff --git a/src/netcore/Wexflow.Server/Contracts/WorkflowInfo.cs b/src/netcore/Wexflow.Server/Contracts/WorkflowInfo.cs index 8af1b535..04c6bb54 100644 --- a/src/netcore/Wexflow.Server/Contracts/WorkflowInfo.cs +++ b/src/netcore/Wexflow.Server/Contracts/WorkflowInfo.cs @@ -100,5 +100,45 @@ public int CompareTo(object obj) var wfi = (WorkflowInfo)obj; return wfi.Id.CompareTo(Id); } + + public override bool Equals(object obj) + { + return ReferenceEquals(this, obj) || (obj is null ? false : throw new NotImplementedException()); + } + + public override int GetHashCode() + { + throw new NotImplementedException(); + } + + public static bool operator ==(WorkflowInfo left, WorkflowInfo right) + { + return left is null ? right is null : left.Equals(right); + } + + public static bool operator !=(WorkflowInfo left, WorkflowInfo right) + { + return !(left == right); + } + + public static bool operator <(WorkflowInfo left, WorkflowInfo right) + { + return left is null ? right is not null : left.CompareTo(right) < 0; + } + + public static bool operator <=(WorkflowInfo left, WorkflowInfo right) + { + return left is null || left.CompareTo(right) <= 0; + } + + public static bool operator >(WorkflowInfo left, WorkflowInfo right) + { + return left is not null && left.CompareTo(right) > 0; + } + + public static bool operator >=(WorkflowInfo left, WorkflowInfo right) + { + return left is null ? right is null : left.CompareTo(right) >= 0; + } } } diff --git a/src/netcore/Wexflow.Server/WexflowServer.cs b/src/netcore/Wexflow.Server/WexflowServer.cs index 7bf282b2..9f7acebf 100644 --- a/src/netcore/Wexflow.Server/WexflowServer.cs +++ b/src/netcore/Wexflow.Server/WexflowServer.cs @@ -193,7 +193,8 @@ private static void OnWorkflowChanged(object source, PollingFileSystemEventArgs Logger.ErrorFormat("Error while deleting the workflow {0}", ex, path); } break; - + case WatcherChangeTypes.Renamed: + case WatcherChangeTypes.All: default: break; } diff --git a/src/netcore/Wexflow.Tasks.FileSystemWatcher/FileSystemWatcher.cs b/src/netcore/Wexflow.Tasks.FileSystemWatcher/FileSystemWatcher.cs index 7a6a8214..5c00b096 100644 --- a/src/netcore/Wexflow.Tasks.FileSystemWatcher/FileSystemWatcher.cs +++ b/src/netcore/Wexflow.Tasks.FileSystemWatcher/FileSystemWatcher.cs @@ -264,7 +264,8 @@ private void OnChanged(object source, PollingFileSystemEventArgs e) ErrorFormat("An error while updating PollingFileSystemWatcher.OnDeleted database entry.", ex); } break; - + case WatcherChangeTypes.Renamed: + case WatcherChangeTypes.All: default: break; } diff --git a/src/netcore/Wexflow.Tasks.FilesDiff/FilesDiff.cs b/src/netcore/Wexflow.Tasks.FilesDiff/FilesDiff.cs index 719bda4f..5b7ea00a 100644 --- a/src/netcore/Wexflow.Tasks.FilesDiff/FilesDiff.cs +++ b/src/netcore/Wexflow.Tasks.FilesDiff/FilesDiff.cs @@ -71,6 +71,8 @@ private void CheckFiles() case ChangeType.Modified: sw.Write("~ "); break; + case ChangeType.Unchanged: + case ChangeType.Imaginary: default: sw.Write(" "); break; diff --git a/src/netcore/Wexflow.Tasks.Ftp/Ftp.cs b/src/netcore/Wexflow.Tasks.Ftp/Ftp.cs index 4fdd86a9..017487e3 100644 --- a/src/netcore/Wexflow.Tasks.Ftp/Ftp.cs +++ b/src/netcore/Wexflow.Tasks.Ftp/Ftp.cs @@ -168,6 +168,7 @@ private bool DoWork(ref bool atLeastOneSuccess) _plugin.Delete(file); _ = Workflow.FilesPerTask[file.TaskId].Remove(file); break; + case FtpCommad.List: default: break; } diff --git a/src/netcore/Wexflow.Tasks.Md5/Md5.cs b/src/netcore/Wexflow.Tasks.Md5/Md5.cs index 2e467a61..c4abdaac 100644 --- a/src/netcore/Wexflow.Tasks.Md5/Md5.cs +++ b/src/netcore/Wexflow.Tasks.Md5/Md5.cs @@ -82,6 +82,7 @@ public override TaskStatus Run() private static string GetMd5(string filePath) { StringBuilder sb = new(); +#pragma warning disable CA5351 // Ne pas utiliser d'algorithmes de chiffrement cassés using (var md5 = MD5.Create()) { using var stream = File.OpenRead(filePath); @@ -92,6 +93,7 @@ private static string GetMd5(string filePath) _ = sb.Append(bt.ToString("x2")); } } +#pragma warning restore CA5351 // Ne pas utiliser d'algorithmes de chiffrement cassés return sb.ToString(); } } diff --git a/src/netcore/Wexflow.Tasks.Movedir/Movedir.cs b/src/netcore/Wexflow.Tasks.Movedir/Movedir.cs index f929403f..8325bcd8 100644 --- a/src/netcore/Wexflow.Tasks.Movedir/Movedir.cs +++ b/src/netcore/Wexflow.Tasks.Movedir/Movedir.cs @@ -65,7 +65,7 @@ public override TaskStatus Run() return new TaskStatus(succeeded ? Status.Success : Status.Error, false); } - private void DeleteRec(string dir) + private static void DeleteRec(string dir) { foreach (var file in Directory.GetFiles(dir)) { diff --git a/src/netcore/Wexflow.Tasks.Sha1/Sha1.cs b/src/netcore/Wexflow.Tasks.Sha1/Sha1.cs index ee9bb264..9493f72b 100644 --- a/src/netcore/Wexflow.Tasks.Sha1/Sha1.cs +++ b/src/netcore/Wexflow.Tasks.Sha1/Sha1.cs @@ -82,7 +82,9 @@ public override TaskStatus Run() private static string GetSha1(string filePath) { using var stream = File.OpenRead(filePath); +#pragma warning disable CA5350 // Ne pas utiliser d'algorithmes de chiffrement faibles using var alg = SHA1.Create(); +#pragma warning restore CA5350 // Ne pas utiliser d'algorithmes de chiffrement faibles StringBuilder sb = new(); var hashValue = alg.ComputeHash(stream); diff --git a/src/netcore/Wexflow.Tasks.Sha256/Sha256.cs b/src/netcore/Wexflow.Tasks.Sha256/Sha256.cs index fc2ccbbe..61df455f 100644 --- a/src/netcore/Wexflow.Tasks.Sha256/Sha256.cs +++ b/src/netcore/Wexflow.Tasks.Sha256/Sha256.cs @@ -34,7 +34,7 @@ public override TaskStatus Run() { try { - var sha1 = GetSha1(file.Path); + var sha1 = GetSha256(file.Path); xdoc.Root?.Add(new XElement("File", new XAttribute("path", file.Path), new XAttribute("name", file.FileName), @@ -79,7 +79,7 @@ public override TaskStatus Run() return new TaskStatus(status, false); } - private static string GetSha1(string filePath) + private static string GetSha256(string filePath) { using var stream = File.OpenRead(filePath); using var alg = SHA256.Create(); diff --git a/src/netcore/Wexflow.Tasks.Sha512/Sha512.cs b/src/netcore/Wexflow.Tasks.Sha512/Sha512.cs index 89a58042..75fe7f62 100644 --- a/src/netcore/Wexflow.Tasks.Sha512/Sha512.cs +++ b/src/netcore/Wexflow.Tasks.Sha512/Sha512.cs @@ -34,7 +34,7 @@ public override TaskStatus Run() { try { - var sha1 = GetSha1(file.Path); + var sha1 = GetSha512(file.Path); xdoc.Root?.Add(new XElement("File", new XAttribute("path", file.Path), new XAttribute("name", file.FileName), @@ -79,7 +79,7 @@ public override TaskStatus Run() return new TaskStatus(status, false); } - private static string GetSha1(string filePath) + private static string GetSha512(string filePath) { using var stream = File.OpenRead(filePath); using var alg = SHA512.Create(); diff --git a/tests/netcore/Wexflow.NetCore.Tests/FilesInfo.cs b/tests/netcore/Wexflow.NetCore.Tests/FilesInfo.cs index fc50ec63..1bb3d13e 100644 --- a/tests/netcore/Wexflow.NetCore.Tests/FilesInfo.cs +++ b/tests/netcore/Wexflow.NetCore.Tests/FilesInfo.cs @@ -24,13 +24,14 @@ public void TestInitialize() Helper.DeleteFiles(FilesInfoFolder); FileInfo info1 = new(File1); FileInfo info2 = new(File2); - _expectedResult = string.Format(_expectedResult - , info1.CreationTime.ToString(dateFormat) - , info1.LastWriteTime.ToString(dateFormat) - , info1.LastAccessTime.ToString(dateFormat) - , info2.CreationTime.ToString(dateFormat) - , info2.LastWriteTime.ToString(dateFormat) - , info2.LastAccessTime.ToString(dateFormat)); + _expectedResult = string.Format( + _expectedResult, + info1.CreationTime.ToString(dateFormat), + info1.LastWriteTime.ToString(dateFormat), + info1.LastAccessTime.ToString(dateFormat), + info2.CreationTime.ToString(dateFormat), + info2.LastWriteTime.ToString(dateFormat), + info2.LastAccessTime.ToString(dateFormat)); } [TestCleanup]