From de2499bec770417da84c99b006c29c8c3e6b68e9 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Mon, 23 Dec 2024 13:11:47 +0530 Subject: [PATCH] GSAGH-550: sonar cloud suggestion --- GsaGH/Helpers/Assembly/ModelAssembly.cs | 2 -- GsaGH/Helpers/TaskHelper.cs | 2 +- GsaGH/Parameters/4_Analysis/GsaAnalysisTask.cs | 10 +++++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/GsaGH/Helpers/Assembly/ModelAssembly.cs b/GsaGH/Helpers/Assembly/ModelAssembly.cs index 7d362a878..ce4c73c78 100644 --- a/GsaGH/Helpers/Assembly/ModelAssembly.cs +++ b/GsaGH/Helpers/Assembly/ModelAssembly.cs @@ -29,7 +29,6 @@ internal partial class ModelAssembly { private GsaIntDictionary _axes; private GsaGuidIntListDictionary _elements; private GsaIntDictionary _gridLines; - private GsaModel _gsaModel; private GsaGuidDictionary _lists; private ConcurrentDictionary> memberElementRelationship; private GsaGuidDictionary _members; @@ -595,7 +594,6 @@ private void ReportWarningFromAddingGridSurfacesOrList(string mes, string troubl private void SetupModel(GsaModel model, LengthUnit unit) { model ??= new GsaModel(); _model = model.ApiModel; - _gsaModel = model; _unit = unit; _model.UiUnits().LengthLarge = UnitMapping.GetApiUnit(_unit); UiUnits units = _model.UiUnits(); diff --git a/GsaGH/Helpers/TaskHelper.cs b/GsaGH/Helpers/TaskHelper.cs index ca8d5e5b7..9889d1af7 100644 --- a/GsaGH/Helpers/TaskHelper.cs +++ b/GsaGH/Helpers/TaskHelper.cs @@ -23,7 +23,7 @@ public static void AddAnalysisTask(GsaAnalysisTask task, GsaModel model) { public static void ImportAnalysisTask(GsaAnalysisTask task, ref GsaModel model) { ReadOnlyDictionary existingTasks = model.ApiModel.AnalysisTasks(); if (task != null && !existingTasks.Keys.Contains(task.Id)) { - int highestTask = existingTasks.Count(); + int highestTask = existingTasks.Count; var analysisCases = new Dictionary(); foreach (GsaAnalysisCase analysisCase in task.Cases) { analysisCases.Add(analysisCase.Id, new AnalysisCase(analysisCase.Name, analysisCase.Definition)); diff --git a/GsaGH/Parameters/4_Analysis/GsaAnalysisTask.cs b/GsaGH/Parameters/4_Analysis/GsaAnalysisTask.cs index a9b770b0a..cd6416dd5 100644 --- a/GsaGH/Parameters/4_Analysis/GsaAnalysisTask.cs +++ b/GsaGH/Parameters/4_Analysis/GsaAnalysisTask.cs @@ -7,6 +7,8 @@ using GsaGH.Helpers; +using Rhino.Commands; + namespace GsaGH.Parameters { /// /// An analysis task is a package of work for the solver. Thus we can have a static analysis task, a modal analysis task, etc. Each analysis task has one or more analysis case(s). The distinction is that the cases corresponds to result sets and define items such as loading (in the static case) while the task describes what the solver has to do. @@ -33,11 +35,9 @@ internal GsaAnalysisTask(AnalysisTask task, Model model) { } private void CreateCases(Model model) { ReadOnlyDictionary analysisCases = model.AnalysisCases(); - foreach (int caseId in ApiTask.Cases) { - if (analysisCases.ContainsKey(caseId)) { - AnalysisCase analysisCase = model.AnalysisCases()[caseId]; - Cases.Add(new GsaAnalysisCase(caseId, analysisCase.Name, analysisCase.Description)); - } + foreach (int caseId in ApiTask.Cases.Where(x => analysisCases.ContainsKey(x))) { + AnalysisCase analysisCase = model.AnalysisCases()[caseId]; + Cases.Add(new GsaAnalysisCase(caseId, analysisCase.Name, analysisCase.Description)); } } public override string ToString() {