Skip to content

Commit 00ab8d0

Browse files
committed
Adopting a few review suggestions
1 parent 7f5f2be commit 00ab8d0

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/Elastic.Documentation/AppliesTo/ApplicabilitySelector.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ public static Applicability GetPrimaryApplicability(IEnumerable<Applicability> a
3030
};
3131

3232
var availableApplicabilities = applicabilityList
33-
.Where(a => a.Version is null || a.Version is AllVersionsSpec ||
34-
(a.Version is VersionSpec vs && vs.Min <= currentVersion))
33+
.Where(a => a.Version is null || a.Version is AllVersionsSpec || a.Version.Min <= currentVersion)
3534
.ToList();
3635

3736
if (availableApplicabilities.Count != 0)
@@ -43,8 +42,7 @@ public static Applicability GetPrimaryApplicability(IEnumerable<Applicability> a
4342
}
4443

4544
var futureApplicabilities = applicabilityList
46-
.Where(a => a.Version is not null && a.Version is not AllVersionsSpec &&
47-
a.Version is VersionSpec vs && vs.Min > currentVersion)
45+
.Where(a => a.Version is not null && a.Version is not AllVersionsSpec && a.Version.Min > currentVersion)
4846
.ToList();
4947

5048
if (futureApplicabilities.Count != 0)

src/Elastic.Documentation/AppliesTo/ApplicableToYamlConverter.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,13 @@ private static void ValidateApplicabilityCollection(string key, AppliesCollectio
294294
}
295295

296296
// Rule: In a range, the first version must be less than or equal the last version
297-
foreach (var item in items)
297+
foreach (var item in items.Where(a => a.Version is { Kind: VersionSpecKind.Range }))
298298
{
299-
if (item.Version is { Kind: VersionSpecKind.Range } spec)
299+
var spec = item.Version!;
300+
if (spec.Min.CompareTo(spec.Max!) > 0)
300301
{
301-
if (spec.Min.CompareTo(spec.Max!) > 0)
302-
{
303-
diagnostics.Add((Severity.Warning,
304-
$"Key '{key}', {item.Lifecycle}: Range has first version ({spec.Min.Major}.{spec.Min.Minor}) greater than last version ({spec.Max!.Major}.{spec.Max.Minor})."));
305-
}
302+
diagnostics.Add((Severity.Warning,
303+
$"Key '{key}', {item.Lifecycle}: Range has first version ({spec.Min.Major}.{spec.Min.Minor}) greater than last version ({spec.Max!.Major}.{spec.Max.Minor})."));
306304
}
307305
}
308306

0 commit comments

Comments
 (0)