Skip to content

Commit b81d703

Browse files
committed
Use early returns
1 parent a30587e commit b81d703

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

util/gh-pages/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
left: auto;
111111
}
112112

113+
<!-- TODO -->
113114
#version-filter-count {
114115
display: none;
115116
}
@@ -291,7 +292,7 @@
291292
border: 1px solid var(--theme-popup-border);
292293
}
293294

294-
#version-filter-selector .item {
295+
#version-filter-selector .checkbox {
295296
display: flex;
296297
}
297298

@@ -440,14 +441,14 @@ <h1>Clippy Lints</h1>
440441
<span class="caret"></span>
441442
</button>
442443
<ul id="version-filter-selector" class="dropdown-menu">
443-
<li class="item">
444+
<li class="checkbox">
444445
<label ng-click="clearVersionFilters()">
445446
<input type="checkbox" class="invisible" />
446447
Clear filters
447448
</label>
448449
</li>
449450
<li role="separator" class="divider"></li>
450-
<li class="item" ng-repeat="(filter, vars) in versionFilters">
451+
<li class="checkbox" ng-repeat="(filter, vars) in versionFilters">
451452
<label ng-attr-for="filter-{filter}">{{filter}}</label>
452453
<span>1.</span>
453454
<input type="number"

util/gh-pages/script.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
// 1.29.0 and greater
186186
if (minorVersion && minorVersion > 28) {
187187
$scope.versionFilters[filter].enabled = true;
188+
continue;
188189
}
189190

190191
$scope.versionFilters[filter].enabled = false;
@@ -201,25 +202,20 @@
201202
let lintVersion = lint.version.startsWith("pre ") ? lint.version.substring(4, lint.version.length) : lint.version;
202203
let lintMinorVersion = lintVersion.substring(2, 4);
203204

204-
let result;
205205
switch (filter) {
206+
// "=" gets the highest priority, since all filters are inclusive
207+
case "=":
208+
return (lintMinorVersion == minorVersion);
206209
case "≥":
207-
result = (lintMinorVersion >= minorVersion);
210+
if (lintMinorVersion < minorVersion) { return false; }
208211
break;
209212
case "≤":
210-
result = (lintMinorVersion <= minorVersion);
213+
if (lintMinorVersion > minorVersion) { return false; }
211214
break;
212-
// "=" gets the highest priority, since all filters are inclusive
213-
case "=":
214-
return (lintMinorVersion == minorVersion);
215215
default:
216216
return true
217217
}
218218

219-
if (!result) {
220-
return false;
221-
}
222-
223219
let cmpFilter;
224220
if (filter === "≥") {
225221
cmpFilter = "≤";
@@ -229,10 +225,10 @@
229225

230226
if (filters[cmpFilter].enabled) {
231227
let cmpMinorVersion = filters[cmpFilter].minorVersion;
232-
result = (cmpFilter === "≥") ? (lintMinorVersion >= cmpMinorVersion) : (lintMinorVersion <= cmpMinorVersion);
228+
return (cmpFilter === "≥") ? (lintMinorVersion >= cmpMinorVersion) : (lintMinorVersion <= cmpMinorVersion);
233229
}
234230

235-
return result;
231+
return true;
236232
}
237233
}
238234

0 commit comments

Comments
 (0)