Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed SonarCloud task void issues related #664

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 52 additions & 97 deletions CDP4Composition/Mvvm/BrowserViewModelBase.cs

Large diffs are not rendered by default.

26 changes: 23 additions & 3 deletions CDP4Composition/OfficeRibbon/RibbonPart.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RibbonPart.cs" company="RHEA System S.A.">
// Copyright (c) 2015 RHEA System S.A.
// Copyright (c) 2015-2021 RHEA System S.A.
//
// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Ahmed Abulwafa Ahmed
//
// This file is part of CDP4-IME Community Edition.
// The CDP4-IME Community Edition is the RHEA Concurrent Design Desktop Application and Excel Integration
// compliant with ECSS-E-TM-10-25 Annex A and Annex C.
//
// The CDP4-IME Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or any later version.
//
// The CDP4-IME Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------------------------

namespace CDP4Composition
{
Expand All @@ -15,6 +34,7 @@ namespace CDP4Composition
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

using CDP4Composition.Navigation;
using CDP4Composition.Navigation.Interfaces;
using CDP4Composition.PluginSettingService;
Expand Down Expand Up @@ -142,7 +162,7 @@ public List<string> ControlIdentifiers
public virtual Task OnAction(string ribbonControlId, string ribbonControlTag = "")
{
logger.Debug("The OnAction method of the {0} is not overriden, therefore the OnAction method only shows this log message", this.GetType());
return null;
return default;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RuleVerificationService.cs" company="RHEA System S.A.">
// Copyright (c) 2015 RHEA System S.A.
// Copyright (c) 2015-2021 RHEA System S.A.
//
// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Ahmed Abulwafa Ahmed
//
// This file is part of CDP4-IME Community Edition.
// The CDP4-IME Community Edition is the RHEA Concurrent Design Desktop Application and Excel Integration
// compliant with ECSS-E-TM-10-25 Annex A and Annex C.
//
// The CDP4-IME Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or any later version.
//
// The CDP4-IME Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------------------------

namespace CDP4Composition.Services
{
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using CDP4Common;

using CDP4Common.CommonData;
using CDP4Common.EngineeringModelData;
using CDP4Common.Exceptions;
using CDP4Common.SiteDirectoryData;

using CDP4Dal;
using CDP4Dal.Events;
using CDP4Dal.Operations;

using NLog;

/// <summary>
Expand Down Expand Up @@ -117,26 +138,24 @@ public void Execute(ISession session, RuleVerificationList verificationList)
{
if (session == null)
{
throw new ArgumentNullException("session", "The session may not be null");
throw new ArgumentNullException(nameof(session), "The session may not be null");
}

if (verificationList == null)
{
throw new ArgumentNullException("verificationList", "The verificationList may not be null");
throw new ArgumentNullException(nameof(verificationList), "The verificationList may not be null");
}

foreach (var ruleVerification in verificationList.RuleVerification)
{
var builtInRuleVerification = ruleVerification as BuiltInRuleVerification;
if (builtInRuleVerification != null && builtInRuleVerification.IsActive)
switch (ruleVerification)
{
this.Execute(session, builtInRuleVerification, verificationList);
}

var userRuleVerification = ruleVerification as UserRuleVerification;
if (userRuleVerification != null && userRuleVerification.IsActive)
{
this.Execute(session, userRuleVerification, verificationList);
case BuiltInRuleVerification builtInRuleVerification when builtInRuleVerification.IsActive:
this.Execute(session, builtInRuleVerification, verificationList);
break;
case UserRuleVerification userRuleVerification when userRuleVerification.IsActive:
this.Execute(session, userRuleVerification, verificationList);
break;
}
}
}
Expand All @@ -159,7 +178,7 @@ private void Execute(ISession session, BuiltInRuleVerification builtInRuleVerifi

if (iteration == null)
{
throw new ContainmentException(string.Format("The container Iteration of the RuleVerificationList {0} has not been set", container.Iid));
throw new ContainmentException($"The container Iteration of the RuleVerificationList {container.Iid} has not been set");
}

foreach (var violation in builtInRuleVerification.Violation)
Expand All @@ -171,13 +190,14 @@ private void Execute(ISession session, BuiltInRuleVerification builtInRuleVerifi
CDPMessageBus.Current.SendObjectChangeEvent(builtInRuleVerification, EventKind.Updated);

var builtInRule = this.QueryBuiltInRule(builtInRuleVerification);

if (builtInRule == null)
{
logger.Debug("The BuiltInRule with name {0} is not registered with the Service. The BuiltInRuleVerification cannot be executed", builtInRuleVerification.Name);
return;
}

IEnumerable<RuleViolation> violations = builtInRule.Verify(iteration);
var violations = builtInRule.Verify(iteration);

this.UpdateExecutedOn(session, builtInRuleVerification);

Expand Down Expand Up @@ -209,7 +229,7 @@ private void Execute(ISession session, UserRuleVerification userRuleVerification

if (iteration == null)
{
throw new ContainmentException(string.Format("The container Iteration of the RuleVerificationList {0} has not been set", container.Iid));
throw new ContainmentException($"The container Iteration of the RuleVerificationList {container.Iid} has not been set");
}

foreach (var violation in userRuleVerification.Violation)
Expand Down Expand Up @@ -270,7 +290,7 @@ private void Execute(ISession session, UserRuleVerification userRuleVerification
/// <param name="ruleVerification">
/// The <see cref="RuleVerification"/> that is to be updated.
/// </param>
private async void UpdateExecutedOn(ISession session, RuleVerification ruleVerification)
private void UpdateExecutedOn(ISession session, RuleVerification ruleVerification)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably best to make this private async Task ...

{
try
{
Expand All @@ -281,7 +301,7 @@ private async void UpdateExecutedOn(ISession session, RuleVerification ruleVerif
clone.ExecutedOn = DateTime.UtcNow;

var operationContainer = transaction.FinalizeTransaction();
await session.Write(operationContainer);
session.Write(operationContainer).GetAwaiter().GetResult();
}
catch (Exception ex)
{
Expand All @@ -301,8 +321,7 @@ private async void UpdateExecutedOn(ISession session, RuleVerification ruleVerif
/// </returns>
private IBuiltInRule QueryBuiltInRule(BuiltInRuleVerification builtInRuleVerification)
{
Lazy<IBuiltInRule, IBuiltInRuleMetaData> lazyBuiltInRule;
this.builtInRules.TryGetValue(builtInRuleVerification.Name, out lazyBuiltInRule);
this.builtInRules.TryGetValue(builtInRuleVerification.Name, out var lazyBuiltInRule);

if (lazyBuiltInRule == null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IterationTrackParameterDetailViewModel.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2020 RHEA System S.A.
// Copyright (c) 2015-2021 RHEA System S.A.
//
// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Smiechowski Nathanael
// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Ahmed Abulwafa Ahmed
//
// This file is part of CDP4-IME Community Edition.
// The CDP4-IME Community Edition is the RHEA Concurrent Design Desktop Application and Excel Integration
Expand Down
41 changes: 27 additions & 14 deletions CDP4Dashboard/ViewModels/Widget/IterationTrackParameterViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
// -----------------------------------------------------------------------
// <copyright file="IterationTrackParameterViewModel.cs" company="RHEA">
// Copyright (c) 2020 RHEA Group. All rights reserved.
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IterationTrackParameterViewModel.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2021 RHEA System S.A.
//
// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Ahmed Abulwafa Ahmed
//
// This file is part of CDP4-IME Community Edition.
// The CDP4-IME Community Edition is the RHEA Concurrent Design Desktop Application and Excel Integration
// compliant with ECSS-E-TM-10-25 Annex A and Annex C.
//
// The CDP4-IME Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or any later version.
//
// The CDP4-IME Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// -----------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------------------------

namespace CDP4Dashboard.ViewModels.Widget
{
Expand Down Expand Up @@ -31,8 +50,6 @@ namespace CDP4Dashboard.ViewModels.Widget
using CDP4RequirementsVerification;
using CDP4RequirementsVerification.Verifiers;

using NLog;

using ReactiveUI;

/// <summary>
Expand Down Expand Up @@ -73,11 +90,6 @@ public class IterationTrackParameterViewModel<TThing, TValueSet> : WidgetBase, I
/// </summary>
private IterationTrackParameter iterationTrackParameter;

/// <summary>
/// The Logger.
/// </summary>
private static Logger logger = LogManager.GetCurrentClassLogger();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to add more logging instead of removing the logger


/// <summary>
/// The block visibility.
/// </summary>
Expand Down Expand Up @@ -131,7 +143,7 @@ public class IterationTrackParameterViewModel<TThing, TValueSet> : WidgetBase, I
/// <summary>
/// The current <see cref="Iteration"/>
/// </summary>
private Iteration iteration;
private readonly Iteration iteration;

/// <summary>
/// The cache that stores the listeners that allow this row to react on update on the associated <see cref="IValueSet"/>
Expand Down Expand Up @@ -343,7 +355,8 @@ private void UpdateValueSetListeners()
/// <summary>
/// Verify the <see cref="IterationTrackParameter"/>'s Requirements'
/// </summary>
private async void VerifyRequirements()
/// <returns>A <see cref="Task"/></returns>
private async Task VerifyRequirements()
{
var binaryRelationshipsToVerify =
this.iterationTrackParameter.ParameterOrOverride.QueryRelationships
Expand Down Expand Up @@ -476,7 +489,7 @@ await this.Session.Read(parameterValueSets,

this.RefreshViewValues();
this.UpdateValueSetListeners();
this.VerifyRequirements();
await this.VerifyRequirements();
}

/// <summary>
Expand Down
Loading