Skip to content

Commit 2c29651

Browse files
[Code Quality] Implement SonarQube improvements
1 parent 31efe6e commit 2c29651

File tree

7 files changed

+61
-69
lines changed

7 files changed

+61
-69
lines changed

SySML2.NET.REST/IRestClient.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,16 @@ public interface IRestClient
132132
Task<IEnumerable<Tag>> RequestTags(Guid project, Guid? tag, QueryParameters queryParameters, CancellationToken cancellationToken);
133133

134134
/// <summary>
135-
/// Requests the <see cref="Element"/>s in a <see cref="Branch"/> of a <see cref="Project"/> from the SysML2 model server REST API
135+
/// Requests the <see cref="IElement"/>s in a <see cref="Branch"/> of a <see cref="Project"/> from the SysML2 model server REST API
136136
/// </summary>
137137
/// <param name="project">
138-
/// The unique identifier of the <see cref="Project"/> that contains the requested <see cref="Element"/>s
138+
/// The unique identifier of the <see cref="Project"/> that contains the requested <see cref="IElement"/>s
139139
/// </param>
140140
/// <param name="commit">
141-
/// The unique identifier of the <see cref="Commit"/> that contains the requested <see cref="Element"/>s
141+
/// The unique identifier of the <see cref="Commit"/> that contains the requested <see cref="IElement"/>s
142142
/// </param>
143143
/// <param name="element">
144-
/// The unique identifier of the <see cref="Element"/> to read. In case this is null all <see cref="Element"/>s are read.
144+
/// The unique identifier of the <see cref="IElement"/> to read. In case this is null all <see cref="IElement"/>s are read.
145145
/// </param>
146146
/// <param name="queryParameters">
147147
/// The <see cref="QueryParameters"/> used to filter the response on the SysML2 model server REST API
@@ -150,18 +150,18 @@ public interface IRestClient
150150
/// The <see cref="CancellationToken"/> used to cancel the operation
151151
/// </param>
152152
/// <returns>
153-
/// A list of <see cref="Element"/>s that are contained by the specified <see cref="Project"/> and <see cref="Commit"/>, or a single <see cref="Element"/> if so requested
153+
/// A list of <see cref="IElement"/>s that are contained by the specified <see cref="Project"/> and <see cref="Commit"/>, or a single <see cref="IElement"/> if so requested
154154
/// </returns>
155155
Task<IEnumerable<IElement>> RequestElements(Guid project, Guid commit, Guid? element, QueryParameters queryParameters, CancellationToken cancellationToken);
156156

157157
/// <summary>
158-
/// Requests the root <see cref="Element"/>s in a <see cref="Commit"/> of a <see cref="Project"/> from the SysML2 model server REST API
158+
/// Requests the root <see cref="IElement"/>s in a <see cref="Commit"/> of a <see cref="Project"/> from the SysML2 model server REST API
159159
/// </summary>
160160
/// <param name="project">
161-
/// The unique identifier of the <see cref="Project"/> that contains the requested <see cref="Element"/>s
161+
/// The unique identifier of the <see cref="Project"/> that contains the requested <see cref="IElement"/>s
162162
/// </param>
163163
/// <param name="commit">
164-
/// The unique identifier of the <see cref="Commit"/> that contains the requested <see cref="Element"/>s
164+
/// The unique identifier of the <see cref="Commit"/> that contains the requested <see cref="IElement"/>s
165165
/// </param>
166166
/// <param name="queryParameters">
167167
/// The <see cref="QueryParameters"/> used to filter the response on the SysML2 model server REST API
@@ -170,7 +170,7 @@ public interface IRestClient
170170
/// The <see cref="CancellationToken"/> used to cancel the operation
171171
/// </param>
172172
/// <returns>
173-
/// A list of <see cref="Element"/>s that are contained by the specified <see cref="Project"/> and <see cref="Commit"/>, or a single <see cref="Element"/> if so requested
173+
/// A list of <see cref="IElement"/>s that are contained by the specified <see cref="Project"/> and <see cref="Commit"/>, or a single <see cref="IElement"/> if so requested
174174
/// </returns>
175175
Task<IEnumerable<IElement>> RequestRootElements(Guid project, Guid commit, QueryParameters queryParameters, CancellationToken cancellationToken);
176176
}

SySML2.NET.REST/RestClient.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,16 @@ public async Task<IEnumerable<Tag>> RequestTags(Guid project, Guid? tag, QueryPa
290290
}
291291

292292
/// <summary>
293-
/// Requests the <see cref="Element"/>s in a <see cref="Branch"/> of a <see cref="Project"/> from the SysML2 model server REST API
293+
/// Requests the <see cref="IElement"/>s in a <see cref="Branch"/> of a <see cref="Project"/> from the SysML2 model server REST API
294294
/// </summary>
295295
/// <param name="project">
296-
/// The unique identifier of the <see cref="Project"/> that contains the requested <see cref="Element"/>s
296+
/// The unique identifier of the <see cref="Project"/> that contains the requested <see cref="IElement"/>s
297297
/// </param>
298298
/// <param name="commit">
299-
/// The unique identifier of the <see cref="Commit"/> that contains the requested <see cref="Element"/>s
299+
/// The unique identifier of the <see cref="Commit"/> that contains the requested <see cref="IElement"/>s
300300
/// </param>
301301
/// <param name="element">
302-
/// The unique identifier of the <see cref="Element"/> to read. In case this is null all <see cref="Element"/>s are read.
302+
/// The unique identifier of the <see cref="IElement"/> to read. In case this is null all <see cref="IElement"/>s are read.
303303
/// </param>
304304
/// <param name="queryParameters">
305305
/// The <see cref="QueryParameters"/> used to filter the response on the SysML2 model server REST API
@@ -308,7 +308,7 @@ public async Task<IEnumerable<Tag>> RequestTags(Guid project, Guid? tag, QueryPa
308308
/// The <see cref="CancellationToken"/> used to cancel the operation
309309
/// </param>
310310
/// <returns>
311-
/// A list of <see cref="Element"/>s that are contained by the specified <see cref="Project"/> and <see cref="Commit"/>, or a single <see cref="Element"/> if so requested
311+
/// A list of <see cref="IElement"/>s that are contained by the specified <see cref="Project"/> and <see cref="Commit"/>, or a single <see cref="IElement"/> if so requested
312312
/// </returns>
313313
public async Task<IEnumerable<IElement>> RequestElements(Guid project, Guid commit, Guid? element, QueryParameters queryParameters, CancellationToken cancellationToken)
314314
{
@@ -340,13 +340,13 @@ public async Task<IEnumerable<IElement>> RequestElements(Guid project, Guid comm
340340
}
341341

342342
/// <summary>
343-
/// Requests the root <see cref="Element"/>s in a <see cref="Commit"/> of a <see cref="Project"/> from the SysML2 model server REST API
343+
/// Requests the root <see cref="IElement"/>s in a <see cref="Commit"/> of a <see cref="Project"/> from the SysML2 model server REST API
344344
/// </summary>
345345
/// <param name="project">
346-
/// The unique identifier of the <see cref="Project"/> that contains the requested <see cref="Element"/>s
346+
/// The unique identifier of the <see cref="Project"/> that contains the requested <see cref="IElement"/>s
347347
/// </param>
348348
/// <param name="commit">
349-
/// The unique identifier of the <see cref="Commit"/> that contains the requested <see cref="Element"/>s
349+
/// The unique identifier of the <see cref="Commit"/> that contains the requested <see cref="IElement"/>s
350350
/// </param>
351351
/// <param name="queryParameters">
352352
/// The <see cref="QueryParameters"/> used to filter the response on the SysML2 model server REST API
@@ -355,7 +355,7 @@ public async Task<IEnumerable<IElement>> RequestElements(Guid project, Guid comm
355355
/// The <see cref="CancellationToken"/> used to cancel the operation
356356
/// </param>
357357
/// <returns>
358-
/// A list of <see cref="Element"/>s that are contained by the specified <see cref="Project"/> and <see cref="Commit"/>, or a single <see cref="Element"/> if so requested
358+
/// A list of <see cref="IElement"/>s that are contained by the specified <see cref="Project"/> and <see cref="Commit"/>, or a single <see cref="IElement"/> if so requested
359359
/// </returns>
360360
public async Task<IEnumerable<IElement>> RequestRootElements(Guid project, Guid commit, QueryParameters queryParameters, CancellationToken cancellationToken)
361361
{

SysML2.NET.API/DataService/ProjectService.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ public override async Task<bool> BeforeCreate(IData data, CancellationToken canc
6060
throw new ArgumentException("This is not a Project", nameof(data));
6161
}
6262

63-
var commit = new Commit
64-
{
65-
Id = Guid.Parse("04969904ad5b4cc695042f0fba68fb3b"),
66-
67-
};
68-
6963
var branch = new Branch
7064
{
7165
Id = Guid.Parse("2deabbda92a140f5a2ff8af3e12f050e"),

SysML2.NET.API/Modules/BaseModule.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ protected async Task WriteResultsToResponse(IEnumerable<IData> dataItems, Serial
100100
var dtoTypeName = this.GetType().Name.Replace("Module", string.Empty);
101101

102102
response.ContentType = "application/json";
103-
this.logger.LogDebug("start serializing {dtoTypeName} objects to result Stream", dtoTypeName);
103+
this.logger.LogDebug("start serializing {DtoTypeName} objects to result Stream", dtoTypeName);
104104

105105
var resultStream = new MemoryStream();
106106
await this.serializer.SerializeAsync(dataItems, serializationModeKind, resultStream, jsonWriterOptions, cancellationToken);
107107

108-
this.logger.LogDebug("{dtoTypeName} objects serialized to stream in {elapsed} [ms]", dtoTypeName, sw.ElapsedMilliseconds);
108+
this.logger.LogDebug("{DtoTypeName} objects serialized to stream in {Elapsed} [ms]", dtoTypeName, sw.ElapsedMilliseconds);
109109

110110
resultStream.Seek(0, SeekOrigin.Begin);
111111

@@ -140,12 +140,12 @@ protected async Task WriteResultToResponse(IData dataItem, SerializationModeKind
140140
var dtoTypeName = this.GetType().Name.Replace("Module", string.Empty);
141141

142142
response.ContentType = "application/json";
143-
this.logger.LogDebug("start serializing {dtoTypeName} objects to result Stream", dtoTypeName);
143+
this.logger.LogDebug("start serializing {DtoTypeName} objects to result Stream", dtoTypeName);
144144

145145
var resultStream = new MemoryStream();
146146
await this.serializer.SerializeAsync(dataItem, serializationModeKind, resultStream, jsonWriterOptions, cancellationToken);
147147

148-
this.logger.LogDebug("{dtoTypeName} object serialized to stream in {elapsed} [ms]", dtoTypeName, sw.ElapsedMilliseconds);
148+
this.logger.LogDebug("{DtoTypeName} object serialized to stream in {Elapsed} [ms]", dtoTypeName, sw.ElapsedMilliseconds);
149149

150150
resultStream.Seek(0, SeekOrigin.Begin);
151151

SysML2.NET.API/Modules/ProjectModule.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ public void AddRoutes(IEndpointRouteBuilder app)
9494
await WriteResultsToResponse(dataItems, SerializationModeKind.JSON, res, jsonWriterOptions,
9595
cancellationToken);
9696
}
97-
catch (TaskCanceledException)
97+
catch (TaskCanceledException taskCanceledException)
9898
{
99-
this.logger.LogInformation("request cancelled");
99+
this.logger.LogInformation(taskCanceledException, "request cancelled");
100100
res.StatusCode = 202;
101101
}
102102
catch (Exception exception)
@@ -121,9 +121,9 @@ await WriteResultsToResponse(dataItems, SerializationModeKind.JSON, res, jsonWri
121121
res.StatusCode = 200;
122122
await WriteResultsToResponse(dataItems, SerializationModeKind.JSON, res, jsonWriterOptions, cancellationToken);
123123
}
124-
catch (TaskCanceledException)
124+
catch (TaskCanceledException taskCanceledException)
125125
{
126-
this.logger.LogInformation("request cancelled");
126+
this.logger.LogInformation(taskCanceledException,"request cancelled");
127127
res.StatusCode = 202;
128128
}
129129
catch (Exception exception)
@@ -155,9 +155,9 @@ await WriteResultsToResponse(dataItems, SerializationModeKind.JSON, res, jsonWri
155155
res.StatusCode = 200;
156156
await WriteResultToResponse(project, SerializationModeKind.JSON, res, jsonWriterOptions, cancellationToken);
157157
}
158-
catch (TaskCanceledException)
158+
catch (TaskCanceledException taskCanceledException)
159159
{
160-
this.logger.LogInformation("request cancelled");
160+
this.logger.LogInformation(taskCanceledException, "request cancelled");
161161
res.StatusCode = 202;
162162
}
163163
catch (Exception exception)

SysML2.NET.CodeGenerator/Generators/UmlHandleBarsGenerators/UmlCoreEnumProviderGenerator.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ private async Task<string> GenerateEnumerationProviderInternalAsync(XmiReaderRes
158158
.SelectMany(x => x.PackagedElement.OfType<IEnumeration>())
159159
.ToList();
160160

161-
var enumNames = enumerations.Select(x => x.Name);
162-
163161
var enumeration = enumerations.Single(x => x.Name == name);
164162

165163
var generatedProviderEnumeration = template(enumeration);

0 commit comments

Comments
 (0)