Skip to content

Commit

Permalink
Resharper Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SirSparkles committed Dec 9, 2021
1 parent 9c8a3f0 commit e1e5fd8
Show file tree
Hide file tree
Showing 43 changed files with 185 additions and 217 deletions.
2 changes: 1 addition & 1 deletion TVRename/Exporter/UpcomingiCAL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected override bool Generate(System.IO.Stream str, IEnumerable<ProcessedEpis
{
Calendar calendar = new() { ProductId = "Upcoming Shows Exported by TV Rename http://www.tvrename.com" };

foreach (CalendarEvent ev in episodes.Select(CreateEvent).Where(ev => !(ev is null)))
foreach (CalendarEvent ev in episodes.Select(CreateEvent).Where(ev => ev is not null))
{
calendar.Events.Add(ev);
}
Expand Down
8 changes: 4 additions & 4 deletions TVRename/Forms/BulkAddMovies/BulkAddMovie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void bnRemoveMonFolder_Click(object sender, System.EventArgs e)
DeleteSelectedFolder(lstFMMonitorFolders, TVSettings.Instance.MovieLibraryFolders);
}

private void DeleteSelectedFolder([NotNull] ListBox lb, SafeList<string> folders)
private void DeleteSelectedFolder([NotNull] ListBox lb, IList<string> folders)
{
for (int i = lb.SelectedIndices.Count - 1; i >= 0; i--)
{
Expand Down Expand Up @@ -252,7 +252,7 @@ private void lstFMIgnoreFolders_DragDrop(object _, [NotNull] DragEventArgs e)
AddDraggedFiles(e, TVSettings.Instance.IgnoreFolders);
}

private void AddDraggedFiles([NotNull] DragEventArgs e, SafeList<string> strings)
private void AddDraggedFiles([NotNull] DragEventArgs e, ICollection<string> strings)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string path in files)
Expand Down Expand Up @@ -303,7 +303,7 @@ private void bnFullAuto_Click(object sender, System.EventArgs e)
bwIdentify.RunWorkerAsync();
}

private void AutoMatchMovie([NotNull] CancellationTokenSource cts, PossibleNewMovie ai, BackgroundWorker bw, int total)
private static void AutoMatchMovie([NotNull] CancellationTokenSource cts, PossibleNewMovie ai, BackgroundWorker bw, int total)
{
if (cts.IsCancellationRequested)
{
Expand Down Expand Up @@ -605,7 +605,7 @@ private void bwIdentify_ProgressChanged(object sender, [NotNull] ProgressChanged
{
lvFMNewShows.Update();

pbProgress.Value = e.ProgressPercentage.Between(0,100);
pbProgress.Value = e.ProgressPercentage.Between(0,100);
lblStatusLabel.Text = ((PossibleNewMovie)e.UserState).RefinedHint;
UpdateListItem((PossibleNewMovie)e.UserState, false);
}
Expand Down
5 changes: 2 additions & 3 deletions TVRename/Forms/ShowPreferences/EditSeason.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ private void FillSeenEpisodes(bool keepSel)
{
if (i < lvSeenEpisodes.Items.Count)
{
int n = i;
if (n >= 0 && n < lvSeenEpisodes.Items.Count)
if (i >= 0 && i < lvSeenEpisodes.Items.Count)
{
lvSeenEpisodes.Items[n].Selected = true;
lvSeenEpisodes.Items[i].Selected = true;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/Forms/Supporting/CopyMoveProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private void cbPause_CheckedChanged(object sender, EventArgs e)

private void CopyMoveProgress_SizeChanged(object sender, EventArgs e)
{
if (!(sender is Form {WindowState: FormWindowState.Minimized} childWindow))
if (sender is not Form {WindowState: FormWindowState.Minimized} childWindow)
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/Forms/Tools/MergedEpisodeFinder.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 13 additions & 13 deletions TVRename/Forms/Tools/MergedEpisodeFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ private void chkNameTest_CheckedChanged(object sender, EventArgs e)
UpdateUI();
}

private void chkMIssingTest_CheckedChanged(object sender, EventArgs e)
private void chkMissingTest_CheckedChanged(object sender, EventArgs e)
{
if (!chkMIssingTest.Checked)
switch (chkMIssingTest.Checked)
{
chkFilesizeTest.Checked = false;
}

if (chkMIssingTest.Checked)
{
chkNameTest.Checked = true;
case false:
chkFilesizeTest.Checked = false;
break;
case true:
chkNameTest.Checked = true;
break;
}

UpdateUI();
Expand Down Expand Up @@ -113,7 +113,7 @@ private void lvDuplicates_MouseClick(object sender, [NotNull] MouseEventArgs e)
}

PossibleMergedEpisode? mlastSelected = (PossibleMergedEpisode)lvMergedEpisodes.SelectedItems[0].Tag;
ListViewItem? mlastClicked = lvMergedEpisodes.SelectedItems[0];
ListViewItem? mLastClicked = lvMergedEpisodes.SelectedItems[0];
ShowConfiguration? si = mlastSelected?.ShowConfiguration;

if (si == null)
Expand All @@ -133,7 +133,7 @@ private void lvDuplicates_MouseClick(object sender, [NotNull] MouseEventArgs e)
(_, _) => mainUi.EditSeason(si, mlastSelected.SeasonNumber));

possibleMergedEpisodeRightClickMenu.Items.Add(new ToolStripSeparator());
AddRcMenuItem("Add Rule", (_, _) => AddRule(mlastSelected, si, mlastClicked));
AddRcMenuItem("Add Rule", (_, _) => AddRule(mlastSelected, si, mLastClicked));

possibleMergedEpisodeRightClickMenu.Show(pt);
}
Expand All @@ -155,11 +155,11 @@ private void AddRule([NotNull] PossibleMergedEpisode selected, [NotNull] ShowCon
dupEps.Remove(selected);
}

private void GotoEpGuide(ShowConfiguration? si, PossibleMergedEpisode? mlastSelected)
private void GotoEpGuide(ShowConfiguration? si, PossibleMergedEpisode? mLastSelected)
{
if (mlastSelected != null)
if (mLastSelected != null)
{
mainUi.GotoEpguideFor(mlastSelected.Episode, true);
mainUi.GotoEpguideFor(mLastSelected.Episode, true);
}
else
{
Expand Down
19 changes: 7 additions & 12 deletions TVRename/Forms/Tools/OrphanFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ private static object GroupFolderTitleDelegate(object rowObject)
private static object GroupSeasonKeyDelegate(object rowObject)
{
FileIssue ep = (FileIssue)rowObject;
if (ep.SeasonNumber.HasValue)
{
return $"{ep.Showname} - Season {ep.SeasonNumber}";
}

return ep.Showname;
return ep.SeasonNumber.HasValue ? $"{ep.Showname} - Season {ep.SeasonNumber}" : ep.Showname;
}

private void OlvFileIssues_MouseClick(object sender, [NotNull] MouseEventArgs e)
Expand All @@ -62,7 +57,7 @@ private void OlvFileIssues_MouseClick(object sender, [NotNull] MouseEventArgs e)
}

Point pt = ((ListView)sender).PointToScreen(new Point(e.X, e.Y));
if (!(olvFileIssues.FocusedObject is FileIssue iss))
if (olvFileIssues.FocusedObject is not FileIssue iss)
{
return;
}
Expand Down Expand Up @@ -120,14 +115,14 @@ private void UpdateIssues(BackgroundWorker bw)

foreach (KeyValuePair<int, SafeList<string>> showfolders in folders)
{
foreach (string showfolder in showfolders.Value)
foreach (string showFolder in showfolders.Value)
{
if (doneFolders.Contains(showfolder))
if (doneFolders.Contains(showFolder))
{
continue;
}
doneFolders.Add(showfolder);
foreach (FileInfo file in new DirectoryInfo(showfolder).GetFiles()
doneFolders.Add(showFolder);
foreach (FileInfo file in new DirectoryInfo(showFolder).GetFiles()
.Where(file => file.IsMovieFile()))
{
FinderHelper.FindSeasEp(file, out int seasonNumber, out int episodeNumber, out int _, show);
Expand All @@ -136,7 +131,7 @@ private void UpdateIssues(BackgroundWorker bw)
{
issues.Add(new FileIssue(show, file, "File does not match a Filename Processor"));
}
else if (folders.ContainsKey(seasonNumber) && !folders[seasonNumber].Contains(showfolder))
else if (folders.ContainsKey(seasonNumber) && !folders[seasonNumber].Contains(showFolder))
{
issues.Add(new FileIssue(show, file, "File is in the wrong cachedSeries folder", seasonNumber, episodeNumber));
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/Forms/Tools/RecommendationView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ private void lvRecommendations_CellRightClick(object sender, [NotNull] BrightIde

private void lvRecommendations_ItemSelectionChanged(object sender, [NotNull] ListViewItemSelectionChangedEventArgs e)
{
if (!((e.Item as BrightIdeasSoftware.OLVListItem)?.RowObject is RecommendationRow rr))
if ((e.Item as BrightIdeasSoftware.OLVListItem)?.RowObject is not RecommendationRow rr)
{
return;
}
Expand Down
14 changes: 7 additions & 7 deletions TVRename/Forms/UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ private static bool UseCustom([NotNull] ListView view)
{
foreach (ListViewItem lvi in view.SelectedItems)
{
if (!(lvi.Tag is ProcessedEpisode pe))
if (lvi.Tag is not ProcessedEpisode pe)
{
continue;
}
Expand Down Expand Up @@ -3726,7 +3726,7 @@ private void SetCheckboxes()
if (2 * mDoc.TheActionList.Actions.Count > mDoc.TheActionList.Count)
{
olvAction.CheckAll();
foreach (Item i in mDoc.TheActionList.Where(i => !(i is Action)))
foreach (Item i in mDoc.TheActionList.Where(i => i is not Action))
{
olvAction.UncheckObject(i);
}
Expand Down Expand Up @@ -4131,7 +4131,7 @@ private void olvAction_ItemCheck(object sender, [NotNull] ItemCheckEventArgs e)
}

//Needed to de-select any un action able items
if (olvAction.GetModelObject(e.Index) is Item action && !(action is Action))
if (olvAction.GetModelObject(e.Index) is Item action && action is not Action)
{
e.NewValue = CheckState.Unchecked;
}
Expand Down Expand Up @@ -4697,7 +4697,7 @@ private void BwUpdateSchedule_DoWork(object sender, [NotNull] DoWorkEventArgs e)

private void BwUpdateSchedule_RunWorkerCompleted(object sender, [NotNull] RunWorkerCompletedEventArgs e)
{
if (!(e.Result is List<ListViewItem> newContents))
if (e.Result is not List<ListViewItem> newContents)
{
return;
}
Expand Down Expand Up @@ -4726,7 +4726,7 @@ private void BwUpdateSchedule_RunWorkerCompleted(object sender, [NotNull] RunWor

foreach (ListViewItem lvi in newContents)
{
if (!(lvi.Tag is ProcessedEpisode ei))
if (lvi.Tag is not ProcessedEpisode ei)
{
continue;
}
Expand Down Expand Up @@ -4827,7 +4827,7 @@ private void OlvAction_Dropped(object sender, [NotNull] OlvDropEventArgs e)

// Establish item in list being dragged to, and exit if no item matched
// Check at least one file was being dragged, and that dragged-to item is a "Missing Item" item.
if (files.Length <= 0 || !(e.DropTargetItem.RowObject is ItemMissing mi))
if (files.Length <= 0 || e.DropTargetItem.RowObject is not ItemMissing mi)
{
return;
}
Expand All @@ -4838,7 +4838,7 @@ private void OlvAction_Dropped(object sender, [NotNull] OlvDropEventArgs e)

private void OlvAction_CanDrop(object sender, [NotNull] OlvDropEventArgs e)
{
if (!(e.DropSink?.DropTargetItem?.RowObject is Item item))
if (e.DropSink?.DropTargetItem?.RowObject is not Item item)
{
e.Effect = DragDropEffects.None;
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionCopyMoveRename.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public override bool SameAs(Item o)

public override int CompareTo(Item o)
{
if (!(o is ActionCopyMoveRename cmr))
if (o is not ActionCopyMoveRename cmr)
{
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionDeleteDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override bool SameAs(Item o)

public override int CompareTo(Item o)
{
if (!(o is ActionDeleteDirectory cmr) || toRemove.Parent.FullName is null || cmr.toRemove.Parent.FullName is null)
if (o is not ActionDeleteDirectory cmr || toRemove.Parent.FullName is null || cmr.toRemove.Parent.FullName is null)
{
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionDownloadImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public override bool SameAs(Item o)

public override int CompareTo(Item o)
{
return !(o is ActionDownloadImage dl) ? -1 : string.Compare(destination.FullName, dl.destination.FullName, StringComparison.Ordinal);
return o is not ActionDownloadImage dl ? -1 : string.Compare(destination.FullName, dl.destination.FullName, StringComparison.Ordinal);
}

public override int IconNumber => 5;
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionMede8erViewXML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public override bool SameAs(Item o)

public override int CompareTo(Item o)
{
if (!(o is ActionMede8erViewXML nfo))
if (o is not ActionMede8erViewXML nfo)
{
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionMede8erXML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public override bool SameAs(Item o)

public override int CompareTo(Item o)
{
if (!(o is ActionMede8erXML nfo))
if (o is not ActionMede8erXML nfo)
{
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionMoveRenameDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public ActionMoveRenameDirectory(string sourceFolder, string targetFolder, Proce

public override int CompareTo(Item o)
{
if (!(o is ActionMoveRenameDirectory cmr))
if (o is not ActionMoveRenameDirectory cmr)
{
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionNFO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public override bool SameAs(Item o)

public override int CompareTo(Item o)
{
if (!(o is ActionNfo nfo))
if (o is not ActionNfo nfo)
{
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionNfoEpisode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private static void UpdateEpisodeFields([NotNull] Episode episode, ShowConfigura
UpdateRatings(root, showRating, episode.SiteRatingCount ?? 0);
}

if (!(show is null))
if (show is not null)
{
root.UpdateElement("originaltitle", show.ShowName, true);
root.UpdateElement("showtitle", show.ShowName, true);
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionNfoMovie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected override ActionOutcome UpdateFile()
//says that we need a format like this:
//<episodeguide><url post="yes" cache="auth.json">https://api.thetvdb.com/login?{&quot;apikey&quot;:&quot;((API-KEY))&quot;,&quot;id&quot;:((ID))}|Content-Type=application/json</url></episodeguide>

if (!(cachedSeries is null))
if (cachedSeries is not null)
{
root.UpdateElement("originaltitle", Movie.ShowName);
root.UpdateElement("sorttitle", UI.GenerateShowUiName(Movie));
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionNfoShow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected override ActionOutcome UpdateFile()
episodeGuideNode.UpdateElement("url",tmdbUrl);
}

if (!(cachedSeries is null))
if (cachedSeries is not null)
{
root.UpdateElement("originaltitle", SelectedShow.ShowName);
root.ReplaceElements("studio", cachedSeries.Networks);
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionPyTivoMeta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public override bool SameAs(Item o)

public override int CompareTo(Item obj)
{
if (!(obj is ActionPyTivoMeta nfo))
if (obj is not ActionPyTivoMeta nfo)
{
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionTDownload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private static string SaveDownloadedData(byte[] r, string name)

public override int CompareTo(Item o)
{
return !(o is ActionTDownload rss) ? -1 : string.Compare(url, rss.url, StringComparison.Ordinal);
return o is not ActionTDownload rss ? -1 : string.Compare(url, rss.url, StringComparison.Ordinal);
}

public override IgnoreItem? Ignore => GenerateIgnore(theFileNoExt);
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionTRemove.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ActionTRemove(IDownloadProvider source, TorrentEntry lastFoundEntry, Movi

public override int CompareTo(Item o)
{
return !(o is ActionTRemove rss) ? -1 : string.Compare(name.TorrentFile, rss.name.TorrentFile, StringComparison.Ordinal);
return o is not ActionTRemove rss ? -1 : string.Compare(name.TorrentFile, rss.name.TorrentFile, StringComparison.Ordinal);
}

[NotNull]
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/ActionWdtvMeta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private ActionOutcome WriteEpisodeMetaDataFile()

public override int CompareTo(Item o)
{
if (!(o is ActionWdtvMeta nfo))
if (o is not ActionWdtvMeta nfo)
{
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion TVRename/ItemsAndActions/MovieItemMissing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override bool SameAs(Item o)

public override int CompareTo(Item o)
{
if (!(o is MovieItemMissing miss))
if (o is not MovieItemMissing miss)
{
return -1;
}
Expand Down
Loading

0 comments on commit e1e5fd8

Please sign in to comment.