Skip to content

Commit a766b79

Browse files
authored
Fix most of the code warnings (#2519)
This fixes most of the code warnings that are in the codebase. There is a separate commit for every warning type. There still are 4 instances of warning **CS0649 Field '…' is never assigned to, and will always have its default value null**: - `PauseAfterEachItem._Options` - `KeepOutboundLinkTargetProcessor._options` - `OutboundLinkCheckingProcessor._options` - `TfsWorkItemOverwriteAreasAsTagsProcessor._config` As the warning states, these are fields which are declared, but are never set ad hence the value is `null`. The problem is, I cannot remove these fileds, because _they are used in code_. So I believe, that those classes (or at least those specific code paths) are not used at all, because it would fail with `NullReferenceException`. The only possibility is, that the values are set somewhere by reflection? So I will leave these warnings to someone else to look at them.
2 parents c8278f2 + 3a9db8b commit a766b79

31 files changed

+85
-130
lines changed

src/MigrationTools.Clients.AzureDevops.Rest/Endpoints/AzureDevOpsEndpoint.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace MigrationTools.Endpoints
2222
{
2323
public class AzureDevOpsEndpoint : Endpoint<AzureDevOpsEndpointOptions>
2424
{
25+
[Obsolete("Dont know what this is for")]
2526
public override int Count => 0;
2627

2728
public AzureDevOpsEndpoint(IOptions<AzureDevOpsEndpointOptions> optipons, EndpointEnricherContainer endpointEnrichers, IServiceProvider serviceProvider, ITelemetryLogger telemetry, ILogger<AzureDevOpsEndpoint> logger)
@@ -208,10 +209,8 @@ public async Task<IEnumerable<DefinitionType>> GetApiDefinitionsAsync<Definition
208209
/// <typeparam name="DefinitionType"></typeparam>
209210
/// <param name="routeParameters">strings that are injected into the route parameters of the definitions url</param>
210211
/// <param name="queryString">additional query string parameters passed to the underlying api call</param>
211-
/// <param name="singleDefinitionQueryString">additional query string parameter passed when pulling the single instance details (ie. $expands, etc)</param>
212-
/// <param name="queryForDetails">a boolean flag to allow caller to skip the calls for each individual definition details</param>
213212
/// <returns></returns>
214-
public async Task<DefinitionType> GetApiDefinitionAsync<DefinitionType>(string[] routeParameters = null, string queryString = "", string singleDefinitionQueryString = "", bool queryForDetails = true)
213+
public async Task<DefinitionType> GetApiDefinitionAsync<DefinitionType>(string[] routeParameters = null, string queryString = "")
215214
where DefinitionType : RestApiDefinition, new()
216215
{
217216
var apiPathAttribute = typeof(DefinitionType).GetCustomAttributes(typeof(ApiPathAttribute), false).OfType<ApiPathAttribute>().FirstOrDefault();
@@ -235,11 +234,10 @@ public async Task<DefinitionType> GetApiDefinitionAsync<DefinitionType>(string[]
235234
/// <summary>
236235
/// Make HTTP Request to add Revision / Version of Task Group
237236
/// </summary>
238-
/// <param name="targetDefinitions"></param>
239237
/// <param name="rootDefinitions"></param>
240238
/// <param name="updatedDefinitions"></param>
241239
/// <returns>List of Mappings</returns>
242-
public async Task<List<Mapping>> UpdateTaskGroupsAsync(IEnumerable<TaskGroup> targetDefinitions, IEnumerable<TaskGroup> rootDefinitions, IEnumerable<TaskGroup> updatedDefinitions)
240+
public async Task<List<Mapping>> UpdateTaskGroupsAsync(IEnumerable<TaskGroup> rootDefinitions, IEnumerable<TaskGroup> updatedDefinitions)
243241
{
244242
var migratedDefinitions = new List<Mapping>();
245243
foreach (var definitionToBeMigrated in updatedDefinitions)
@@ -649,4 +647,4 @@ public static void AddToPath(this HttpClient client, string pathToAdd)
649647
client.BaseAddress = new Uri($"https://{client.BaseAddress.Host}:{client.BaseAddress.Port}{client.BaseAddress.LocalPath}{pathToAdd}{client.BaseAddress.Query}");
650648
}
651649
}
652-
}
650+
}

src/MigrationTools.Clients.AzureDevops.Rest/Processors/AzureDevOpsPipelineProcessor.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ private IEnumerable<DefinitionType> FilterOutExistingDefinitions<DefinitionType>
150150
/// <summary>
151151
/// Filter incompatible TaskGroups
152152
/// </summary>
153-
/// <param name="filteredTaskGroups"></param>
153+
/// <param name="sourceDefinitions"></param>
154154
/// <param name="availableTasks"></param>
155+
/// <param name="taskGroupMapping"></param>
155156
/// <returns>List of filtered Definitions</returns>
156157
private IEnumerable<BuildDefinition> FilterOutIncompatibleBuildDefinitions(IEnumerable<BuildDefinition> sourceDefinitions, IEnumerable<TaskDefinition> availableTasks, IEnumerable<Mapping> taskGroupMapping)
157158
{
@@ -631,7 +632,7 @@ private async Task<IEnumerable<Mapping>> CreateTaskGroupDefinitionsAsync()
631632

632633
targetDefinitions = await Target.GetApiDefinitionsAsync<TaskGroup>(queryForDetails: false);
633634
var rootTargetDefinitions = SortDefinitionsByVersion(targetDefinitions).First();
634-
await Target.UpdateTaskGroupsAsync(targetDefinitions, rootTargetDefinitions, updatedSourceDefinitions);
635+
await Target.UpdateTaskGroupsAsync(rootTargetDefinitions, updatedSourceDefinitions);
635636

636637
targetDefinitions = await Target.GetApiDefinitionsAsync<TaskGroup>(queryForDetails: false);
637638
mappings.AddRange(FindExistingMappings(sourceDefinitions, targetDefinitions.Where(d => d.Name != null), mappings));

src/MigrationTools.Clients.AzureDevops.Rest/Processors/ProcessDefinitionProcessor.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
namespace MigrationTools.Processors
2121
{
22-
22+
2323
internal class ProcessorModel
2424
{
2525
public Dictionary<string, ProcessDefinitionModel> ProcessDefinitions { get; set; } = new Dictionary<string, ProcessDefinitionModel>();
@@ -151,7 +151,7 @@ await SourceFields.Values.ParallelForEachAsync(Math.Max(1, Options.MaxDegreeOfPa
151151
catch (Exception ex)
152152
{
153153
Log.LogError(ex, "Failed to synchronize processes.");
154-
throw ex;
154+
throw;
155155
}
156156
}
157157

@@ -215,7 +215,7 @@ await SyncDefinitionType<WorkItemState>(
215215
foreach (var field in sourceWit.Fields)
216216
{
217217
var existingField = TargetModel.WorkItemFields.Values.FirstOrDefault(x => x.ReferenceName == field.ReferenceName);
218-
//if (existingField == null || (existingField != null && field.Customization != "system")) // I don't think you can modify
218+
//if (existingField == null || (existingField != null && field.Customization != "system")) // I don't think you can modify
219219
//{
220220
await SyncDefinitionType<WorkItemTypeField>(
221221
TargetModel.WorkItemFields,
@@ -320,7 +320,7 @@ await SyncDefinitionType<WorkItemPage>(
320320
}
321321
else
322322
{
323-
323+
324324
// Its on a different page .. lets move pages
325325
var tempTargetGroup = existingGroup.Value.CloneAsNew();
326326
tempTargetGroup.Id = existingGroup.Value.Id;
@@ -446,7 +446,7 @@ await SyncDefinitionType<WorkItemPage>(
446446
Log.LogInformation($"Completed sync of work item type [{Source.Options.Name}::{sourceWit.WorkItemType.Name}] in [{Target.Options.Name}::{targetWit.WorkItemType.Name}].");
447447
}
448448

449-
449+
450450

451451
private async Task<DefinitionType> SyncDefinitionType<DefinitionType>(Dictionary<string, DefinitionType> DataDictionary, DefinitionType sourceDef, DefinitionType targetDef, params string[] routeParams)
452452
where DefinitionType : RestApiDefinition, ISynchronizeable<DefinitionType>, new()
@@ -468,7 +468,7 @@ private async Task<DefinitionType> SyncDefinitionType<DefinitionType>(Dictionary
468468
private async Task BuildModel(ProcessorModel model, AzureDevOpsEndpoint endpoint, bool warnOnMissing)
469469
{
470470
// Grab all the procs, then iterate over them looking for procs user has configured to be
471-
// sync'd. Then grab all Work Item Types for the given process and filter those by the ones user
471+
// sync'd. Then grab all Work Item Types for the given process and filter those by the ones user
472472
// wants to sync.
473473

474474
Log.LogDebug($"Loading model for [{endpoint.Options.Name}].");
@@ -589,7 +589,7 @@ private async Task LoadWorkItemFields(ProcessorModel model, WorkItemType wit, Az
589589
}
590590
private async Task LoadLayout(ProcessorModel model, WorkItemTypeModel wit, AzureDevOpsEndpoint endpoint, string processId)
591591
{
592-
wit.Layout = (await endpoint.GetApiDefinitionAsync<WorkItemLayout>(new string[] { processId, wit.WorkItemType.ReferenceName }, queryForDetails: false));
592+
wit.Layout = (await endpoint.GetApiDefinitionAsync<WorkItemLayout>(new string[] { processId, wit.WorkItemType.ReferenceName }));
593593
foreach (var page in wit.Layout.Pages)
594594
{
595595
var pageKey = $"{wit.WorkItemType.Name}::{page.Label}";

src/MigrationTools.Clients.FileSystem/Endpoints/FileSystemWorkItemEndpoint.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public FileSystemWorkItemEndpoint(IOptions<FileSystemWorkItemEndpointOptions> op
2020
_innerList = new List<WorkItemData>();
2121
}
2222

23+
[Obsolete("Dont know what this is for")]
2324
public override int Count => GetWorkItems().Count();
2425

2526
public void EnsureStore()
@@ -70,4 +71,4 @@ public void PersistWorkItem(WorkItemData source)
7071
LoadStore();
7172
}
7273
}
73-
}
74+
}

src/MigrationTools.Clients.TfsObjectModel/Endpoints/TfsEndpoint.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,9 @@ public Uri TfsProjectUri
5656
get { return TfsProject.Uri; }
5757
}
5858

59+
[Obsolete("Dont know what this is for")]
5960
public override int Count => 0;
6061

61-
62-
63-
6462
private TfsTeamProjectCollection GetTfsCollection()
6563
{
6664
using (var activity = ActivitySourceProvider.ActivitySource.StartActivity("GetTfsCollection", ActivityKind.Client))
@@ -191,4 +189,4 @@ private Project GetTfsProject()
191189
return _Project;
192190
}
193191
}
194-
}
192+
}

src/MigrationTools.Clients.TfsObjectModel/Endpoints/TfsTeamProjectEndpoint.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ IServiceProvider Services
3939

4040
_workItemClient = ActivatorUtilities.CreateInstance<TfsWorkItemMigrationClient>(Services, this, options);
4141
//networkCredentials IOptions<NetworkCredentialsOptions> networkCredentials,
42-
4342
}
4443

44+
[Obsolete("Dont know what this is for")]
4545
public override int Count => 0;
4646

47-
4847
public IWorkItemMigrationClient WorkItems
4948
{
5049
get
@@ -177,4 +176,4 @@ public T GetClient<T>() where T : IVssHttpClient
177176
return _collection.GetClient<T>();
178177
}
179178
}
180-
}
179+
}

src/MigrationTools.Clients.TfsObjectModel/Endpoints/TfsWorkItemConvertor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private SortedDictionary<int, RevisionItem> GetRevisionItems(RevisionCollection
5858
var dictionary = items.ToDictionary(item => item.Number);
5959
return new SortedDictionary<int, RevisionItem>(dictionary);
6060
}
61-
catch (ArgumentException e)
61+
catch (ArgumentException)
6262
{
6363
Log.Warning("For some Reason there are multiple Revisions on {WorkItemId} with the same System.Rev. We will create a renumbered list...", items[0].WorkItemId);
6464
var currentNumber = -1;

src/MigrationTools.Clients.TfsObjectModel/Processors/TfsExportUsersForMappingProcessorOptions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ public class TfsExportUsersForMappingProcessorOptions : ProcessorOptions
1010

1111
public string WIQLQuery { get; set; }
1212

13-
/// `OnlyListUsersInWorkItems`
13+
/// <summary>
14+
/// `OnlyListUsersInWorkItems`
1415
/// </summary>
1516
/// <default>true</default>
1617
public bool OnlyListUsersInWorkItems { get; set; } = true;
1718

1819
}
19-
}
20+
}

src/MigrationTools.Clients.TfsObjectModel/Processors/TfsTestPlansAndSuitesMigrationProcessorOptions.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,10 @@ public class TfsTestPlansAndSuitesMigrationProcessorOptions : ProcessorOptions
4343

4444
public bool FilterCompleted { get; set; }
4545

46-
/// <inheritdoc />
47-
public bool IsProcessorCompatible(IReadOnlyList<IProcessorConfig> otherProcessors)
48-
{
49-
return true;
50-
}
51-
5246
public TfsTestPlansAndSuitesMigrationProcessorOptions()
5347
{
5448
MigrationDelay = 0;
5549
RemoveAllLinks = false;
5650
}
5751
}
58-
}
52+
}

src/MigrationTools.Clients.TfsObjectModel/Processors/TfsTestVariablesMigrationProcessorOptions.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,10 @@ namespace MigrationTools.Processors
77
{
88
public class TfsTestVariablesMigrationProcessorOptions : ProcessorOptions
99
{
10-
/// <inheritdoc />
11-
public bool Enabled { get; set; }
12-
1310
/// <inheritdoc />
1411
public string Processor
1512
{
1613
get { return "TestVariablesMigrationContext"; }
1714
}
18-
19-
/// <inheritdoc />
20-
public bool IsProcessorCompatible(IReadOnlyList<IProcessorConfig> otherProcessors)
21-
{
22-
return true;
23-
}
2415
}
25-
}
16+
}

0 commit comments

Comments
 (0)