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 /* Expanding the mdBoom theme*/
125 --inline-code-bg: #f6f7f6;
128 --inline-code-bg: #f6f7f6;
131 --inline-code-bg: #1d1f21;
134 --inline-code-bg: #1d1f21;
137 --inline-code-bg: #191f26;
140 /* Applying the mdBook theme */
148 border: solid 1px var(--icons);
154 background: var(--theme-hover);
158 margin-top: calc(2em + 0.7em);
161 border: 1px solid var(--theme-popup-border);
164 background: var(--theme-popup-bg);
173 .theme-choice > li:hover {
174 background: var(--theme-hover);
179 background: var(--theme-hover);
180 border: 1px solid var(--theme-popup-border);
183 border-color: var(--theme-popup-border);
185 .panel-default > .panel-heading {
186 background: var(--theme-hover);
188 border: 1px solid var(--theme-popup-border);
190 .panel-default > .panel-heading:hover {
191 filter: brightness(90%);
195 border: 1px solid var(--theme-popup-border);
198 background: var(--bg);
199 border: 1px solid var(--theme-popup-border);
202 #filter-label, #filter-clear {
203 background: var(--searchbar-bg);
204 color: var(--searchbar-fg);
205 border-color: var(--theme-popup-border);
206 filter: brightness(95%);
208 #filter-label:hover, #filter-clear:hover {
209 filter: brightness(90%);
212 background: var(--searchbar-bg);
213 color: var(--searchbar-fg);
214 border-color: var(--theme-popup-border);
217 #filter-input::-webkit-input-placeholder,
218 #filter-input::-moz-placeholder {
219 color: var(--searchbar-fg);
224 color: var(--inline-code-color);
225 background-color: var(--inline-code-bg);
228 scrollbar-color: var(--scrollbar) var(--bg);
231 background: var(--bg);
238 <div id="theme-icon" class="theme-icon">🖌</div>
239 <ul id="theme-menu" class="theme-choice" style="display: none;">
240 <li id="light">Light</li>
241 <li id="rust">Rust</li>
242 <li id="coal">Coal</li>
243 <li id="navy">Navy</li>
244 <li id="ayu">Ayu</li>
247 <div class="container" ng-app="clippy" ng-controller="lintList">
248 <div class="page-header">
249 <h1>Clippy Lints</h1>
253 <div class="alert alert-danger" role="alert">
254 Sorry, this site only works with JavaScript! :(
260 <div class="alert alert-info" role="alert" ng-if="loading">
263 <div class="alert alert-danger" role="alert" ng-if="error">
267 <div class="panel panel-default" ng-show="data">
268 <div class="panel-body row filter-panel">
269 <div class="col-md-6 form-inline">
270 <div class="form-group form-group-lg">
273 <a href="https://doc.rust-lang.org/rustc/lints/levels.html">(?)</a>
275 <div class="checkbox" ng-repeat="(level, enabled) in levels">
276 <label class="text-capitalize">
277 <input type="checkbox" ng-model="levels[level]" />
283 <div class="col-md-6 form-inline">
284 <div class="form-group form-group-lg">
287 <a href="https://github.com/rust-lang/rust-clippy/#clippy">(?)</a>
289 <div class="checkbox" ng-repeat="(group, enabled) in groups">
290 <label class="text-capitalize">
291 <input type="checkbox" ng-model="groups[group]" />
298 <div class="panel-body row">
299 <div class="col-md-12 form-horizontal">
300 <div class="input-group">
301 <label class="input-group-addon" id="filter-label" for="filter-input">Filter:</label>
302 <input type="text" class="form-control" placeholder="Keywords or search string" id="filter-input" ng-model="search" ng-model-options="{debounce: 50}"/>
303 <span class="input-group-btn">
304 <button id="filter-clear" class="btn" type="button" ng-click="search = ''">
312 <!-- The order of the filters should be from most likely to remove a lint to least likely to improve performance. -->
313 <article class="panel panel-default" id="{{lint.id}}" ng-repeat="lint in data | filter:bySearch | filter:byGroups | filter:byLevels">
314 <header class="panel-heading" ng-click="open[lint.id] = !open[lint.id]">
315 <h2 class="panel-title">
316 <div class="panel-title-name">
317 <span>{{lint.id}}</span>
318 <a href="#{{lint.id}}" class="anchor label label-default" ng-click="open[lint.id] = true; $event.stopPropagation()">¶</a>
321 <div class="panel-title-addons">
322 <span class="label label-lint-group label-default label-group-{{lint.group}}">{{lint.group}}</span>
324 <span class="label label-lint-level label-lint-level-{{lint.level}}">{{lint.level}}</span>
327 <span class="label label-doc-folding" ng-show="open[lint.id]">−</span>
328 <span class="label label-doc-folding" ng-hide="open[lint.id]">+</span>
333 <ul class="list-group lint-docs" ng-class="{collapse: true, in: open[lint.id]}">
334 <div class="list-group-item lint-doc-md" ng-bind-html="lint.docs | markdown"></div>
335 <div class="lint-additional-info-container">
336 <!-- Applicability -->
337 <div class="lint-additional-info-item">
338 <span> Applicability: </span>
339 <span class="label label-default label-applicability">{{lint.applicability.applicability}}</span>
340 <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/enum.Applicability.html#variants">(?)</a>
342 <!-- TODO xFrednet 2021-05-19: Somehow collect and show the version See rust-clippy#6492 -->
343 <!-- Open related issues -->
344 <div class="lint-additional-info-item">
345 <a href="https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+{{lint.id}}">Related Issues</a>
347 <!-- Jump to source -->
348 <div class="lint-additional-info-item">
349 <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>
357 <a href="https://github.com/rust-lang/rust-clippy">
358 <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"/>
361 <script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/7.0.0/markdown-it.min.js"></script>
362 <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script>
363 <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/languages/rust.min.js"></script>
364 <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.12/angular.min.js"></script>
367 var md = window.markdownit({
371 highlight: function (str, lang) {
372 if (lang && hljs.getLanguage(lang)) {
374 return '<pre class="hljs"><code>' +
375 hljs.highlight(lang, str, true).value +
380 return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
384 function scrollToLint(lintId) {
385 var target = document.getElementById(lintId);
389 target.scrollIntoView();
392 function scrollToLintByURL($scope) {
393 var removeListener = $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
394 scrollToLint(window.location.hash.slice(1));
399 function selectGroup($scope, selectedGroup) {
400 var groups = $scope.groups;
401 for (var group in groups) {
402 if (groups.hasOwnProperty(group)) {
403 if (group === selectedGroup) {
404 groups[group] = true;
406 groups[group] = false;
412 angular.module("clippy", [])
413 .filter('markdown', function ($sce) {
414 return function (text) {
415 return $sce.trustAsHtml(
416 md.render(text || '')
417 // Oh deer, what a hack :O
418 .replace('<table', '<table class="table"')
422 .directive('onFinishRender', function ($timeout) {
425 link: function (scope, element, attr) {
426 if (scope.$last === true) {
427 $timeout(function () {
428 scope.$emit(attr.onFinishRender);
434 .controller("lintList", function ($scope, $http, $timeout) {
436 var LEVEL_FILTERS_DEFAULT = {allow: true, warn: true, deny: true, none: true};
437 $scope.levels = LEVEL_FILTERS_DEFAULT;
438 $scope.byLevels = function (lint) {
439 return $scope.levels[lint.level];
442 var GROUPS_FILTER_DEFAULT = {
454 $scope.groups = GROUPS_FILTER_DEFAULT;
455 $scope.byGroups = function (lint) {
456 return $scope.groups[lint.group];
459 $scope.bySearch = function (lint, index, array) {
460 let searchStr = $scope.search;
461 // It can be `null` I haven't missed this value
462 if (searchStr == null || searchStr.length < 3) {
465 searchStr = searchStr.toLowerCase();
468 if (lint.id.indexOf(searchStr.replace("-", "_")) !== -1) {
472 // Search the description
473 // The use of `for`-loops instead of `foreach` enables us to return early
474 let terms = searchStr.split(" ");
475 let docsLowerCase = lint.docs.toLowerCase();
476 for (index = 0; index < terms.length; index++) {
477 // This is more likely and will therefor be checked first
478 if (docsLowerCase.indexOf(terms[index]) !== -1) {
482 if (lint.id.indexOf(terms[index]) !== -1) {
494 $scope.loading = true;
495 // This will be used to jump into the source code of the version that this documentation is for.
496 $scope.docVersion = window.location.pathname.split('/')[2] || "master";
498 if (window.location.hash.length > 1) {
499 $scope.search = window.location.hash.slice(1);
500 $scope.open[window.location.hash.slice(1)] = true;
501 scrollToLintByURL($scope);
504 $http.get('./lints.json')
505 .success(function (data) {
507 $scope.loading = false;
509 var selectedGroup = getQueryVariable("sel");
511 selectGroup($scope, selectedGroup.toLowerCase());
514 scrollToLintByURL($scope);
516 .error(function (data) {
518 $scope.loading = false;
521 window.addEventListener('hashchange', function () {
523 $timeout(function () {
524 $scope.levels = LEVEL_FILTERS_DEFAULT;
525 $scope.search = window.location.hash.slice(1);
526 $scope.open[window.location.hash.slice(1)] = true;
528 scrollToLintByURL($scope);
535 function getQueryVariable(variable) {
536 var query = window.location.search.substring(1);
537 var vars = query.split('&');
538 for (var i = 0; i < vars.length; i++) {
539 var pair = vars[i].split('=');
540 if (decodeURIComponent(pair[0]) == variable) {
541 return decodeURIComponent(pair[1]);
546 function setupListeners() {
547 let themeIcon = document.getElementById("theme-icon");
548 let themeMenu = document.getElementById("theme-menu");
549 themeIcon.addEventListener("click", function(e) {
550 if (themeMenu.style.display == "none") {
551 themeMenu.style.display = "block";
553 themeMenu.style.display = "none";
557 let children = themeMenu.children;
558 for (let index = 0; index < children.length; index++) {
559 let child = children[index];
560 child.addEventListener("click", function(e) {
561 setTheme(child.id, true);
568 function setTheme(theme, store) {
569 let enableHighlight = false;
570 let enableNight = false;
571 let enableAyu = false;
573 if (theme == "ayu") {
575 } else if (theme == "coal" || theme == "navy") {
577 } else if (theme == "rust") {
578 enableHighlight = true;
580 enableHighlight = true;
581 // this makes sure that an unknown theme request gets set to a known one
584 document.getElementsByTagName("body")[0].className = theme;
586 document.getElementById("styleHighlight").disabled = !enableHighlight;
587 document.getElementById("styleNight").disabled = !enableNight;
588 document.getElementById("styleAyu").disabled = !enableAyu;
592 localStorage.setItem('clippy-lint-list-theme', theme);
597 // loading the theme after the initial load
598 setTheme(localStorage.getItem('clippy-lint-list-theme'), false);