3 Welcome to a Clippy's lint list, at least the source code of it. If you are
4 interested in contributing to this website checkout `util/gh-pages/index.html`
5 inside the rust-clippy repository.
7 Otherwise, have a great day =^.^=
11 <meta charset="UTF-8"/>
12 <meta name="viewport" content="width=device-width, initial-scale=1"/>
14 <title>Clippy Lints</title>
16 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"/>
17 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/styles/github.min.css"/>
19 <!-- The files are not copied over into the Clippy project since they use the MPL-2.0 License -->
20 <link rel="stylesheet" href="https://rust-lang.github.io/mdBook/css/variables.css"/>
21 <link id="styleHighlight" rel="stylesheet" href="https://rust-lang.github.io/mdBook/highlight.css">
22 <link id="styleNight" rel="stylesheet" href="https://rust-lang.github.io/mdBook/tomorrow-night.css" disabled="true">
23 <link id="styleAyu" rel="stylesheet" href="https://rust-lang.github.io/mdBook/ayu-highlight.css" disabled="true">
25 blockquote { font-size: 1em; }
26 [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; }
28 .form-inline .checkbox { margin-right: 0.6em }
30 .panel-heading { cursor: pointer; }
32 .panel-title { display: flex; flex-wrap: wrap;}
33 .panel-title .label { display: inline-block; }
35 .panel-title-name { flex: 1; min-width: 400px;}
36 .panel-title-name span { vertical-align: bottom; }
38 .panel .panel-title-name .anchor { display: none; }
39 .panel:hover .panel-title-name .anchor { display: inline;}
43 padding-bottom: 0.3em;
53 .label-lint-level-allow {
54 background-color: #5cb85c;
56 .label-lint-level-warn {
57 background-color: #f0ad4e;
59 .label-lint-level-deny {
60 background-color: #d9534f;
62 .label-lint-level-none {
63 background-color: #777777;
67 .label-group-deprecated {
73 background-color: #fff;
74 border: 1px solid var(--theme-popup-border);
76 .label-doc-folding:hover {
77 background-color: #e6e6e6;
81 border-top: 1px solid var(--theme-popup-border);
86 .lint-doc-md > h3:first-child {
91 @media (max-width:749px) {
92 .lint-additional-info-container {
96 .lint-additional-info-item + .lint-additional-info-item {
97 border-top: 1px solid var(--theme-popup-border);
100 @media (min-width:750px) {
101 .lint-additional-info-container {
105 .lint-additional-info-item + .lint-additional-info-item {
106 border-left: 1px solid var(--theme-popup-border);
110 .lint-additional-info-item {
111 display: inline-flex;
114 padding: 9px 5px 5px 15px;
117 .label-applicability {
118 background-color: #777777;
123 background-color: #777777;
125 font-family: monospace;
129 /* Expanding the mdBoom theme*/
131 --inline-code-bg: #f6f7f6;
134 --inline-code-bg: #f6f7f6;
137 --inline-code-bg: #1d1f21;
140 --inline-code-bg: #1d1f21;
143 --inline-code-bg: #191f26;
146 /* Applying the mdBook theme */
154 border: solid 1px var(--icons);
160 background: var(--theme-hover);
164 margin-top: calc(2em + 0.7em);
167 border: 1px solid var(--theme-popup-border);
170 background: var(--theme-popup-bg);
179 .theme-choice > li:hover {
180 background: var(--theme-hover);
185 background: var(--theme-hover);
186 border: 1px solid var(--theme-popup-border);
189 border-color: var(--theme-popup-border);
191 .panel-default > .panel-heading {
192 background: var(--theme-hover);
194 border: 1px solid var(--theme-popup-border);
196 .panel-default > .panel-heading:hover {
197 filter: brightness(90%);
201 border: 1px solid var(--theme-popup-border);
204 background: var(--bg);
205 border: 1px solid var(--theme-popup-border);
208 #filter-label, #filter-clear {
209 background: var(--searchbar-bg);
210 color: var(--searchbar-fg);
211 border-color: var(--theme-popup-border);
212 filter: brightness(95%);
214 #filter-label:hover, #filter-clear:hover {
215 filter: brightness(90%);
218 background: var(--searchbar-bg);
219 color: var(--searchbar-fg);
220 border-color: var(--theme-popup-border);
223 #filter-input::-webkit-input-placeholder,
224 #filter-input::-moz-placeholder {
225 color: var(--searchbar-fg);
230 color: var(--inline-code-color);
231 background-color: var(--inline-code-bg);
234 scrollbar-color: var(--scrollbar) var(--bg);
237 background: var(--bg);
244 <div id="theme-icon" class="theme-icon">🖌</div>
245 <ul id="theme-menu" class="theme-choice" style="display: none;">
246 <li id="light">Light</li>
247 <li id="rust">Rust</li>
248 <li id="coal">Coal</li>
249 <li id="navy">Navy</li>
250 <li id="ayu">Ayu</li>
253 <div class="container" ng-app="clippy" ng-controller="lintList">
254 <div class="page-header">
255 <h1>Clippy Lints</h1>
259 <div class="alert alert-danger" role="alert">
260 Sorry, this site only works with JavaScript! :(
266 <div class="alert alert-info" role="alert" ng-if="loading">
269 <div class="alert alert-danger" role="alert" ng-if="error">
273 <div class="panel panel-default" ng-show="data">
274 <div class="panel-body row filter-panel">
275 <div class="col-md-6 form-inline">
276 <div class="form-group form-group-lg">
279 <a href="https://doc.rust-lang.org/rustc/lints/levels.html">(?)</a>
281 <div class="checkbox" ng-repeat="(level, enabled) in levels">
282 <label class="text-capitalize">
283 <input type="checkbox" ng-model="levels[level]" />
289 <div class="col-md-6 form-inline">
290 <div class="form-group form-group-lg">
293 <a href="https://github.com/rust-lang/rust-clippy/#clippy">(?)</a>
295 <div class="checkbox" ng-repeat="(group, enabled) in groups">
296 <label class="text-capitalize">
297 <input type="checkbox" ng-model="groups[group]" />
304 <div class="panel-body row">
305 <div class="col-md-12 form-horizontal">
306 <div class="input-group">
307 <label class="input-group-addon" id="filter-label" for="filter-input">Filter:</label>
308 <input type="text" class="form-control" placeholder="Keywords or search string" id="filter-input" ng-model="search" ng-model-options="{debounce: 50}"/>
309 <span class="input-group-btn">
310 <button id="filter-clear" class="btn" type="button" ng-click="search = ''">
318 <!-- The order of the filters should be from most likely to remove a lint to least likely to improve performance. -->
319 <article class="panel panel-default" id="{{lint.id}}" ng-repeat="lint in data | filter:bySearch | filter:byGroups | filter:byLevels">
320 <header class="panel-heading" ng-click="open[lint.id] = !open[lint.id]">
321 <h2 class="panel-title">
322 <div class="panel-title-name">
323 <span>{{lint.id}}</span>
324 <a href="#{{lint.id}}" class="anchor label label-default" ng-click="open[lint.id] = true; $event.stopPropagation()">¶</a>
327 <div class="panel-title-addons">
328 <span class="label label-lint-group label-default label-group-{{lint.group}}">{{lint.group}}</span>
330 <span class="label label-lint-level label-lint-level-{{lint.level}}">{{lint.level}}</span>
333 <span class="label label-doc-folding" ng-show="open[lint.id]">−</span>
334 <span class="label label-doc-folding" ng-hide="open[lint.id]">+</span>
339 <div class="list-group lint-docs" ng-class="{collapse: true, in: open[lint.id]}">
340 <div class="list-group-item lint-doc-md" ng-bind-html="lint.docs | markdown"></div>
341 <div class="lint-additional-info-container">
342 <!-- Applicability -->
343 <div class="lint-additional-info-item">
344 <span> Applicability: </span>
345 <span class="label label-default label-applicability">{{lint.applicability.applicability}}</span>
346 <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/enum.Applicability.html#variants">(?)</a>
348 <!-- Clippy version -->
349 <div class="lint-additional-info-item">
350 <span>{{lint.group == "deprecated" ? "Deprecated" : "Added"}} in: </span>
351 <span class="label label-default label-version">{{lint.version}}</span>
353 <!-- Open related issues -->
354 <div class="lint-additional-info-item">
355 <a href="https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+{{lint.id}}">Related Issues</a>
357 <!-- Jump to source -->
358 <div class="lint-additional-info-item">
359 <a href="https://github.com/rust-lang/rust-clippy/blob/{{docVersion}}/clippy_lints/{{lint.id_span.path}}#L{{lint.id_span.line}}">View Source</a>
367 <a href="https://github.com/rust-lang/rust-clippy">
368 <img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on Github"/>
371 <script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/12.3.2/markdown-it.min.js"></script>
372 <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script>
373 <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/languages/rust.min.js"></script>
374 <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.12/angular.min.js"></script>
377 var md = window.markdownit({
381 highlight: function (str, lang) {
382 if (lang && hljs.getLanguage(lang)) {
384 return '<pre class="hljs"><code>' +
385 hljs.highlight(lang, str, true).value +
390 return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
394 function scrollToLint(lintId) {
395 var target = document.getElementById(lintId);
399 target.scrollIntoView();
402 function scrollToLintByURL($scope) {
403 var removeListener = $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
404 scrollToLint(window.location.hash.slice(1));
409 function selectGroup($scope, selectedGroup) {
410 var groups = $scope.groups;
411 for (var group in groups) {
412 if (groups.hasOwnProperty(group)) {
413 if (group === selectedGroup) {
414 groups[group] = true;
416 groups[group] = false;
422 angular.module("clippy", [])
423 .filter('markdown', function ($sce) {
424 return function (text) {
425 return $sce.trustAsHtml(
426 md.render(text || '')
427 // Oh deer, what a hack :O
428 .replace('<table', '<table class="table"')
432 .directive('onFinishRender', function ($timeout) {
435 link: function (scope, element, attr) {
436 if (scope.$last === true) {
437 $timeout(function () {
438 scope.$emit(attr.onFinishRender);
444 .controller("lintList", function ($scope, $http, $timeout) {
446 var LEVEL_FILTERS_DEFAULT = {allow: true, warn: true, deny: true, none: true};
447 $scope.levels = LEVEL_FILTERS_DEFAULT;
448 $scope.byLevels = function (lint) {
449 return $scope.levels[lint.level];
452 var GROUPS_FILTER_DEFAULT = {
464 $scope.groups = GROUPS_FILTER_DEFAULT;
465 $scope.byGroups = function (lint) {
466 return $scope.groups[lint.group];
469 $scope.bySearch = function (lint, index, array) {
470 let searchStr = $scope.search;
471 // It can be `null` I haven't missed this value
472 if (searchStr == null || searchStr.length < 3) {
475 searchStr = searchStr.toLowerCase();
478 if (lint.id.indexOf(searchStr.replace("-", "_")) !== -1) {
482 // Search the description
483 // The use of `for`-loops instead of `foreach` enables us to return early
484 let terms = searchStr.split(" ");
485 let docsLowerCase = lint.docs.toLowerCase();
486 for (index = 0; index < terms.length; index++) {
487 // This is more likely and will therefor be checked first
488 if (docsLowerCase.indexOf(terms[index]) !== -1) {
492 if (lint.id.indexOf(terms[index]) !== -1) {
504 $scope.loading = true;
505 // This will be used to jump into the source code of the version that this documentation is for.
506 $scope.docVersion = window.location.pathname.split('/')[2] || "master";
508 if (window.location.hash.length > 1) {
509 $scope.search = window.location.hash.slice(1);
510 $scope.open[window.location.hash.slice(1)] = true;
511 scrollToLintByURL($scope);
514 $http.get('./lints.json')
515 .success(function (data) {
517 $scope.loading = false;
519 var selectedGroup = getQueryVariable("sel");
521 selectGroup($scope, selectedGroup.toLowerCase());
524 scrollToLintByURL($scope);
526 setTimeout(function () {
527 var el = document.getElementById('filter-input');
528 if (el) { el.focus() }
531 .error(function (data) {
533 $scope.loading = false;
536 window.addEventListener('hashchange', function () {
538 $timeout(function () {
539 $scope.levels = LEVEL_FILTERS_DEFAULT;
540 $scope.search = window.location.hash.slice(1);
541 $scope.open[window.location.hash.slice(1)] = true;
543 scrollToLintByURL($scope);
550 function getQueryVariable(variable) {
551 var query = window.location.search.substring(1);
552 var vars = query.split('&');
553 for (var i = 0; i < vars.length; i++) {
554 var pair = vars[i].split('=');
555 if (decodeURIComponent(pair[0]) == variable) {
556 return decodeURIComponent(pair[1]);
561 function setupListeners() {
562 let themeIcon = document.getElementById("theme-icon");
563 let themeMenu = document.getElementById("theme-menu");
564 themeIcon.addEventListener("click", function(e) {
565 if (themeMenu.style.display == "none") {
566 themeMenu.style.display = "block";
568 themeMenu.style.display = "none";
572 let children = themeMenu.children;
573 for (let index = 0; index < children.length; index++) {
574 let child = children[index];
575 child.addEventListener("click", function(e) {
576 setTheme(child.id, true);
583 function setTheme(theme, store) {
584 let enableHighlight = false;
585 let enableNight = false;
586 let enableAyu = false;
588 if (theme == "ayu") {
590 } else if (theme == "coal" || theme == "navy") {
592 } else if (theme == "rust") {
593 enableHighlight = true;
595 enableHighlight = true;
596 // this makes sure that an unknown theme request gets set to a known one
599 document.getElementsByTagName("body")[0].className = theme;
601 document.getElementById("styleHighlight").disabled = !enableHighlight;
602 document.getElementById("styleNight").disabled = !enableNight;
603 document.getElementById("styleAyu").disabled = !enableAyu;
607 localStorage.setItem('clippy-lint-list-theme', theme);
612 // loading the theme after the initial load
613 setTheme(localStorage.getItem('clippy-lint-list-theme'), false);