Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Hjelm committed Oct 14, 2023
1 parent 5c37749 commit 2d80c5c
Show file tree
Hide file tree
Showing 44 changed files with 186 additions and 226 deletions.
6 changes: 3 additions & 3 deletions src/WorkItemMigrator/JiraExport/IJiraProvider.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using Atlassian.Jira;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Atlassian.Jira;
using Newtonsoft.Json.Linq;
using static JiraExport.JiraProvider;

namespace JiraExport
Expand Down
15 changes: 6 additions & 9 deletions src/WorkItemMigrator/JiraExport/JiraCommandLine.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

using Common.Config;

using Common.Config;
using Microsoft.Extensions.CommandLineUtils;

using Migration.Common.Config;
using Migration.Common.Log;
using Migration.WIContract;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using static JiraExport.JiraProvider;

namespace JiraExport
Expand Down
17 changes: 8 additions & 9 deletions src/WorkItemMigrator/JiraExport/JiraItem.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

using Atlassian.Jira;
using Atlassian.Jira;
using Migration.Common;
using Migration.Common.Log;

using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace JiraExport
{
Expand Down Expand Up @@ -37,7 +35,7 @@ private static List<JiraRevision> BuildRevisions(JiraItem jiraItem, IJiraProvide
string issueKey = jiraItem.Key;
var remoteIssue = jiraItem.RemoteIssue;
Dictionary<string, object> fieldsTemp = ExtractFields(issueKey, remoteIssue, jiraProvider);

// Add CustomFieldName fields, copy over all non-custom fields.
// These get removed as we loop over the changeLog, so we're left with the original Jira values by the time we reach firstRevision.
Dictionary<string, object> fields = new Dictionary<string, object>(StringComparer.InvariantCultureIgnoreCase);
Expand All @@ -47,7 +45,8 @@ private static List<JiraRevision> BuildRevisions(JiraItem jiraItem, IJiraProvide
if (!String.IsNullOrEmpty(key))
{
fields[key] = field.Value;
} else
}
else
{
fields[field.Key] = field.Value;
}
Expand Down
13 changes: 6 additions & 7 deletions src/WorkItemMigrator/JiraExport/JiraMapper.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Common.Config;

using Common.Config;
using Migration.Common;
using Migration.Common.Config;
using Migration.Common.Log;
using Migration.WIContract;
using System;
using System.Collections.Generic;
using System.Linq;

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Migration.Jira-Export.Tests")]

Expand Down Expand Up @@ -371,7 +370,7 @@ private HashSet<string> InitializeTypeMappings()
private Func<JiraRevision, (bool, object)> IfChanged<T>(string sourceField, bool isCustomField, Func<T, object> mapperFunc = null)
{
// Store both the customFieldName and the sourceField as the changelog seems to only use the customFieldName, which is then passed into this function as the sourceField.
string customFieldName="";
string customFieldName = "";
if (isCustomField)
{
customFieldName = _jiraProvider.GetCustomId(sourceField);
Expand All @@ -391,7 +390,7 @@ private HashSet<string> InitializeTypeMappings()
{
return (true, (T)value);
}
}
}
else if (r.Fields.TryGetValue(customFieldName.ToLower(), out value))
{
if (mapperFunc != null)
Expand Down
16 changes: 7 additions & 9 deletions src/WorkItemMigrator/JiraExport/JiraProvider.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using Atlassian.Jira;
using Atlassian.Jira;
using Atlassian.Jira.Remote;
using Migration.Common;
using Migration.Common.Log;

using Newtonsoft.Json.Linq;

using RestSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Web;

namespace JiraExport
{
Expand Down
4 changes: 2 additions & 2 deletions src/WorkItemMigrator/JiraExport/JiraRevision.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Migration.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using Migration.Common;

namespace JiraExport
{
Expand Down
4 changes: 2 additions & 2 deletions src/WorkItemMigrator/JiraExport/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Migration.Common.Log;
using Migration.Common.Log;
using System;

namespace JiraExport
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ public static object MapRemainingWork(string seconds)
var secs = 0d;
try
{
if(seconds == null)
if (seconds == null)
{
throw new FormatException();
}
secs = Convert.ToDouble(seconds);
} catch (FormatException)
}
catch (FormatException)
{
Logger.Log(LogLevel.Warning, $"A FormatException was thrown when converting RemainingWork value '{seconds}' to double. Defaulting to RemainingWork = null.");
return null;
Expand Down
8 changes: 4 additions & 4 deletions src/WorkItemMigrator/Migration.Common.Log/Logger.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;

namespace Migration.Common.Log
{
Expand Down
6 changes: 3 additions & 3 deletions src/WorkItemMigrator/Migration.Common.Log/VersionInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Newtonsoft.Json.Linq;
using Semver;
using System;
using System.Diagnostics;
using System.Net.Http;
using Newtonsoft.Json.Linq;
using Semver;

namespace Migration.Common.Log
{
Expand Down
4 changes: 2 additions & 2 deletions src/WorkItemMigrator/Migration.Common/BaseMapper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Migration.Common.Log;
using System;
using System.Collections.Generic;
using Migration.Common.Log;

namespace Migration.Common
{
Expand Down
12 changes: 6 additions & 6 deletions src/WorkItemMigrator/Migration.Common/Config/ConfigReaderJson.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using Common.Config;
using Migration.Common.Log;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Common.Config;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Migration.Common.Log;

namespace Migration.Common.Config
{
Expand Down Expand Up @@ -87,7 +87,7 @@ public ConfigJson DeserializeText(string input)
}
result.TypeMap.Types.AddRange(types);

if(obj.ContainsKey("repository-map"))
if (obj.ContainsKey("repository-map"))
{
var repositories = obj.SelectToken("repository-map.repository").Select(li => li.ToObject<Repository>()).ToList();
if (result.RepositoryMap.Repositories == null)
Expand Down
8 changes: 4 additions & 4 deletions src/WorkItemMigrator/Migration.Common/MigrationContext.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Common.Config;
using Common.Config;
using Migration.Common.Log;
using Migration.WIContract;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Migration.Common
{
Expand Down
4 changes: 2 additions & 2 deletions src/WorkItemMigrator/Migration.Common/RevisionUtility.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Migration.WIContract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Migration.WIContract;

namespace Migration.Common
{
Expand Down
5 changes: 2 additions & 3 deletions src/WorkItemMigrator/Migration.Common/UserMapper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Collections.Generic;
using Migration.Common.Log;
using System.Collections.Generic;
using System.IO;

using Migration.Common.Log;

namespace Migration.Common
{
public static class UserMapper
Expand Down
8 changes: 3 additions & 5 deletions src/WorkItemMigrator/Migration.WIContract/WiItemProvider.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using Migration.Common.Log;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;

using Migration.Common.Log;

using Newtonsoft.Json;

namespace Migration.WIContract
{
public class WiItemProvider
Expand Down
20 changes: 8 additions & 12 deletions src/WorkItemMigrator/WorkItemImport/Agent.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.Operations;

using Migration.Common;
using Migration.Common.Log;
using Migration.WIContract;

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using VsWebApi = Microsoft.VisualStudio.Services.WebApi;
using WebApi = Microsoft.TeamFoundation.WorkItemTracking.WebApi;
using WebModel = Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;

using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
using System.IO;

namespace WorkItemImport
{
public class Agent
Expand Down
4 changes: 2 additions & 2 deletions src/WorkItemMigrator/WorkItemImport/ExecutionPlan.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using Migration.Common;
using Migration.Common;
using Migration.WIContract;
using System.Collections.Generic;

namespace WorkItemImport
{
Expand Down
6 changes: 3 additions & 3 deletions src/WorkItemMigrator/WorkItemImport/ExecutionPlanBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Migration.Common;
using Migration.Common.Log;
using System;
using System.Collections.Generic;
using System.IO;
using Migration.Common;
using Migration.Common.Log;

namespace WorkItemImport
{
Expand Down
16 changes: 7 additions & 9 deletions src/WorkItemMigrator/WorkItemImport/ImportCommandLine.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Common.Config;

using Common.Config;
using Microsoft.Extensions.CommandLineUtils;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;

using Migration.Common;
using Migration.Common.Config;
using Migration.Common.Log;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;

namespace WorkItemImport
{
Expand Down Expand Up @@ -143,7 +141,7 @@ private bool ExecuteMigration(CommandOption token, CommandOption url, CommandOpt
importedItems++;

// Artifical wait (optional) to avoid throttling for ADO Services
if(config.SleepTimeBetweenRevisionImportMilliseconds > 0)
if (config.SleepTimeBetweenRevisionImportMilliseconds > 0)
{
Thread.Sleep(config.SleepTimeBetweenRevisionImportMilliseconds);
}
Expand Down
4 changes: 2 additions & 2 deletions src/WorkItemMigrator/WorkItemImport/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Migration.Common.Log;
using Migration.Common.Log;
using System;

namespace WorkItemImport
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
using Microsoft.VisualStudio.Services.WebApi.Patch.Json;
using Migration.WIContract;
using System;
using System.Collections.Generic;

namespace WorkItemImport
{
Expand Down
Loading

0 comments on commit 2d80c5c

Please sign in to comment.