diff --git a/starsky/starsky.foundation.database/Helpers/FileIndexCompareHelper.cs b/starsky/starsky.foundation.database/Helpers/FileIndexCompareHelper.cs index f24d72fa3c..fbfcfe35e7 100644 --- a/starsky/starsky.foundation.database/Helpers/FileIndexCompareHelper.cs +++ b/starsky/starsky.foundation.database/Helpers/FileIndexCompareHelper.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using starsky.foundation.database.Models; @@ -141,6 +142,8 @@ public static FileIndexItem Set(FileIndexItem? sourceIndexItem, string fieldName /// /// name e.g. Tags /// bool, true=exist + [SuppressMessage("Usage", "Collection-specific Exists " + + "method should be used instead of the Any extension.")] public static bool CheckIfPropertyExist(string fieldName) { PropertyInfo[] propertiesA = new FileIndexItem().GetType().GetProperties( diff --git a/starsky/starsky.foundation.sync/SyncServices/SyncFolder.cs b/starsky/starsky.foundation.sync/SyncServices/SyncFolder.cs index 058f7e6941..d841ea9bfb 100644 --- a/starsky/starsky.foundation.sync/SyncServices/SyncFolder.cs +++ b/starsky/starsky.foundation.sync/SyncServices/SyncFolder.cs @@ -137,7 +137,7 @@ internal async Task CompareFolderListAndFixMissingFolders(List subPaths, { if ( subPaths.Count == folderList.Count ) return; - foreach ( var path in subPaths.Where(path => folderList.All(p => p.FilePath != path) && + foreach ( var path in subPaths.Where(path => folderList.TrueForAll(p => p.FilePath != path) && _subPathStorage.ExistFolder(path) && !_syncIgnoreCheck.Filter(path) ) ) { await _query.AddItemAsync(new FileIndexItem(path) @@ -155,7 +155,7 @@ internal async Task> AddParentFolder(string subPath, List p.FilePath).ToList(); - if ( allResults.All(p => p.FilePath != subPath)) + if ( allResults.TrueForAll(p => p.FilePath != subPath)) { var subPathStatus = _subPathStorage.IsFolderOrFile(subPath); var exifStatus = subPathStatus == @@ -301,7 +301,7 @@ internal static List PathsToUpdateInDatabase( var resultDatabaseItems = new List(databaseItems); foreach ( var path in pathsOnDisk ) { - var item = databaseItems.FirstOrDefault(p => string.Equals(p.FilePath, path, StringComparison.InvariantCultureIgnoreCase)); + var item = databaseItems.Find(p => string.Equals(p.FilePath, path, StringComparison.InvariantCultureIgnoreCase)); if (item == null ) // when the file should be added to the index { // Status is used by MultiFile diff --git a/starsky/starsky.foundation.sync/SyncServices/SyncMultiFile.cs b/starsky/starsky.foundation.sync/SyncServices/SyncMultiFile.cs index 17e90b38ba..262b2417b6 100644 --- a/starsky/starsky.foundation.sync/SyncServices/SyncMultiFile.cs +++ b/starsky/starsky.foundation.sync/SyncServices/SyncMultiFile.cs @@ -50,7 +50,7 @@ internal async Task> MultiFile(List subPathInFiles, var resultDatabaseItems = new List(); foreach ( var path in subPathInFiles ) { - var item = databaseItems.FirstOrDefault(p => + var item = databaseItems.Find(p => string.Equals(p.FilePath, path, StringComparison.InvariantCultureIgnoreCase)); if (item == null ) // when the file should be added to the index { diff --git a/starsky/starsky.foundation.sync/SyncServices/SyncSingleFile.cs b/starsky/starsky.foundation.sync/SyncServices/SyncSingleFile.cs index 7a782fc66a..d4acaff790 100644 --- a/starsky/starsky.foundation.sync/SyncServices/SyncSingleFile.cs +++ b/starsky/starsky.foundation.sync/SyncServices/SyncSingleFile.cs @@ -44,7 +44,7 @@ internal async Task> SingleFile(string subPath, ISynchronize.SocketUpdateDelegate? updateDelegate = null) { // when item does not exist in db - if ( dbItems?.FirstOrDefault(p => p.FilePath == subPath) == null ) + if ( dbItems?.Find(p => p.FilePath == subPath) == null ) { return await SingleFile(subPath); } @@ -91,7 +91,7 @@ internal async Task> SingleFile(string subPath, scanItems.Add(item); } - foreach ( var item in dbItems.Where(item => scanItems.All(p => p.FilePath != item.FilePath)) ) + foreach ( var item in dbItems.Where(item => scanItems.TrueForAll(p => p.FilePath != item.FilePath)) ) { scanItems.Add(item); } diff --git a/starsky/starsky/Program.cs b/starsky/starsky/Program.cs index 3bc66fe64e..763f0d7d65 100644 --- a/starsky/starsky/Program.cs +++ b/starsky/starsky/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -13,6 +14,8 @@ namespace starsky { public static class Program { + [SuppressMessage("Usage", "S6603: The collection-specific TrueForAll " + + "method should be used instead of the All extension")] public static async Task Main(string[] args) { var appSettingsPath = Path.Join( diff --git a/starsky/starsky/clientapp/src/components/atoms/list-image/list-image.tsx b/starsky/starsky/clientapp/src/components/atoms/list-image/list-image.tsx index 9592cc77f7..f465b528b8 100644 --- a/starsky/starsky/clientapp/src/components/atoms/list-image/list-image.tsx +++ b/starsky/starsky/clientapp/src/components/atoms/list-image/list-image.tsx @@ -98,11 +98,12 @@ const ListImage: React.FunctionComponent = memo((props) => { ); } - const className = error - ? `img-box--error img-box--${props.imageFormat}` - : isLoading - ? "img-box img-box--loading" - : "img-box"; + let className = "img-box"; + if (error) { + className += ` img-box--error img-box--${props.imageFormat}`; + } else if (isLoading) { + className += " img-box--loading"; + } return (
diff --git a/starsky/starsky/clientapp/src/components/molecules/force-sync-wait-button/force-sync-wait-button.tsx b/starsky/starsky/clientapp/src/components/molecules/force-sync-wait-button/force-sync-wait-button.tsx index 59b51e2693..e99c9a16dc 100644 --- a/starsky/starsky/clientapp/src/components/molecules/force-sync-wait-button/force-sync-wait-button.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/force-sync-wait-button/force-sync-wait-button.tsx @@ -55,7 +55,7 @@ const ForceSyncWaitButton: React.FunctionComponent< ForceSyncWaitButtonPropTypes > = ({ propsParentFolder, historyLocationSearch, callback, dispatch }) => { function forceSync(): Promise { - const parentFolder = propsParentFolder ? propsParentFolder : "/"; + const parentFolder = propsParentFolder ?? "/"; setIsLoading(true); new FileListCache().CacheCleanEverything(); diff --git a/starsky/starsky/clientapp/src/components/organisms/modal-archive-synchronize-manually/modal-archive-synchronize-manually.tsx b/starsky/starsky/clientapp/src/components/organisms/modal-archive-synchronize-manually/modal-archive-synchronize-manually.tsx index 538472fc42..f6be9712a2 100644 --- a/starsky/starsky/clientapp/src/components/organisms/modal-archive-synchronize-manually/modal-archive-synchronize-manually.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/modal-archive-synchronize-manually/modal-archive-synchronize-manually.tsx @@ -79,7 +79,7 @@ const ModalArchiveSynchronizeManually: React.FunctionComponent< function removeCache() { setIsLoading(true); new FileListCache().CacheCleanEverything(); - const parentFolder = props.parentFolder ? props.parentFolder : "/"; + const parentFolder = props.parentFolder ?? "/"; FetchGet( new UrlQuery().UrlRemoveCache(new URLPath().encodeURI(parentFolder)) ).then((_) => { @@ -106,7 +106,7 @@ const ModalArchiveSynchronizeManually: React.FunctionComponent< const [geoSyncPercentage, setGeoSyncPercentage] = useState(0); function geoSync() { - const parentFolder = props.parentFolder ? props.parentFolder : "/"; + const parentFolder = props.parentFolder ?? "/"; const bodyParams = new URLSearchParams(); bodyParams.set("f", parentFolder); @@ -116,7 +116,7 @@ const ModalArchiveSynchronizeManually: React.FunctionComponent< } function fetchGeoSyncStatus() { - const parentFolder = props.parentFolder ? props.parentFolder : "/"; + const parentFolder = props.parentFolder ?? "/"; FetchGet( new UrlQuery().UrlGeoStatus(new URLPath().encodeURI(parentFolder)) ).then((anyData) => { @@ -136,7 +136,7 @@ const ModalArchiveSynchronizeManually: React.FunctionComponent< useInterval(() => fetchGeoSyncStatus(), 10000); function manualThumbnailSync() { - const parentFolder = props.parentFolder ? props.parentFolder : "/"; + const parentFolder = props.parentFolder ?? "/"; const bodyParams = new URLSearchParams(); bodyParams.set("f", parentFolder); setIsLoading(true); @@ -144,7 +144,7 @@ const ModalArchiveSynchronizeManually: React.FunctionComponent< FetchPost( new UrlQuery().UrlThumbnailGeneration(), bodyParams.toString() - ).then((anyData) => { + ).then((_) => { setTimeout(() => { setIsLoading(false); props.handleExit(); diff --git a/starsky/starsky/clientapp/src/components/organisms/preferences-app-settings/preferences-app-settings.tsx b/starsky/starsky/clientapp/src/components/organisms/preferences-app-settings/preferences-app-settings.tsx index 74c504417d..f0191a6261 100644 --- a/starsky/starsky/clientapp/src/components/organisms/preferences-app-settings/preferences-app-settings.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/preferences-app-settings/preferences-app-settings.tsx @@ -45,7 +45,7 @@ export const PreferencesAppSettings: React.FunctionComponent = (_) => { async function changeSetting(value: string, name?: string): Promise { const bodyParams = new URLSearchParams(); - bodyParams.set(name ? name : "", value); + bodyParams.set(name ?? "", value); const result = await FetchPost( new UrlQuery().UrlApiAppSettings(), bodyParams.toString()