Skip to content

Commit

Permalink
Use literals for all states in WITClientUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Hjelm committed Apr 29, 2024
1 parent 278432b commit 589c4ab
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/WorkItemMigrator/WorkItemImport/WitClient/WitClientUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class WitClientUtils
private const string Reverse = "Reverse";
private const string AttachedFile = "AttachedFile";
private const string Comment = "comment";
private const string New = "New";
private const string Resolved = "Resolved";
private const string Done = "Done";
private const string Closed = "Closed";

public WitClientUtils(IWitClientWrapper witClientWrapper)
{
Expand Down Expand Up @@ -798,20 +802,20 @@ private void CorrectClosedByAndClosedDate(WiRevision rev, WorkItem wi)

if (
(
wiState.Equals("Done", StringComparison.InvariantCultureIgnoreCase)
|| wiState.Equals("Closed", StringComparison.InvariantCultureIgnoreCase)
wiState.Equals(Done, StringComparison.InvariantCultureIgnoreCase)
|| wiState.Equals(Closed, StringComparison.InvariantCultureIgnoreCase)
)
&& !(revState.Equals("Done", StringComparison.InvariantCultureIgnoreCase)
|| revState.Equals("Closed", StringComparison.InvariantCultureIgnoreCase))
&& !(revState.Equals(Done, StringComparison.InvariantCultureIgnoreCase)
|| revState.Equals(Closed, StringComparison.InvariantCultureIgnoreCase))
)
{
rev.Fields.Add(new WiField() { ReferenceName = WiFieldReference.ClosedDate, Value = "" });
rev.Fields.Add(new WiField() { ReferenceName = WiFieldReference.ClosedBy, Value = "" });
}

if (
revState.Equals("Done", StringComparison.InvariantCultureIgnoreCase)
|| revState.Equals("Closed", StringComparison.InvariantCultureIgnoreCase)
revState.Equals(Done, StringComparison.InvariantCultureIgnoreCase)
|| revState.Equals(Closed, StringComparison.InvariantCultureIgnoreCase)
)
{
if (!rev.Fields.HasAnyByRefName(WiFieldReference.ClosedDate))
Expand All @@ -826,13 +830,13 @@ private void CorrectActivatedByAndActivatedDate(WiRevision rev, WorkItem wi)
var wiState = wi.Fields[WiFieldReference.State].ToString() ?? string.Empty;
var revState = rev.Fields.GetFieldValueOrDefault<string>(WiFieldReference.State) ?? string.Empty;

if (!wiState.Equals("New", StringComparison.InvariantCultureIgnoreCase) && revState.Equals("New", StringComparison.InvariantCultureIgnoreCase))
if (!wiState.Equals(New, StringComparison.InvariantCultureIgnoreCase) && revState.Equals(New, StringComparison.InvariantCultureIgnoreCase))
{
rev.Fields.Add(new WiField() { ReferenceName = WiFieldReference.ActivatedDate, Value = "" });
rev.Fields.Add(new WiField() { ReferenceName = WiFieldReference.ActivatedBy, Value = "" });
}

if (wiState.Equals("New", StringComparison.InvariantCultureIgnoreCase) && !revState.Equals("New", StringComparison.InvariantCultureIgnoreCase))
if (wiState.Equals(New, StringComparison.InvariantCultureIgnoreCase) && !revState.Equals(New, StringComparison.InvariantCultureIgnoreCase))
{
if (!rev.Fields.HasAnyByRefName(WiFieldReference.ActivatedDate))
rev.Fields.Add(new WiField() { ReferenceName = WiFieldReference.ActivatedDate, Value = rev.Time });
Expand All @@ -847,23 +851,23 @@ private void CorrectResolvedByAndResolvedDate(WiRevision rev, WorkItem wi)
var wiState = wi.Fields[WiFieldReference.State].ToString() ?? string.Empty;
var revState = rev.Fields.GetFieldValueOrDefault<string>(WiFieldReference.State) ?? string.Empty;

if ((wiState.Equals("Resolved", StringComparison.InvariantCultureIgnoreCase)
|| wiState.Equals("Done", StringComparison.InvariantCultureIgnoreCase)
|| wiState.Equals("Closed", StringComparison.InvariantCultureIgnoreCase))
&& !revState.Equals("Resolved", StringComparison.InvariantCultureIgnoreCase)
&& !revState.Equals("Done", StringComparison.InvariantCultureIgnoreCase)
&& !revState.Equals("Closed", StringComparison.InvariantCultureIgnoreCase))
if ((wiState.Equals(Resolved, StringComparison.InvariantCultureIgnoreCase)
|| wiState.Equals(Done, StringComparison.InvariantCultureIgnoreCase)
|| wiState.Equals(Closed, StringComparison.InvariantCultureIgnoreCase))
&& !revState.Equals(Resolved, StringComparison.InvariantCultureIgnoreCase)
&& !revState.Equals(Done, StringComparison.InvariantCultureIgnoreCase)
&& !revState.Equals(Closed, StringComparison.InvariantCultureIgnoreCase))
{
rev.Fields.Add(new WiField() { ReferenceName = WiFieldReference.ResolvedDate, Value = "" });
rev.Fields.Add(new WiField() { ReferenceName = WiFieldReference.ResolvedBy, Value = "" });
}

if ((revState.Equals("Resolved", StringComparison.InvariantCultureIgnoreCase)
&& !wiState.Equals("Done", StringComparison.InvariantCultureIgnoreCase)
&& !wiState.Equals("Closed", StringComparison.InvariantCultureIgnoreCase))
|| ((revState.Equals("Done", StringComparison.InvariantCultureIgnoreCase)
|| revState.Equals("Closed", StringComparison.InvariantCultureIgnoreCase))
&& !wiState.Equals("Resolved", StringComparison.InvariantCultureIgnoreCase)))
if ((revState.Equals(Resolved, StringComparison.InvariantCultureIgnoreCase)
&& !wiState.Equals(Done, StringComparison.InvariantCultureIgnoreCase)
&& !wiState.Equals(Closed, StringComparison.InvariantCultureIgnoreCase))
|| ((revState.Equals(Done, StringComparison.InvariantCultureIgnoreCase)
|| revState.Equals(Closed, StringComparison.InvariantCultureIgnoreCase))
&& !wiState.Equals(Resolved, StringComparison.InvariantCultureIgnoreCase)))
{
if (!rev.Fields.HasAnyByRefName(WiFieldReference.ResolvedDate))
rev.Fields.Add(new WiField() { ReferenceName = WiFieldReference.ResolvedDate, Value = rev.Time });
Expand Down

0 comments on commit 589c4ab

Please sign in to comment.