Skip to content

Commit

Permalink
more changes for sonar cloud
Browse files Browse the repository at this point in the history
Signed-off-by: Neil South <[email protected]>
  • Loading branch information
neildsouth committed Feb 8, 2024
1 parent 139384a commit f305fec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/WorkflowManager/Logging/Log.600000.Dicom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static partial class Log
[LoggerMessage(EventId = 600007, Level = LogLevel.Error, Message = "Failed to get DICOM metadata from bucket {bucketId}. Payload: {payloadId}")]
public static partial void FailedToGetDicomMetadataFromBucket(this ILogger logger, string payloadId, string bucketId, Exception ex);

[LoggerMessage(EventId = 600000, Level = LogLevel.Error, Message = "Failed to get DICOM tag {dicomTag} from dictionary")]
[LoggerMessage(EventId = 600008, Level = LogLevel.Error, Message = "Failed to get DICOM tag {dicomTag} from dictionary")]
public static partial void FailedToGetDicomTagFromDictoionary(this ILogger logger, string dicomTag, Exception ex);
}
}
2 changes: 1 addition & 1 deletion src/WorkflowManager/Storage/Services/DicomService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public async Task<IEnumerable<string>> GetDicomPathsForTaskAsync(string outputDi

var dicomFiles = files?.Where(f => f.FilePath.EndsWith(".dcm"));

return dicomFiles?.Select(d => d.FilePath)?.ToList() ?? [];
return dicomFiles?.Select(d => d.FilePath) ?? [];
}

public async Task<string> GetAnyValueAsync(string keyId, string payloadId, string bucketId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private async Task ProcessArtifactReceivedOutputs(ArtifactsReceivedEvent message
private async Task<bool> AllRequiredArtifactsReceivedAsync(ArtifactsReceivedEvent message, WorkflowInstance workflowInstance,
string taskId, string workflowInstanceId, WorkflowRevision workflowTemplate, IEnumerable<ArtifactType> receivedArtifacts)
{
var taskExecution = workflowInstance.Tasks.FirstOrDefault(t => t.TaskId == taskId);
var taskExecution = Array.Find<TaskExecution>([.. workflowInstance.Tasks], t => t.TaskId == taskId);

if (taskExecution is null)
{
Expand All @@ -326,7 +326,8 @@ await _workflowInstanceRepository.UpdateTaskStatusAsync(workflowInstanceId, task
private string[] GetTasksWithAllInputs(WorkflowRevision workflowTemplate, string currentTaskId, IEnumerable<ArtifactType> artifactsRecieved)
{
var excutableTasks = new List<String>();
var task = workflowTemplate.Workflow!.Tasks.FirstOrDefault(t => t.Id == currentTaskId);

var task = Array.Find<TaskObject>(workflowTemplate.Workflow!.Tasks, t => t.Id == currentTaskId);
if (task is null)
{
_logger.ErrorFindingTask(currentTaskId);
Expand Down Expand Up @@ -354,8 +355,9 @@ private string[] GetTasksWithAllInputs(WorkflowRevision workflowTemplate, string
private Dictionary<ArtifactType, bool> GetTasksInput(WorkflowRevision workflowTemplate, string taskId, string previousTaskId)
{
var results = new Dictionary<ArtifactType, bool>();
var task = workflowTemplate.Workflow!.Tasks.FirstOrDefault(t => t.Id == taskId);
var previousTask = workflowTemplate.Workflow!.Tasks.FirstOrDefault(t => t.Id == previousTaskId);

var task = Array.Find<TaskObject>(workflowTemplate.Workflow!.Tasks, t => t.Id == taskId);
var previousTask = Array.Find<TaskObject>(workflowTemplate.Workflow!.Tasks, t => t.Id == previousTaskId);
if (previousTask is null || task is null)
{
_logger.ErrorFindingTask(taskId);
Expand Down Expand Up @@ -969,6 +971,8 @@ private async Task<List<TaskExecution>> CreateTaskDestinations(
string taskId,
IEnumerable<ArtifactType> receivedArtifacts)
{
_ = workflow ?? throw new ArgumentNullException(nameof(workflow));

var currentTaskDestinations = workflow.Workflow?.Tasks?.SingleOrDefault(t => t.Id == taskId)?.TaskDestinations;

var newTaskExecutions = new List<TaskExecution>();
Expand All @@ -981,7 +985,7 @@ private async Task<List<TaskExecution>> CreateTaskDestinations(
foreach (var taskDest in currentTaskDestinations)
{
// have we got all inputs we need ?
var neededInputs = GetTasksInput(workflow, taskDest.Name, taskId).Where(t => t.Value);
var neededInputs = GetTasksInput(workflow!, taskDest.Name, taskId).Where(t => t.Value);
var remainingManditory = neededInputs.Where(i => receivedArtifacts.Any(a => a == i.Key) is false);
if (remainingManditory.Count() is not 0)
{
Expand Down

0 comments on commit f305fec

Please sign in to comment.