]> git.lizzy.rs Git - rust.git/blob - util/gh-pages/index.html
`map_identity` Add tests for needless `.map_err`
[rust.git] / util / gh-pages / index.html
1 <!DOCTYPE html>
2 <!--
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.
6
7 Otherwise, have a great day =^.^=
8 -->
9 <html lang="en">
10 <head>
11     <meta charset="UTF-8"/>
12     <meta name="viewport" content="width=device-width, initial-scale=1"/>
13
14     <title>Clippy Lints</title>
15
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"/>
18
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">
24     <style>
25         blockquote { font-size: 1em; }
26         [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; }
27
28         .form-inline .checkbox { margin-right: 0.6em }
29
30         .panel-heading { cursor: pointer; }
31
32         .panel-title { display: flex; flex-wrap: wrap;}
33         .panel-title .label { display: inline-block; }
34
35         .panel-title-name { flex: 1; min-width: 400px;}
36         .panel-title-name span { vertical-align: bottom; }
37
38         .panel .panel-title-name .anchor { display: none; }
39         .panel:hover .panel-title-name .anchor { display: inline;}
40
41         .label {
42             padding-top: 0.3em;
43             padding-bottom: 0.3em;
44         }
45
46         .label-lint-group {
47             min-width: 8em;
48         }
49         .label-lint-level {
50             min-width: 4em;
51         }
52
53         .label-lint-level-allow {
54             background-color: #5cb85c;
55         }
56         .label-lint-level-warn {
57             background-color: #f0ad4e;
58         }
59         .label-lint-level-deny {
60             background-color: #d9534f;
61         }
62         .label-lint-level-none {
63             background-color: #777777;
64             opacity: 0.5;
65         }
66
67         .label-group-deprecated {
68             opacity: 0.5;
69         }
70
71         .label-doc-folding {
72             color: #000;
73             background-color: #fff;
74             border: 1px solid var(--theme-popup-border);
75         }
76         .label-doc-folding:hover {
77             background-color: #e6e6e6;
78         }
79
80         .lint-doc-md > h3 {
81             border-top: 1px solid var(--theme-popup-border);
82             padding: 10px 15px;
83             margin: 0 -15px;
84             font-size: 18px;
85         }
86         .lint-doc-md > h3:first-child {
87             border-top: none;
88             padding-top: 0px;
89         }
90
91         @media (max-width:749px) {
92             .lint-additional-info-container {
93                 display: flex;
94                 flex-flow: column;
95             }
96             .lint-additional-info-item + .lint-additional-info-item {
97                 border-top: 1px solid var(--theme-popup-border);
98             }
99         }
100         @media (min-width:750px) {
101             .lint-additional-info-container {
102                 display: flex;
103                 flex-flow: row;
104             }
105             .lint-additional-info-item + .lint-additional-info-item {
106                 border-left: 1px solid var(--theme-popup-border);
107             }
108         }
109
110         .lint-additional-info-item {
111             display: inline-flex;
112             min-width: 200px;
113             flex-grow: 1;
114             padding: 9px 5px 5px 15px;
115         }
116
117         .label-applicability {
118             background-color: #777777;
119             margin: auto 5px;
120         }
121
122         .label-version {
123             background-color: #777777;
124             margin: auto 5px;
125             font-family: monospace;
126         }
127     </style>
128     <style>
129         /* Expanding the mdBoom theme*/
130         .light {
131             --inline-code-bg: #f6f7f6;
132         }
133         .rust {
134             --inline-code-bg: #f6f7f6;
135         }
136         .coal {
137             --inline-code-bg: #1d1f21;
138         }
139         .navy {
140             --inline-code-bg: #1d1f21;
141         }
142         .ayu {
143             --inline-code-bg: #191f26;
144         }
145
146         /* Applying the mdBook theme */
147         .theme-icon {
148             position: absolute;
149             text-align: center;
150             width: 2em;
151             height: 2em;
152             margin: 0.7em;
153             line-height: 2em;
154             border: solid 1px var(--icons);
155             border-radius: 5px;
156             user-select: none;
157             cursor: pointer;
158         }
159         .theme-icon:hover {
160             background: var(--theme-hover);
161         }
162         .theme-choice {
163             position: absolute;
164             margin-top: calc(2em + 0.7em);
165             margin-left: 0.7em;
166             list-style: none;
167             border: 1px solid var(--theme-popup-border);
168             border-radius: 5px;
169             color: var(--fg);
170             background: var(--theme-popup-bg);
171             padding: 0 0;
172         }
173         .theme-choice > li {
174             padding: 5px 10px;
175             font-size: 0.8em;
176             user-select: none;
177             cursor: pointer;
178         }
179         .theme-choice > li:hover {
180             background: var(--theme-hover);
181         }
182
183         .alert {
184             color: var(--fg);
185             background: var(--theme-hover);
186             border: 1px solid var(--theme-popup-border);
187         }
188         .page-header {
189             border-color: var(--theme-popup-border);
190         }
191         .panel-default > .panel-heading {
192             background: var(--theme-hover);
193             color: var(--fg);
194             border: 1px solid var(--theme-popup-border);
195         }
196         .panel-default > .panel-heading:hover {
197             filter: brightness(90%);
198         }
199         .list-group-item {
200             background: 0%;
201             border: 1px solid var(--theme-popup-border);
202         }
203         .panel, pre, hr {
204             background: var(--bg);
205             border: 1px solid var(--theme-popup-border);
206         }
207
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%);
213         }
214         #filter-label:hover, #filter-clear:hover {
215             filter: brightness(90%);
216         }
217         #filter-input {
218             background: var(--searchbar-bg);
219             color: var(--searchbar-fg);
220             border-color: var(--theme-popup-border);
221         }
222
223         #filter-input::-webkit-input-placeholder,
224         #filter-input::-moz-placeholder {
225             color: var(--searchbar-fg);
226             opacity: 30%;
227         }
228
229         :not(pre) > code {
230             color: var(--inline-code-color);
231             background-color: var(--inline-code-bg);
232         }
233         html {
234             scrollbar-color: var(--scrollbar) var(--bg);
235         }
236         body {
237             background: var(--bg);
238             color: var(--fg);
239         }
240
241     </style>
242 </head>
243 <body>
244     <div id="theme-icon" class="theme-icon">&#128396;</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>
251     </ul>
252
253     <div class="container" ng-app="clippy" ng-controller="lintList">
254         <div class="page-header">
255             <h1>Clippy Lints</h1>
256         </div>
257
258         <noscript>
259             <div class="alert alert-danger" role="alert">
260                 Sorry, this site only works with JavaScript! :(
261             </div>
262         </noscript>
263
264         <div ng-cloak>
265
266             <div class="alert alert-info" role="alert" ng-if="loading">
267                 Loading&#x2026;
268             </div>
269             <div class="alert alert-danger" role="alert" ng-if="error">
270                 Error loading lints!
271             </div>
272
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">
277                             <p class="h4">
278                                 Lint levels
279                                 <a href="https://doc.rust-lang.org/rustc/lints/levels.html">(?)</a>
280                             </p>
281                             <div class="checkbox" ng-repeat="(level, enabled) in levels">
282                                 <label class="text-capitalize">
283                                     <input type="checkbox" ng-model="levels[level]" />
284                                     {{level}}
285                                 </label>
286                             </div>
287                         </div>
288                     </div>
289                     <div class="col-md-6 form-inline">
290                         <div class="form-group form-group-lg">
291                             <p class="h4">
292                                 Lint groups
293                                 <a href="https://github.com/rust-lang/rust-clippy/#clippy">(?)</a>
294                             </p>
295                             <div class="checkbox" ng-repeat="(group, enabled) in groups">
296                                 <label class="text-capitalize">
297                                     <input type="checkbox" ng-model="groups[group]" />
298                                     {{group}}
299                                 </label>
300                             </div>
301                         </div>
302                     </div>
303                 </div>
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 = ''">
311                                     Clear
312                                 </button>
313                             </span>
314                         </div>
315                     </div>
316                 </div>
317             </div>
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()">&para;</a>
325                         </div>
326
327                         <div class="panel-title-addons">
328                             <span class="label label-lint-group label-default label-group-{{lint.group}}">{{lint.group}}</span>
329
330                             <span class="label label-lint-level label-lint-level-{{lint.level}}">{{lint.level}}</span>
331
332
333                             <span class="label label-doc-folding" ng-show="open[lint.id]">&minus;</span>
334                             <span class="label label-doc-folding" ng-hide="open[lint.id]">&plus;</span>
335                         </div>
336                     </h2>
337                 </header>
338
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>
347                         </div>
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>
352                         </div>
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>
356                         </div>
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>
360                         </div>
361                     </div>
362                 </div>
363             </article>
364         </div>
365     </div>
366
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"/>
369     </a>
370
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>
375     <script>
376     (function () {
377         var md = window.markdownit({
378             html: true,
379             linkify: true,
380             typographer: true,
381             highlight: function (str, lang) {
382                 if (lang && hljs.getLanguage(lang)) {
383                     try {
384                         return '<pre class="hljs"><code>' +
385                             hljs.highlight(lang, str, true).value +
386                             '</code></pre>';
387                     } catch (__) {}
388                 }
389
390                 return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
391             }
392         });
393
394         function scrollToLint(lintId) {
395             var target = document.getElementById(lintId);
396             if (!target) {
397                 return;
398             }
399             target.scrollIntoView();
400         }
401
402         function scrollToLintByURL($scope) {
403             var removeListener = $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
404                 scrollToLint(window.location.hash.slice(1));
405                 removeListener();
406             });
407         }
408
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;
415                     } else {
416                         groups[group] = false;
417                     }
418                 }
419             }
420         }
421
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"')
429                 );
430             };
431         })
432         .directive('onFinishRender', function ($timeout) {
433             return {
434                 restrict: 'A',
435                 link: function (scope, element, attr) {
436                     if (scope.$last === true) {
437                         $timeout(function () {
438                             scope.$emit(attr.onFinishRender);
439                         });
440                     }
441                 }
442             };
443         })
444         .controller("lintList", function ($scope, $http, $timeout) {
445             // Level filter
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];
450             };
451
452             var GROUPS_FILTER_DEFAULT = {
453                 cargo: true,
454                 complexity: true,
455                 correctness: true,
456                 deprecated: false,
457                 nursery: true,
458                 pedantic: true,
459                 perf: true,
460                 restriction: true,
461                 style: true,
462                 suspicious: true,
463             };
464             $scope.groups = GROUPS_FILTER_DEFAULT;
465             $scope.byGroups = function (lint) {
466                 return $scope.groups[lint.group];
467             };
468
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) {
473                     return true;
474                 }
475                 searchStr = searchStr.toLowerCase();
476
477                 // Search by id
478                 if (lint.id.indexOf(searchStr.replace("-", "_")) !== -1) {
479                     return true;
480                 }
481
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) {
489                         continue;
490                     }
491
492                     if (lint.id.indexOf(terms[index]) !== -1) {
493                         continue;
494                     }
495
496                     return false;
497                 }
498
499                 return true;
500             }
501
502             // Get data
503             $scope.open = {};
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";
507
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);
512             }
513
514             $http.get('./lints.json')
515             .success(function (data) {
516                 $scope.data = data;
517                 $scope.loading = false;
518
519                 var selectedGroup = getQueryVariable("sel");
520                 if (selectedGroup) {
521                     selectGroup($scope, selectedGroup.toLowerCase());
522                 }
523
524                 scrollToLintByURL($scope);
525
526                 setTimeout(function () {
527                     var el = document.getElementById('filter-input');
528                     if (el) { el.focus() }
529                 }, 0);
530             })
531             .error(function (data) {
532                 $scope.error = data;
533                 $scope.loading = false;
534             });
535
536             window.addEventListener('hashchange', function () {
537                 // trigger re-render
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;
542
543                     scrollToLintByURL($scope);
544                 });
545                 return true;
546             }, false);
547         });
548     })();
549
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]);
557             }
558         }
559     }
560
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";
567             } else {
568                 themeMenu.style.display = "none";
569             }
570         });
571
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);
577             });
578         }
579     }
580
581     setupListeners();
582
583     function setTheme(theme, store) {
584         let enableHighlight = false;
585         let enableNight = false;
586         let enableAyu = false;
587
588         if (theme == "ayu") {
589             enableAyu = true;
590         } else if (theme == "coal" || theme == "navy") {
591             enableNight = true;
592         } else if (theme == "rust") {
593             enableHighlight = true;
594         } else {
595             enableHighlight = true;
596             // this makes sure that an unknown theme request gets set to a known one
597             theme = "light";
598         }
599         document.getElementsByTagName("body")[0].className = theme;
600
601         document.getElementById("styleHighlight").disabled = !enableHighlight;
602         document.getElementById("styleNight").disabled = !enableNight;
603         document.getElementById("styleAyu").disabled = !enableAyu;
604
605         if (store) {
606             try {
607                 localStorage.setItem('clippy-lint-list-theme', theme);
608             } catch (e) { }
609         }
610     }
611
612     // loading the theme after the initial load
613     setTheme(localStorage.getItem('clippy-lint-list-theme'), false);
614     </script>
615 </body>
616 </html>