Use early returns

This commit is contained in:
Serial 2022-05-15 11:30:00 -04:00
parent a30587e0fe
commit b81d703970
2 changed files with 13 additions and 16 deletions

View File

@ -110,6 +110,7 @@ Otherwise, have a great day =^.^=
left: auto;
}
<!-- TODO -->
#version-filter-count {
display: none;
}
@ -291,7 +292,7 @@ Otherwise, have a great day =^.^=
border: 1px solid var(--theme-popup-border);
}
#version-filter-selector .item {
#version-filter-selector .checkbox {
display: flex;
}
@ -440,14 +441,14 @@ Otherwise, have a great day =^.^=
<span class="caret"></span>
</button>
<ul id="version-filter-selector" class="dropdown-menu">
<li class="item">
<li class="checkbox">
<label ng-click="clearVersionFilters()">
<input type="checkbox" class="invisible" />
Clear filters
</label>
</li>
<li role="separator" class="divider"></li>
<li class="item" ng-repeat="(filter, vars) in versionFilters">
<li class="checkbox" ng-repeat="(filter, vars) in versionFilters">
<label ng-attr-for="filter-{filter}">{{filter}}</label>
<span>1.</span>
<input type="number"

View File

@ -185,6 +185,7 @@
// 1.29.0 and greater
if (minorVersion && minorVersion > 28) {
$scope.versionFilters[filter].enabled = true;
continue;
}
$scope.versionFilters[filter].enabled = false;
@ -201,25 +202,20 @@
let lintVersion = lint.version.startsWith("pre ") ? lint.version.substring(4, lint.version.length) : lint.version;
let lintMinorVersion = lintVersion.substring(2, 4);
let result;
switch (filter) {
case "≥":
result = (lintMinorVersion >= minorVersion);
break;
case "≤":
result = (lintMinorVersion <= minorVersion);
break;
// "=" gets the highest priority, since all filters are inclusive
case "=":
return (lintMinorVersion == minorVersion);
case "≥":
if (lintMinorVersion < minorVersion) { return false; }
break;
case "≤":
if (lintMinorVersion > minorVersion) { return false; }
break;
default:
return true
}
if (!result) {
return false;
}
let cmpFilter;
if (filter === "≥") {
cmpFilter = "≤";
@ -229,10 +225,10 @@
if (filters[cmpFilter].enabled) {
let cmpMinorVersion = filters[cmpFilter].minorVersion;
result = (cmpFilter === "≥") ? (lintMinorVersion >= cmpMinorVersion) : (lintMinorVersion <= cmpMinorVersion);
return (cmpFilter === "≥") ? (lintMinorVersion >= cmpMinorVersion) : (lintMinorVersion <= cmpMinorVersion);
}
return result;
return true;
}
}