From b2c871ab2d7d12685b3e6fd36bb27b9324a3727b Mon Sep 17 00:00:00 2001 From: wallstop Date: Thu, 10 Sep 2026 22:57:30 +0000 Subject: [PATCH] Standardize ordered comparison direction --- .llm/context.md | 5 + .../Data/DataVisualizerSettings.cs | 4 +- .../Data/DataVisualizerUserState.cs | 4 +- .../Data/NamespaceCollapseState.cs | 5 +- .../DataVisualizer/Data/NamespaceTypeOrder.cs | 2 +- Editor/DataVisualizer/DataVisualizer.cs | 100 ++++++++++-------- Editor/DataVisualizer/NamespaceController.cs | 8 +- Editor/DataVisualizer/UI/HorizontalToggle.cs | 2 +- .../Utilities/AssetGuidDiscovery.cs | 4 +- .../Utilities/AssetGuidOrder.cs | 4 +- Runtime/Helper/DirectoryHelper.cs | 2 +- Tests/Editor/TypePopoverLayoutTests.cs | 2 +- 12 files changed, 77 insertions(+), 65 deletions(-) diff --git a/.llm/context.md b/.llm/context.md index d5170e5..5379d41 100644 --- a/.llm/context.md +++ b/.llm/context.md @@ -97,6 +97,11 @@ editing any skill with `pwsh -NoProfile -File scripts/generate-skills-index.ps1` files. Dot-folders (`.llm`, `.github`) never get `.meta` files. 18. Keep agent/dev files out of the npm tarball: `package.json` `files` whitelists only `Editor`, `Runtime`, `Tests`, `docs`, and their `.meta` companions. +19. Write explicit ordered comparisons with `<` or `<=`, reversing operands instead + of using `>` or `>=`. Relational patterns retain the operator required by C# + syntax. Keep `!=` when expressing genuine inequality or null checks; do not wrap + `==` in a negation merely to avoid it. Before reversing user-defined operators, + verify the swapped operands and paired operator preserve behavior. ### Skills Discipline diff --git a/Editor/DataVisualizer/Data/DataVisualizerSettings.cs b/Editor/DataVisualizer/Data/DataVisualizerSettings.cs index 3bfd8fb..6395c4b 100644 --- a/Editor/DataVisualizer/Data/DataVisualizerSettings.cs +++ b/Editor/DataVisualizer/Data/DataVisualizerSettings.cs @@ -182,7 +182,7 @@ internal bool SetLastObjectForType(string typeFullName, string guid) } if ( - existingIndex >= 0 + 0 <= existingIndex && string.Equals( lastObjectSelections[existingIndex].objectGuid, guid, @@ -193,7 +193,7 @@ internal bool SetLastObjectForType(string typeFullName, string guid) return false; } - if (existingIndex >= 0) + if (0 <= existingIndex) { lastObjectSelections[existingIndex].objectGuid = guid; } diff --git a/Editor/DataVisualizer/Data/DataVisualizerUserState.cs b/Editor/DataVisualizer/Data/DataVisualizerUserState.cs index 1ca802e..2aa9070 100644 --- a/Editor/DataVisualizer/Data/DataVisualizerUserState.cs +++ b/Editor/DataVisualizer/Data/DataVisualizerUserState.cs @@ -128,7 +128,7 @@ public bool SetLastObjectForType(string typeFullName, string guid) } if ( - existingIndex >= 0 + 0 <= existingIndex && string.Equals( lastObjectSelections[existingIndex].objectGuid, guid, @@ -139,7 +139,7 @@ public bool SetLastObjectForType(string typeFullName, string guid) return false; } - if (existingIndex >= 0) + if (0 <= existingIndex) { lastObjectSelections[existingIndex].objectGuid = guid; } diff --git a/Editor/DataVisualizer/Data/NamespaceCollapseState.cs b/Editor/DataVisualizer/Data/NamespaceCollapseState.cs index b86ffd6..25b4ed8 100644 --- a/Editor/DataVisualizer/Data/NamespaceCollapseState.cs +++ b/Editor/DataVisualizer/Data/NamespaceCollapseState.cs @@ -51,9 +51,10 @@ public static bool Remove(List states, string namespaceK return false; } - return states.RemoveAll(state => + return 0 + < states.RemoveAll(state => string.Equals(state?.namespaceKey, namespaceKey, StringComparison.Ordinal) - ) > 0; + ); } public NamespaceCollapseState Clone() diff --git a/Editor/DataVisualizer/Data/NamespaceTypeOrder.cs b/Editor/DataVisualizer/Data/NamespaceTypeOrder.cs index b1ba373..ddbed5b 100644 --- a/Editor/DataVisualizer/Data/NamespaceTypeOrder.cs +++ b/Editor/DataVisualizer/Data/NamespaceTypeOrder.cs @@ -53,7 +53,7 @@ IReadOnlyList typeFullNameOrder switch (indexA) { - case >= 0 when indexB >= 0: + case >= 0 when 0 <= indexB: return indexA.CompareTo(indexB); case >= 0: return -1; diff --git a/Editor/DataVisualizer/DataVisualizer.cs b/Editor/DataVisualizer/DataVisualizer.cs index 27c18ce..b25d3ef 100644 --- a/Editor/DataVisualizer/DataVisualizer.cs +++ b/Editor/DataVisualizer/DataVisualizer.cs @@ -601,7 +601,7 @@ out string normalizedSavedObjectGuid } // Start loading batches - if (_pendingSearchCacheGuids.Count > 0) + if (0 < _pendingSearchCacheGuids.Count) { ContinuePopulatingSearchCache(generation); } @@ -660,7 +660,7 @@ private void ContinuePopulatingSearchCache(int generation) _allManagedObjectsCache.AddRange(loadedObjects); // Continue with next batch - if (_pendingSearchCacheGuids.Count > 0) + if (0 < _pendingSearchCacheGuids.Count) { rootVisualElement .schedule.Execute(() => ContinuePopulatingSearchCache(generation)) @@ -709,7 +709,7 @@ private void RefreshActiveSearch() private static List DequeueBatch(Queue queue, int batchSize) { List batch = new(batchSize); - for (int i = 0; i < batchSize && queue.Count > 0; i++) + for (int i = 0; i < batchSize && 0 < queue.Count; i++) { batch.Add(queue.Dequeue()); } @@ -1265,7 +1265,7 @@ public void CreateGUI() { if ( !string.IsNullOrWhiteSpace(context._searchField.value) - && context._searchPopover.childCount > 0 + && 0 < context._searchPopover.childCount && context._activePopover != context._searchPopover ) { @@ -1449,7 +1449,7 @@ private static void LoadStyleSheetIfAvailable(VisualElement root) "/Packages/", StringComparison.OrdinalIgnoreCase ); - if (packagesIndex >= 0) + if (0 <= packagesIndex) { packagePath = normalizedPackageRoot.Substring(packagesIndex + 1); // +1 to skip the leading slash so the path starts at "Packages/" } @@ -2015,7 +2015,7 @@ private void HandleSearchKeyDown(KeyDownEvent evt) case KeyCode.DownArrow: { _searchHighlightIndex++; - if (_searchHighlightIndex >= _currentSearchResultItems.Count) + if (_currentSearchResultItems.Count <= _searchHighlightIndex) { _searchHighlightIndex = 0; } @@ -2038,7 +2038,7 @@ private void HandleSearchKeyDown(KeyDownEvent evt) case KeyCode.KeypadEnter: { if ( - _searchHighlightIndex >= 0 + 0 <= _searchHighlightIndex && _searchHighlightIndex < _currentSearchResultItems.Count ) { @@ -2240,7 +2240,7 @@ private void PerformSearch(string searchText) } results.Add((obj, matchInfo)); - if (results.Count >= MaxSearchResults) + if (MaxSearchResults <= results.Count) { break; } @@ -2262,7 +2262,7 @@ private void PerformSearch(string searchText) { scrollView.Add(listContainer); } - if (results.Count > 0) + if (0 < results.Count) { _searchPopover.style.maxHeight = StyleKeyword.Null; foreach ((ScriptableObject resultObj, SearchResultMatchInfo resultInfo) in results) @@ -2507,8 +2507,14 @@ params VisualElement[] contexts List> indices = new(); int start = 0; while ( - (start = fullText.IndexOf(term, start, StringComparison.OrdinalIgnoreCase)) - >= 0 + 0 + <= ( + start = fullText.IndexOf( + term, + start, + StringComparison.OrdinalIgnoreCase + ) + ) ) { indices.Add(Tuple.Create(start, term.Length)); @@ -2604,7 +2610,7 @@ private static MatchDetail SearchStringProperties( HashSet visited ) { - if (obj == null || currentDepth > maxDepth) + if (obj == null || maxDepth < currentDepth) { return null; } @@ -2826,8 +2832,8 @@ private void OnPopoverPointerMove(PointerMoveEvent evt) if ( !float.IsNaN(windowWidth) && !float.IsNaN(windowHeight) - && windowWidth > 0 - && windowHeight > 0 + && 0 < windowWidth + && 0 < windowHeight ) { clampedX = Mathf.Max(0, targetX); @@ -3034,25 +3040,25 @@ private void OpenPopover( popoverWidth = Mathf.Min( popoverWidth, - popover.resolvedStyle.maxWidth.value > 0 + 0 < popover.resolvedStyle.maxWidth.value ? popover.resolvedStyle.maxWidth.value : float.MaxValue ); popoverHeight = Mathf.Min( popoverHeight, - popover.resolvedStyle.maxHeight.value > 0 + 0 < popover.resolvedStyle.maxHeight.value ? popover.resolvedStyle.maxHeight.value : float.MaxValue ); popoverWidth = Mathf.Max( popoverWidth, - popover.resolvedStyle.minWidth.value > 0 + 0 < popover.resolvedStyle.minWidth.value ? popover.resolvedStyle.minWidth.value : 50f ); popoverHeight = Mathf.Max( popoverHeight, - popover.resolvedStyle.minHeight.value > 0 + 0 < popover.resolvedStyle.minHeight.value ? popover.resolvedStyle.minHeight.value : 30f ); @@ -3796,7 +3802,7 @@ private void HandleCreateConfirmed(Type type, TextField nameField, Label errorLa if ( string.IsNullOrWhiteSpace(newName) - || newName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 + || 0 <= newName.IndexOfAny(Path.GetInvalidFileNameChars()) ) { errorLabel.text = "Invalid name."; @@ -3911,7 +3917,7 @@ private void HandleRenameConfirmed(Label titleLabel, TextField nameField, Label if ( string.IsNullOrWhiteSpace(originalPath) || string.IsNullOrWhiteSpace(newName) - || newName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 + || 0 <= newName.IndexOfAny(Path.GetInvalidFileNameChars()) ) { errorLabel.text = "Invalid name."; @@ -4441,7 +4447,7 @@ private void BuildTypeAddList(string filter = null) List searchTerms = string.IsNullOrWhiteSpace(filter) ? new List() : filter.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); - bool isFiltering = searchTerms.Count > 0; + bool isFiltering = 0 < searchTerms.Count; HashSet managedTypeFullNames = _namespaceController .GetAllManagedTypeNames() @@ -4487,7 +4493,7 @@ private void BuildTypeAddList(string filter = null) addableTypes.Add(type); } - if (addableTypes.Count > 0) + if (0 < addableTypes.Count) { foundMatches = true; @@ -4581,7 +4587,7 @@ private void BuildTypeAddList(string filter = null) }; header.userData = clickContext; - if (typesToShowInGroup.Count > 1) + if (1 < typesToShowInGroup.Count) { namespaceLabel.AddToClassList( "type-selection-list-namespace--not-empty" @@ -4727,7 +4733,7 @@ private void HandleTypePopoverKeyDown(KeyDownEvent evt) case KeyCode.DownArrow: { _typePopoverHighlightIndex++; - if (_typePopoverHighlightIndex >= _currentTypePopoverItems.Count) + if (_currentTypePopoverItems.Count <= _typePopoverHighlightIndex) { _typePopoverHighlightIndex = 0; } @@ -4750,7 +4756,7 @@ private void HandleTypePopoverKeyDown(KeyDownEvent evt) case KeyCode.KeypadEnter: { if ( - _typePopoverHighlightIndex >= 0 + 0 <= _typePopoverHighlightIndex && _typePopoverHighlightIndex < _currentTypePopoverItems.Count ) { @@ -4838,7 +4844,7 @@ private void HandleEnterOnPopoverItem(VisualElement element) } else { - if (addableCount > 0) + if (0 < addableCount) { BuildConfirmNamespaceAddPopoverContent(nsKey, addableTypes); OpenPopover(_confirmNamespaceAddPopover, element, isNested: true); @@ -5184,7 +5190,7 @@ private VisualElement CreateObjectColumn() }; _objectListView.bindItem = (element, i) => { - if (i >= 0 && i < _filteredObjects.Count) + if (0 <= i && i < _filteredObjects.Count) { BindObjectRow(element, _filteredObjects[i], i); } @@ -5571,7 +5577,7 @@ internal void UpdateLabelAreaAndFilter() !_currentUniqueLabelsForType.Contains(label) ); - if (removedAnd > 0 || removedOr > 0) + if (0 < removedAnd || 0 < removedOr) { configChanged = true; } @@ -6165,7 +6171,7 @@ List typesToAdd _confirmNamespaceAddPopover.style.paddingRight = 10; string message = - $"Add {countToAdd} type{(countToAdd > 1 ? "s" : "")} from namespace '{namespaceKey}' to Data Visualizer?"; + $"Add {countToAdd} type{(1 < countToAdd ? "s" : "")} from namespace '{namespaceKey}' to Data Visualizer?"; Label messageLabel = new(message) { style = { whiteSpace = WhiteSpace.Normal, marginBottom = 15 }, @@ -6272,7 +6278,7 @@ internal void BuildObjectsView() _objectListView.RefreshItems(); _objectListView.style.display = DisplayStyle.None; _emptyObjectLabel.text = - _selectedObjects.Count > 0 + 0 < _selectedObjects.Count ? $"No objects of type '{NamespaceController.GetTypeDisplayName(selectedType)}' match the current label filter." : $"No objects of type '{NamespaceController.GetTypeDisplayName(selectedType)}' found."; _emptyObjectLabel.style.display = DisplayStyle.Flex; @@ -6293,7 +6299,7 @@ internal void BuildObjectsView() _selectedObject != null ? _filteredObjects.IndexOf(_selectedObject) : -1; _suppressListSelectionCallback = true; _objectListView.SetSelectionWithoutNotify( - selectedIndex >= 0 ? new[] { selectedIndex } : Array.Empty() + 0 <= selectedIndex ? new[] { selectedIndex } : Array.Empty() ); _suppressListSelectionCallback = false; } @@ -6978,7 +6984,7 @@ private void OnNewLabelInputBlur(FocusOutEvent evt) private void PopulateProjectUniqueLabelsCache(bool force = false) { - if (!force && _isLabelCachePopulated && _projectUniqueLabelsCache.Count > 0) + if (!force && _isLabelCachePopulated && 0 < _projectUniqueLabelsCache.Count) { return; } @@ -7013,7 +7019,7 @@ private void UpdateLabelSuggestions(string currentInput) } PopulateProjectUniqueLabelsCache(); - if (_activePopover == null && _projectUniqueLabelsCache.Count > 0) + if (_activePopover == null && 0 < _projectUniqueLabelsCache.Count) { OpenPopover( _inspectorLabelSuggestionsPopover, @@ -7045,7 +7051,7 @@ private void UpdateLabelSuggestions(string currentInput) .Take(10) .ToArray(); - if (suggestions.Length > 0) + if (0 < suggestions.Length) { foreach (string suggestionText in suggestions) { @@ -7107,7 +7113,7 @@ private void HandleNewLabelInputKeyDown(KeyDownEvent evt) case KeyCode.DownArrow: { _labelSuggestionHighlightIndex++; - if (_labelSuggestionHighlightIndex >= _currentLabelSuggestionItems.Count) + if (_currentLabelSuggestionItems.Count <= _labelSuggestionHighlightIndex) { _labelSuggestionHighlightIndex = 0; } @@ -7130,7 +7136,7 @@ private void HandleNewLabelInputKeyDown(KeyDownEvent evt) case KeyCode.KeypadEnter: { if ( - _labelSuggestionHighlightIndex >= 0 + 0 <= _labelSuggestionHighlightIndex && _labelSuggestionHighlightIndex < _currentLabelSuggestionItems.Count ) { @@ -7564,7 +7570,7 @@ private void RefreshSelectedElementVisuals(ScriptableObject dataObject) } int index = _filteredObjects.IndexOf(dataObject); - if (index >= 0) + if (0 <= index) { // Re-binds the row (BindObjectRow refreshes the title) without a full rebuild. _objectListView.RefreshItem(index); @@ -7876,7 +7882,7 @@ string guid in allGuids { SelectObjectAndNavigate(objectToSelect); } - else if (_selectedObjects.Count > 0) + else if (0 < _selectedObjects.Count) { SelectObjectAndNavigate(_selectedObjects[0]); } @@ -7889,7 +7895,7 @@ string guid in allGuids } // Continue loading remaining batches - if (_pendingObjectGuids.Count > 0) + if (0 < _pendingObjectGuids.Count) { if (EnableAsyncLoadDebugLog) { @@ -8034,7 +8040,7 @@ private void ContinueLoadingObjects(Type type, int loadGeneration) LoadObjectBatch(type, batch, true); - if (_pendingObjectGuids.Count > 0) + if (0 < _pendingObjectGuids.Count) { // Schedule next batch _asyncLoadTask = rootVisualElement.schedule.Execute(() => @@ -8073,7 +8079,7 @@ private void UpdateLoadingIndicator(int loadedCount, int totalCount) _isLoadingObjectsAsync && _asyncLoadTargetType == selectedType && selectedType != null - && totalCount > loadedCount + && loadedCount < totalCount ) { _objectLoadingIndicator.style.display = DisplayStyle.Flex; @@ -8221,7 +8227,7 @@ internal void SelectObjectAndNavigate(ScriptableObject dataObject) .schedule.Execute(() => { int i = _filteredObjects.IndexOf(dataObject); - if (i >= 0 && _objectListView != null) + if (0 <= i && _objectListView != null) { _objectListView.ScrollToItem(i); } @@ -8270,7 +8276,7 @@ private void OnObjectListItemReordered(int fromIndex, int toIndex) if (_selectedObject != null) { int i = _filteredObjects.IndexOf(_selectedObject); - if (i >= 0) + if (0 <= i) { _suppressListSelectionCallback = true; _objectListView.SetSelectionWithoutNotify(new[] { i }); @@ -8280,7 +8286,7 @@ private void OnObjectListItemReordered(int fromIndex, int toIndex) // Ensure the dropped item ends up fully in view — drag auto-panning can leave it at the // edge. Deferred so the ListView finishes settling the reordered layout first. - if (toIndex >= 0 && toIndex < _filteredObjects.Count) + if (0 <= toIndex && toIndex < _filteredObjects.Count) { int scrollIndex = toIndex; rootVisualElement @@ -8303,7 +8309,7 @@ internal void SelectObject(ScriptableObject dataObject) { int index = dataObject != null ? _filteredObjects.IndexOf(dataObject) : -1; _suppressListSelectionCallback = true; - if (index >= 0) + if (0 <= index) { _objectListView.SetSelectionWithoutNotify(new[] { index }); _objectListView.ScrollToItem(index); @@ -8527,7 +8533,7 @@ private void PerformNamespaceDrop() } int oldDataIndex = _namespaceOrder.GetValueOrDefault(draggedKey, -1); - if (0 > oldDataIndex) + if (oldDataIndex < 0) { return; } @@ -9361,7 +9367,7 @@ List customOrder switch (indexA) { - case >= 0 when indexB >= 0: + case >= 0 when 0 <= indexB: return indexA.CompareTo(indexB); case >= 0: return -1; diff --git a/Editor/DataVisualizer/NamespaceController.cs b/Editor/DataVisualizer/NamespaceController.cs index b840a2b..157fbef 100644 --- a/Editor/DataVisualizer/NamespaceController.cs +++ b/Editor/DataVisualizer/NamespaceController.cs @@ -100,7 +100,7 @@ out int currentIndex private static Type InternalSelected(VisualElement parent, int index) { - if (0 > index || index >= parent.childCount) + if (index < 0 || parent.childCount <= index) { return null; } @@ -219,7 +219,7 @@ public void Build(DataVisualizer dataVisualizer, ref VisualElement namespaceList string namespaceKey = key; List nonCoreManagedTypes = types.Where(IsTypeRemovable).ToList(); int removableTypeCount = nonCoreManagedTypes.Count; - bool showNamespaceRemoveButton = removableTypeCount > 1; + bool showNamespaceRemoveButton = 1 < removableTypeCount; VisualElement namespaceGroupItem = new() { @@ -318,7 +318,7 @@ public void Build(DataVisualizer dataVisualizer, ref VisualElement namespaceList namespaceRemoveButton = new Button(() => { dataVisualizer.BuildAndOpenConfirmationPopover( - $"Remove {removableTypeCount} non-core type{(removableTypeCount > 1 ? "s" : "")} from namespace '{namespaceKey}'?", + $"Remove {removableTypeCount} non-core type{(1 < removableTypeCount ? "s" : "")} from namespace '{namespaceKey}'?", "Remove", () => { @@ -339,7 +339,7 @@ public void Build(DataVisualizer dataVisualizer, ref VisualElement namespaceList { text = "X", tooltip = - $"Remove {removableTypeCount} non-BaseDataObject type{(removableTypeCount > 1 ? "s" : "")}", + $"Remove {removableTypeCount} non-BaseDataObject type{(1 < removableTypeCount ? "s" : "")}", }; namespaceRemoveButton.AddToClassList(StyleConstants.ActionButtonClass); namespaceRemoveButton.AddToClassList(StyleConstants.DeleteButtonClass); diff --git a/Editor/DataVisualizer/UI/HorizontalToggle.cs b/Editor/DataVisualizer/UI/HorizontalToggle.cs index e16aa71..32b6d99 100644 --- a/Editor/DataVisualizer/UI/HorizontalToggle.cs +++ b/Editor/DataVisualizer/UI/HorizontalToggle.cs @@ -273,7 +273,7 @@ private void UpdateIndicatorPosition(bool animate) ? _leftLabel.resolvedStyle.width : _rightLabel.resolvedStyle.width; - if (animate && resolvedStyle.width > 0) + if (animate && 0 < resolvedStyle.width) { _indicator.RemoveFromClassList(indicatorSelectedUssClassName); diff --git a/Editor/DataVisualizer/Utilities/AssetGuidDiscovery.cs b/Editor/DataVisualizer/Utilities/AssetGuidDiscovery.cs index 6ac6123..ef1edb7 100644 --- a/Editor/DataVisualizer/Utilities/AssetGuidDiscovery.cs +++ b/Editor/DataVisualizer/Utilities/AssetGuidDiscovery.cs @@ -20,10 +20,10 @@ out string normalizedSavedObjectGuid bool candidateAdded = false; string normalizedSavedGuid = null; - if (referencedGuids != null && referencedGuids.Count > 0) + if (referencedGuids != null && 0 < referencedGuids.Count) { candidateLookup = new HashSet(candidates, StringComparer.OrdinalIgnoreCase); - candidateAdded = AddResolvedGuids(type, referencedGuids, candidateLookup) > 0; + candidateAdded = 0 < AddResolvedGuids(type, referencedGuids, candidateLookup); } if (TryNormalizeGuidForType(type, savedObjectGuid, out string normalizedGuid)) diff --git a/Editor/DataVisualizer/Utilities/AssetGuidOrder.cs b/Editor/DataVisualizer/Utilities/AssetGuidOrder.cs index 3cedf0b..be954c4 100644 --- a/Editor/DataVisualizer/Utilities/AssetGuidOrder.cs +++ b/Editor/DataVisualizer/Utilities/AssetGuidOrder.cs @@ -69,7 +69,7 @@ public static bool PlaceAfter(List order, string guid, string anchorGuid } int originalIndex = IndexOf(order, guid); - if (originalIndex >= 0) + if (0 <= originalIndex) { // Stable removal is required because this list is the persisted display order. // This path removes at most one item; swap-back would scramble neighboring GUIDs. @@ -90,7 +90,7 @@ private static bool PlaceAt(List order, string guid, int targetIndex) } int originalIndex = IndexOf(order, guid); - if (originalIndex >= 0) + if (0 <= originalIndex) { // Preserve relative order. This is one removal, not a repeated RemoveAt loop. order.RemoveAt(originalIndex); diff --git a/Runtime/Helper/DirectoryHelper.cs b/Runtime/Helper/DirectoryHelper.cs index 482dc84..9e913c7 100644 --- a/Runtime/Helper/DirectoryHelper.cs +++ b/Runtime/Helper/DirectoryHelper.cs @@ -173,7 +173,7 @@ public static string AbsoluteToUnityRelativePath(string absolutePath) int startIndex = projectRoot.EndsWith("/", StringComparison.OrdinalIgnoreCase) ? projectRoot.Length : projectRoot.Length + 1; - return absolutePath.Length > startIndex ? absolutePath[startIndex..] : string.Empty; + return startIndex < absolutePath.Length ? absolutePath[startIndex..] : string.Empty; } if (absolutePath.StartsWith(projectRoot, StringComparison.OrdinalIgnoreCase)) { diff --git a/Tests/Editor/TypePopoverLayoutTests.cs b/Tests/Editor/TypePopoverLayoutTests.cs index e69a66c..2148836 100644 --- a/Tests/Editor/TypePopoverLayoutTests.cs +++ b/Tests/Editor/TypePopoverLayoutTests.cs @@ -238,7 +238,7 @@ private static IEnumerator WaitForResolvedHeights(params VisualElement[] element private static bool IsPositiveFinite(float value) { - return value > 0 && !float.IsNaN(value) && !float.IsInfinity(value); + return 0 < value && !float.IsNaN(value) && !float.IsInfinity(value); } private sealed class LayoutTestWindow : EditorWindow { }