4 <meta charset="UTF-8"/>
5 <meta name="viewport" content="width=device-width, initial-scale=1"/>
7 <title>ALL the Clippy Lints</title>
9 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css"/>
10 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/styles/github.min.css"/>
12 blockquote { font-size: 1em; }
13 [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; }
15 .form-inline .checkbox { margin-right: 0.6em }
17 .panel-heading { cursor: pointer; }
18 .panel-heading:hover { background-color: #eee; }
20 .panel-title { display: flex; }
21 .panel-title .label { display: inline-block; }
23 .panel-title-name { flex: 1; }
24 .panel-title-name span { vertical-align: bottom; }
26 .panel .panel-title-name .anchor { display: none; }
27 .panel:hover .panel-title-name .anchor { display: inline; color: #fff; }
31 <div class="container" ng-app="clippy" ng-controller="lintList">
32 <div class="page-header">
33 <h1>ALL the Clippy Lints</h1>
37 <div class="alert alert-danger" role="alert">
38 Sorry, this site only works with JavaScript! :(
44 <div class="alert alert-info" role="alert" ng-if="loading">
47 <div class="alert alert-danger" role="alert" ng-if="error">
51 <div class="panel panel-default" ng-show="data">
52 <div class="panel-body row">
53 <div class="col-md-6 form-inline">
54 <div class="form-group form-group-lg">
55 <p class="h4">Lint levels</p>
56 <div class="checkbox" ng-repeat="(level, enabled) in levels">
58 <input type="checkbox" ng-model="levels[level]" />
64 <div class="col-md-6 form-inline">
65 <div class="form-group form-group-lg">
66 <p class="h4">Lint groups</p>
67 <div class="checkbox" ng-repeat="(group, enabled) in groups">
68 <label class="text-capitalize">
69 <input type="checkbox" ng-model="groups[group]" />
76 <div class="panel-body row">
77 <div class="col-md-12 form-horizontal">
78 <div class="input-group">
79 <label class="input-group-addon" id="filter-label" for="filter-input">Filter:</label>
80 <input type="text" class="form-control" placeholder="Keywords or search string" id="filter-input" ng-model="search" ng-model-options="{debounce: 50}"/>
81 <span class="input-group-btn">
82 <button class="btn btn-default" type="button" ng-click="search = ''">
91 <article class="panel panel-default" id="{{lint.id}}"
92 ng-repeat="lint in data | filter:byLevels | filter:byGroups | filter:bySearch | orderBy:'id' track by lint.id">
93 <header class="panel-heading" ng-click="open[lint.id] = !open[lint.id]">
94 <h2 class="panel-title">
95 <div class="panel-title-name">
96 <span>{{lint.id}}</span>
97 <a href="#{{lint.id}}" class="anchor label label-default" ng-click="open[lint.id] = true; $event.stopPropagation()">¶</a>
100 <div class="panel-title-addons">
101 <span class="label label-default text-capitalize">{{lint.group}}</span>
103 <span ng-if="lint.level == 'Allow'" class="label label-success">Allow</span>
104 <span ng-if="lint.level == 'Warn'" class="label label-warning">Warn</span>
105 <span ng-if="lint.level == 'Deny'" class="label label-danger">Deny</span>
106 <span ng-if="lint.level == 'Deprecated'" class="label label-default">Deprecated</span>
108 <button class="btn btn-default btn-xs">
109 <span ng-show="open[lint.id]">−</span>
110 <span ng-hide="open[lint.id]">+</span>
116 <ul class="list-group lint-docs" ng-if="lint.docs" ng-class="{collapse: true, in: open[lint.id]}">
117 <li class="list-group-item" ng-repeat="(title, text) in lint.docs">
118 <h4 class="list-group-item-heading">
121 <div class="list-group-item-text" ng-bind-html="text | markdown"></div>
122 <a ng-if="title == 'Known problems'" href="https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+{{lint.id}}">Search on GitHub</a>
129 <a href="https://github.com/rust-lang/rust-clippy">
130 <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"/>
133 <script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/7.0.0/markdown-it.min.js"></script>
134 <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script>
135 <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/languages/rust.min.js"></script>
136 <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.12/angular.min.js"></script>
139 var md = window.markdownit({
143 highlight: function (str, lang) {
144 if (lang && hljs.getLanguage(lang)) {
146 return '<pre class="hljs"><code>' +
147 hljs.highlight(lang, str, true).value +
152 return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
156 function scrollToLint(lintId) {
157 var target = document.getElementById(lintId);
161 target.scrollIntoView();
164 function scrollToLintByURL($scope) {
165 var removeListener = $scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
166 scrollToLint(window.location.hash.slice(1));
171 function selectGroup($scope, selectedGroup) {
172 var groups = $scope.groups;
173 for (var group in groups) {
174 if (groups.hasOwnProperty(group)) {
175 if (group === selectedGroup) {
176 groups[group] = true;
178 groups[group] = false;
184 function searchLint(lint, term) {
185 for (const field in lint.docs) {
186 // Continue if it's not a property
187 if (!lint.docs.hasOwnProperty(field)) {
191 // Return if not found
192 if (lint.docs[field].toLowerCase().indexOf(term) !== -1) {
200 angular.module("clippy", [])
201 .filter('markdown', function ($sce) {
202 return function (text) {
203 return $sce.trustAsHtml(
204 md.render(text || '')
205 // Oh deer, what a hack :O
206 .replace('<table', '<table class="table"')
210 .directive('onFinishRender', function ($timeout) {
213 link: function (scope, element, attr) {
214 if (scope.$last === true) {
215 $timeout(function () {
216 scope.$emit(attr.onFinishRender);
222 .controller("lintList", function ($scope, $http, $timeout) {
224 var LEVEL_FILTERS_DEFAULT = {Allow: true, Warn: true, Deny: true, Deprecated: true};
225 $scope.levels = LEVEL_FILTERS_DEFAULT;
226 $scope.byLevels = function (lint) {
227 return $scope.levels[lint.level];
231 $scope.byGroups = function (lint) {
232 return $scope.groups[lint.group];
235 $scope.bySearch = function (lint, index, array) {
236 let searchStr = $scope.search;
237 // It can be `null` I haven't missed this value
238 if (searchStr == null || searchStr.length < 3) {
241 searchStr = searchStr.toLowerCase();
244 if (lint.id.indexOf(searchStr.replace("-", "_")) !== -1) {
248 // Search the description
249 // The use of `for`-loops instead of `foreach` enables us to return early
250 let terms = searchStr.split(" ");
251 for (index = 0; index < terms.length; index++) {
252 if (lint.id.indexOf(terms[index]) !== -1) {
256 if (searchLint(lint, terms[index])) {
268 $scope.loading = true;
270 if (window.location.hash.length > 1) {
271 $scope.search = window.location.hash.slice(1);
272 $scope.open[window.location.hash.slice(1)] = true;
273 scrollToLintByURL($scope);
276 $http.get('./lints.json')
277 .success(function (data) {
279 $scope.loading = false;
281 // Initialize lint groups (the same structure is also used to enable filtering)
282 $scope.groups = data.reduce(function (result, val) {
283 result[val.group] = true;
287 var selectedGroup = getQueryVariable("sel");
289 selectGroup($scope, selectedGroup.toLowerCase());
292 scrollToLintByURL($scope);
294 .error(function (data) {
296 $scope.loading = false;
299 window.addEventListener('hashchange', function () {
301 $timeout(function () {
302 $scope.levels = LEVEL_FILTERS_DEFAULT;
303 $scope.search = window.location.hash.slice(1);
304 $scope.open[window.location.hash.slice(1)] = true;
306 scrollToLintByURL($scope);
313 function getQueryVariable(variable) {
314 var query = window.location.search.substring(1);
315 var vars = query.split('&');
316 for (var i = 0; i < vars.length; i++) {
317 var pair = vars[i].split('=');
318 if (decodeURIComponent(pair[0]) == variable) {
319 return decodeURIComponent(pair[1]);