Skip to content

Commit

Permalink
[Fix] SonarQube issues
Browse files Browse the repository at this point in the history
  • Loading branch information
samatrhea committed Mar 16, 2023
1 parent 05b14f2 commit 67d7b49
Show file tree
Hide file tree
Showing 26 changed files with 81 additions and 86 deletions.
2 changes: 1 addition & 1 deletion CDP4Common.NetCore.Tests/ThingExtensionTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void VerifyToDtoMethodWithValueArrayType()
constant.Container = this.siteDir;

var dto = constant.ToDto() as CDP4Common.DTO.Constant;
Assert.AreEqual(2, dto.Value.Count());
Assert.AreEqual(2, dto.Value.Count);
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion CDP4Common.Tests/ThingExtensionTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void VerifyToDtoMethodWithValueArrayType()
constant.Container = this.siteDir;

var dto = constant.ToDto() as CDP4Common.DTO.Constant;
Assert.AreEqual(2, dto.Value.Count());
Assert.AreEqual(2, dto.Value.Count);
}

[Test]
Expand Down
8 changes: 4 additions & 4 deletions CDP4Common/CDP4Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[Refactor] NLog logging to Microsoft.Extensions.Logging.Abstractions; fixes #219
[Implement] extension methods from webapp; fixes #251
[Remove] net461 target framework
[Implement] extension methods from webapp; fixes #251
[Remove] net461 target framework
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
Expand All @@ -41,7 +41,7 @@

<ItemGroup>
<None Include="..\docs\cdp4-icon.png" Pack="true" PackagePath="\" />
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
Expand Down
39 changes: 18 additions & 21 deletions CDP4Common/Poco/BinaryRelationship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,30 @@ public override string UserFriendlyShortName
/// <summary>
/// Gets the list of <see cref="BinaryRelationshipRule"/> applied to this <see cref="BinaryRelationship"/>
/// </summary>
public IEnumerable<BinaryRelationshipRule> AppliedBinaryRelationshipRules
public IEnumerable<BinaryRelationshipRule> QueryAppliedBinaryRelationshipRules()
{
get
if (this.Category == null)
{
if (this.Category == null)
{
return new List<BinaryRelationshipRule>();
}
return new List<BinaryRelationshipRule>();
}

var model = this.GetContainerOfType<EngineeringModel>();
if (model == null)
{
throw new ContainmentException("The Engineering Model container is null.");
}
var model = this.GetContainerOfType<EngineeringModel>();
if (model == null)
{
throw new ContainmentException("The Engineering Model container is null.");
}

var mrdl = model.EngineeringModelSetup.RequiredRdl.Single();
var mrdl = model.EngineeringModelSetup.RequiredRdl.Single();

var appliedRules =
new List<BinaryRelationshipRule>(
mrdl.Rule.OfType<BinaryRelationshipRule>()
.Where(c => this.Category.Contains(c.RelationshipCategory)));
appliedRules.AddRange(mrdl.GetRequiredRdls()
.SelectMany(rdl => rdl.Rule.OfType<BinaryRelationshipRule>())
.Where(c => this.Category.Contains(c.RelationshipCategory)));
var appliedRules =
new List<BinaryRelationshipRule>(
mrdl.Rule.OfType<BinaryRelationshipRule>()
.Where(c => this.Category.Contains(c.RelationshipCategory)));
appliedRules.AddRange(mrdl.GetRequiredRdls()
.SelectMany(rdl => rdl.Rule.OfType<BinaryRelationshipRule>())
.Where(c => this.Category.Contains(c.RelationshipCategory)));

return appliedRules;
}
return appliedRules;
}

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion CDP4Common/Poco/DecompositionRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ private IEnumerable<RuleViolation> VerifyValidUsages(ElementDefinition elementDe
if (isElementDefinitionAMember)
{
isValidUsage = true;
continue;
}
}

Expand Down
1 change: 0 additions & 1 deletion CDP4Common/Poco/ElementBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public override IEnumerable<ReferenceDataLibrary> RequiredRdls
/// Queries all <see cref="ParameterSubscription" /> owned by a given <see cref="DomainOfExpertise" />
/// contained into an <see cref="ElementBase" />
/// </summary>
/// <param name="element">The <see cref="ElementBase" /></param>
/// <param name="domain">The <see cref="DomainOfExpertise" /></param>
/// <returns>A collection of <see cref="ParameterSubscription" /></returns>
public IEnumerable<ParameterSubscription> QueryOwnedParameterSubscriptions(DomainOfExpertise domain)
Expand Down
1 change: 0 additions & 1 deletion CDP4Common/Poco/Iteration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ public IEnumerable<ElementBase> QueryElementsBase()
/// Queries all <see cref="ParameterSubscription" /> owned by a given <see cref="DomainOfExpertise" />
/// contained into an <see cref="Iteration" />
/// </summary>
/// <param name="iteration">The <see cref="Iteration" /></param>
/// <param name="domain">The <see cref="DomainOfExpertise" /></param>
/// <returns>A collection of <see cref="ParameterSubscription" /></returns>
public IEnumerable<ParameterSubscription> QueryOwnedParameterSubscriptions(DomainOfExpertise domain)
Expand Down
6 changes: 3 additions & 3 deletions CDP4Dal.NetCore.Tests/SessionTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public async Task VerifyThatOpenSiteRDLUpdatesListInSession()

await session2.Read(rdlPoco);

Assert.AreEqual(2, session2.OpenReferenceDataLibraries.ToList().Count());
Assert.AreEqual(2, session2.OpenReferenceDataLibraries.ToList().Count);

await session2.Close();
Assert.IsEmpty(session2.OpenReferenceDataLibraries);
Expand Down Expand Up @@ -390,15 +390,15 @@ public async Task VerifyThatCloseModelRdlWorks()

await session2.Assembler.Synchronize(thingsToAdd);
await session2.Read(modelRdlPoco);
Assert.AreEqual(2, session2.OpenReferenceDataLibraries.ToList().Count());
Assert.AreEqual(2, session2.OpenReferenceDataLibraries.ToList().Count);

Lazy<CDP4Common.CommonData.Thing> rdlPocoToClose;
session2.Assembler.Cache.TryGetValue(new CacheKey(modelRdlPoco.Iid, null), out rdlPocoToClose);
Assert.NotNull(rdlPocoToClose);
await session2.CloseModelRdl((ModelReferenceDataLibrary)rdlPocoToClose.Value);

// Checkt that closing a modelRDL doesn't close it's required SiteRDL
Assert.AreEqual(1, session2.OpenReferenceDataLibraries.ToList().Count());
Assert.AreEqual(1, session2.OpenReferenceDataLibraries.ToList().Count);
Assert.AreEqual(ClassKind.SiteReferenceDataLibrary, session2.OpenReferenceDataLibraries.First().ClassKind);
}

Expand Down
18 changes: 9 additions & 9 deletions CDP4Dal.Tests/SessionTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public async Task VerifyThatOpenSiteRDLUpdatesListInSession()

await session2.Read(rdlPoco);

Assert.AreEqual(2, session2.OpenReferenceDataLibraries.ToList().Count());
Assert.AreEqual(2, session2.OpenReferenceDataLibraries.ToList().Count);

await session2.Close();
Assert.IsEmpty(session2.OpenReferenceDataLibraries);
Expand All @@ -349,25 +349,25 @@ public async Task VerifyThatCloseRdlWorks()
session.GetType().GetProperty("ActivePerson").SetValue(session, JohnDoe, null);
await session.Assembler.Synchronize(thingsToAdd);
await session.Read(rdlPoco);
Assert.AreEqual(2, session.OpenReferenceDataLibraries.ToList().Count());
Assert.AreEqual(2, session.OpenReferenceDataLibraries.ToList().Count);

Lazy<CDP4Common.CommonData.Thing> rdlPocoToClose;
session.Assembler.Cache.TryGetValue(new CacheKey(rdlPoco.Iid, null), out rdlPocoToClose);
await session.CloseRdl((CDP4Common.SiteDirectoryData.SiteReferenceDataLibrary)rdlPocoToClose.Value);
Assert.AreEqual(1, session.OpenReferenceDataLibraries.ToList().Count());

Assert.AreEqual(1, session.OpenReferenceDataLibraries.ToList().Count);
await session.Read(rdlPoco);
Assert.AreEqual(2, session.OpenReferenceDataLibraries.ToList().Count());
Assert.AreEqual(2, session.OpenReferenceDataLibraries.ToList().Count);

session.Assembler.Cache.TryGetValue(new CacheKey(rdlPoco.Iid, null), out rdlPocoToClose);
Lazy<CDP4Common.CommonData.Thing> requiredRdlToClose;
session.Assembler.Cache.TryGetValue(new CacheKey(requiredSiteReferenceDataLibraryPoco.Iid, null), out requiredRdlToClose);
await session.CloseRdl((CDP4Common.SiteDirectoryData.SiteReferenceDataLibrary)requiredRdlToClose.Value);

Assert.AreEqual(0, session.OpenReferenceDataLibraries.ToList().Count());
Assert.AreEqual(0, session.OpenReferenceDataLibraries.ToList().Count);

await session.CloseRdl((CDP4Common.SiteDirectoryData.SiteReferenceDataLibrary)rdlPocoToClose.Value);
Assert.AreEqual(0, session.OpenReferenceDataLibraries.ToList().Count());
Assert.AreEqual(0, session.OpenReferenceDataLibraries.ToList().Count);
}

[Test]
Expand Down Expand Up @@ -509,15 +509,15 @@ public async Task VerifyThatCloseModelRdlWorks()

await session2.Assembler.Synchronize(thingsToAdd);
await session2.Read(modelRdlPoco);
Assert.AreEqual(2, session2.OpenReferenceDataLibraries.ToList().Count());
Assert.AreEqual(2, session2.OpenReferenceDataLibraries.ToList().Count);

Lazy<CDP4Common.CommonData.Thing> rdlPocoToClose;
session2.Assembler.Cache.TryGetValue(new CacheKey(modelRdlPoco.Iid, null), out rdlPocoToClose);
Assert.NotNull(rdlPocoToClose);
await session2.CloseModelRdl((ModelReferenceDataLibrary)rdlPocoToClose.Value);

// Checkt that closing a modelRDL doesn't close it's required SiteRDL
Assert.AreEqual(1, session2.OpenReferenceDataLibraries.ToList().Count());
Assert.AreEqual(1, session2.OpenReferenceDataLibraries.ToList().Count);
Assert.AreEqual(ClassKind.SiteReferenceDataLibrary, session2.OpenReferenceDataLibraries.First().ClassKind);
}

Expand Down
8 changes: 4 additions & 4 deletions CDP4Dal/CDP4Dal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 10.0.0
[Update] ThingTransaction namespace; fixes #154
[Remove] net461 target framework
[Update] ThingTransaction namespace; fixes #154
[Remove] net461 target framework
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
Expand All @@ -37,7 +37,7 @@

<ItemGroup>
<None Include="..\docs\cdp4-icon.png" Pack="true" PackagePath="\" />
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions CDP4JsonFileDal/CDP4JsonFileDal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 10.0.0
[Remove] net461 target framework
[Upgrade] to DotNetZip version 1.16.0
[Remove] net461 target framework
[Upgrade] to DotNetZip version 1.16.0
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -33,7 +33,7 @@

<ItemGroup>
<None Include="..\docs\cdp4-icon.png" Pack="true" PackagePath="\" />
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 3 additions & 4 deletions CDP4JsonFileDal/JsonFileDal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public override async Task<IEnumerable<Thing>> Read<T>(T thing, CancellationToke
returned = this.RetrieveSRDLThings(thing as CDP4Common.DTO.SiteReferenceDataLibrary, siteDirectoryData, zip, siteDir);
break;
case ClassKind.DomainOfExpertise:
returned = this.RetrieveDomainOfExpertiseThings(thing as CDP4Common.DTO.DomainOfExpertise, siteDirectoryData, siteDir);
returned = this.RetrieveDomainOfExpertiseThings(thing as CDP4Common.DTO.DomainOfExpertise, siteDirectoryData);
break;
}

Expand Down Expand Up @@ -410,9 +410,8 @@ public override async Task<IEnumerable<Thing>> Read(CDP4Common.DTO.Iteration ite
/// </summary>
/// <param name="domain">The <see cref="DomainOfExpertise"/></param>
/// <param name="siteDirectoryData">All SiteDirectory DTOs</param>
/// <param name="siteDir">The <see cref="SiteDirectory"/> object</param>
/// <returns>List of things contained by the particular srdl</returns>
private List<Thing> RetrieveDomainOfExpertiseThings(CDP4Common.DTO.DomainOfExpertise domain, List<Thing> siteDirectoryData, CDP4Common.SiteDirectoryData.SiteDirectory siteDir)
private List<Thing> RetrieveDomainOfExpertiseThings(CDP4Common.DTO.DomainOfExpertise domain, List<Thing> siteDirectoryData)
{
var returned = new List<Thing>();

Expand Down Expand Up @@ -658,7 +657,7 @@ public override async Task<IEnumerable<Thing>> Open(Credentials credentials, Can
// make sure the uri is not null
if (credentials == null)
{
throw new ArgumentNullException(nameof(this.Credentials.Uri), $"The Credentials URI may not be null");
throw new ArgumentNullException("credentials.Uri", $"The Credentials URI may not be null");
}

// make sure that the uri is of the correct format
Expand Down
8 changes: 4 additions & 4 deletions CDP4JsonSerializer/CDP4JsonSerializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 10.0.0
[Remove] net461 target framework
[Upgrade] to Newtonsoft.Json version 13.0.3
[Remove] net461 target framework
[Upgrade] to Newtonsoft.Json version 13.0.3
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
Expand All @@ -37,7 +37,7 @@

<ItemGroup>
<None Include="..\docs\cdp4-icon.png" Pack="true" PackagePath="\" />
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions CDP4Reporting/CDP4Reporting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 10.0.0
[Remove] net461 target framework
[Remove] net461 target framework
</PackageReleaseNotes>
<LangVersion>latest</LangVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\docs\cdp4-icon.png" Link="cdp4-icon.png" Pack="true" PackagePath="\" />
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\docs\cdp4-icon.png" Link="cdp4-icon.png" Pack="true" PackagePath="\" />
<None Include="..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 10.0.0
[Remove] net461 target framework
[Remove] net461 target framework
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
Expand All @@ -36,7 +36,7 @@

<ItemGroup>
<None Include="..\docs\cdp4-icon.png" Pack="true" PackagePath="\" />
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions CDP4Rules/CDP4Rules.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[UPGRADE] CDP4Common 10.0.0
[Remove] net461 target framework
[Remove] net461 target framework
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
Expand All @@ -36,7 +36,7 @@

<ItemGroup>
<None Include="..\docs\cdp4-icon.png" Pack="true" PackagePath="\" />
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion CDP4Rules/RuleCheckers/ParameterTypeRuleChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace CDP4Rules.RuleCheckers
public class ParameterTypeRuleChecker : RuleChecker
{
/// <summary>
/// Checks whether the <see cref="ParameterType.ShortName"/> is case-sensitive unique within its containing <see cref="ReferenceDataLibrary"/>
/// Checks whether the <see cref="ParameterType"/> Shortname is case-sensitive unique within its containing <see cref="ReferenceDataLibrary"/>
/// </summary>
/// <param name="thing">
/// The subject <see cref="ParameterType"/>
Expand Down
2 changes: 1 addition & 1 deletion CDP4ServicesDal.NetCore.Tests/CdpServicesDalTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ public async Task Verify_that_multiple_read_requests_can_be_made_in_parallel()

for (int i = 0; i < 9; i++)
{
dal.Read(siteDirectory, new CancellationToken(), queryAttributes);
await dal.Read(siteDirectory, new CancellationToken(), queryAttributes);
}

var readresult = await dal.Read(siteDirectory, new CancellationToken());
Expand Down
2 changes: 1 addition & 1 deletion CDP4ServicesDal.Tests/CdpServicesDalTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ public async Task Verify_that_multiple_read_requests_can_be_made_in_parallel()

for (int i = 0; i < 9; i++)
{
dal.Read(siteDirectory, new CancellationToken(), queryAttributes);
await dal.Read(siteDirectory, new CancellationToken(), queryAttributes);
}

var readresult = await dal.Read(siteDirectory, new CancellationToken());
Expand Down
Loading

0 comments on commit 67d7b49

Please sign in to comment.