1
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
+ -->
2
9
< html lang ="en ">
3
10
< head >
4
11
< meta charset ="UTF-8 "/>
5
12
< meta name ="viewport " content ="width=device-width, initial-scale=1 "/>
6
13
7
- < title > ALL the Clippy Lints</ title >
14
+ < title > Clippy Lints</ title >
8
15
9
16
< link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css "/>
10
17
< link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/styles/github.min.css "/>
22
29
23
30
.panel-heading { cursor : pointer; }
24
31
25
- .panel-title { display : flex; }
32
+ .panel-title { display : flex; flex-wrap : wrap; }
26
33
.panel-title .label { display : inline-block; }
27
34
28
- .panel-title-name { flex : 1 ; }
35
+ .panel-title-name { flex : 1 ; min-width : 400 px ; }
29
36
.panel-title-name span { vertical-align : bottom; }
30
37
31
38
.panel .panel-title-name .anchor { display : none; }
32
39
.panel : hover .panel-title-name .anchor { display : inline;}
33
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
+ }
34
121
</ style >
35
122
< style >
36
123
/* Expanding the mdBoom theme*/
159
246
160
247
< div class ="container " ng-app ="clippy " ng-controller ="lintList ">
161
248
< div class ="page-header ">
162
- < h1 > ALL the Clippy Lints</ h1 >
249
+ < h1 > Clippy Lints</ h1 >
163
250
</ div >
164
251
165
252
< noscript >
@@ -181,9 +268,12 @@ <h1>ALL the Clippy Lints</h1>
181
268
< div class ="panel-body row filter-panel ">
182
269
< div class ="col-md-6 form-inline ">
183
270
< div class ="form-group form-group-lg ">
184
- < p class ="h4 "> Lint levels</ p >
271
+ < p class ="h4 ">
272
+ Lint levels
273
+ < a href ="https://doc.rust-lang.org/rustc/lints/levels.html "> (?)</ a >
274
+ </ p >
185
275
< div class ="checkbox " ng-repeat ="(level, enabled) in levels ">
186
- < label >
276
+ < label class =" text-capitalize " >
187
277
< input type ="checkbox " ng-model ="levels[level] " />
188
278
{{level}}
189
279
</ label >
@@ -192,7 +282,10 @@ <h1>ALL the Clippy Lints</h1>
192
282
</ div >
193
283
< div class ="col-md-6 form-inline ">
194
284
< div class ="form-group form-group-lg ">
195
- < p class ="h4 "> Lint groups</ p >
285
+ < p class ="h4 ">
286
+ Lint groups
287
+ < a href ="https://github.com/rust-lang/rust-clippy/#clippy "> (?)</ a >
288
+ </ p >
196
289
< div class ="checkbox " ng-repeat ="(group, enabled) in groups ">
197
290
< label class ="text-capitalize ">
198
291
< input type ="checkbox " ng-model ="groups[group] " />
@@ -216,9 +309,8 @@ <h1>ALL the Clippy Lints</h1>
216
309
</ div >
217
310
</ div >
218
311
</ div >
219
-
220
- < article class ="panel panel-default " id ="{{lint.id}} "
221
- ng-repeat ="lint in data | filter:byLevels | filter:byGroups | filter:bySearch | orderBy:'id' track by lint.id ">
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 ">
222
314
< header class ="panel-heading " ng-click ="open[lint.id] = !open[lint.id] ">
223
315
< h2 class ="panel-title ">
224
316
< div class ="panel-title-name ">
@@ -227,29 +319,36 @@ <h2 class="panel-title">
227
319
</ div >
228
320
229
321
< div class ="panel-title-addons ">
230
- < span class ="label label-default text-capitalize "> {{lint.group}}</ span >
322
+ < span class ="label label-lint-group label-default label-group-{{lint.group}} "> {{lint.group}}</ span >
323
+
324
+ < span class ="label label-lint-level label-lint-level-{{lint.level}} "> {{lint.level}}</ span >
231
325
232
- < span ng-if ="lint.level == 'Allow' " class ="label label-success "> Allow</ span >
233
- < span ng-if ="lint.level == 'Warn' " class ="label label-warning "> Warn</ span >
234
- < span ng-if ="lint.level == 'Deny' " class ="label label-danger "> Deny</ span >
235
- < span ng-if ="lint.level == 'Deprecated' " class ="label label-default "> Deprecated</ span >
236
326
237
- < button class ="btn btn-default btn-xs ">
238
- < span ng-show ="open[lint.id] "> −</ span >
239
- < span ng-hide ="open[lint.id] "> +</ span >
240
- </ button >
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 >
241
329
</ div >
242
330
</ h2 >
243
331
</ header >
244
332
245
- < ul class ="list-group lint-docs " ng-if ="lint.docs " ng-class ="{collapse: true, in: open[lint.id]} ">
246
- < li class ="list-group-item " ng-repeat ="(title, text) in lint.docs ">
247
- < h4 class ="list-group-item-heading ">
248
- {{title}}
249
- </ h4 >
250
- < div class ="list-group-item-text " ng-bind-html ="text | markdown "> </ div >
251
- < 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 >
252
- </ li >
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 >
341
+ </ div >
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 >
346
+ </ div >
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 >
350
+ </ div >
351
+ </ div >
253
352
</ ul >
254
353
</ article >
255
354
</ div >
@@ -310,22 +409,6 @@ <h4 class="list-group-item-heading">
310
409
}
311
410
}
312
411
313
- function searchLint ( lint , term ) {
314
- for ( const field in lint . docs ) {
315
- // Continue if it's not a property
316
- if ( ! lint . docs . hasOwnProperty ( field ) ) {
317
- continue ;
318
- }
319
-
320
- // Return if not found
321
- if ( lint . docs [ field ] . toLowerCase ( ) . indexOf ( term ) !== - 1 ) {
322
- return true ;
323
- }
324
- }
325
-
326
- return false ;
327
- }
328
-
329
412
angular . module ( "clippy" , [ ] )
330
413
. filter ( 'markdown' , function ( $sce ) {
331
414
return function ( text ) {
@@ -350,13 +433,25 @@ <h4 class="list-group-item-heading">
350
433
} )
351
434
. controller ( "lintList" , function ( $scope , $http , $timeout ) {
352
435
// Level filter
353
- var LEVEL_FILTERS_DEFAULT = { Allow : true , Warn : true , Deny : true , Deprecated : true } ;
436
+ var LEVEL_FILTERS_DEFAULT = { allow : true , warn : true , deny : true , none : true } ;
354
437
$scope . levels = LEVEL_FILTERS_DEFAULT ;
355
438
$scope . byLevels = function ( lint ) {
356
439
return $scope . levels [ lint . level ] ;
357
440
} ;
358
441
359
- $scope . groups = { } ;
442
+ var GROUPS_FILTER_DEFAULT = {
443
+ cargo : true ,
444
+ complexity : true ,
445
+ correctness : true ,
446
+ deprecated : false ,
447
+ nursery : true ,
448
+ pedantic : true ,
449
+ perf : true ,
450
+ restriction : true ,
451
+ style : true ,
452
+ suspicious : true ,
453
+ } ;
454
+ $scope . groups = GROUPS_FILTER_DEFAULT ;
360
455
$scope . byGroups = function ( lint ) {
361
456
return $scope . groups [ lint . group ] ;
362
457
} ;
@@ -377,12 +472,14 @@ <h4 class="list-group-item-heading">
377
472
// Search the description
378
473
// The use of `for`-loops instead of `foreach` enables us to return early
379
474
let terms = searchStr . split ( " " ) ;
475
+ let docsLowerCase = lint . docs . toLowerCase ( ) ;
380
476
for ( index = 0 ; index < terms . length ; index ++ ) {
381
- if ( lint . id . indexOf ( terms [ index ] ) !== - 1 ) {
477
+ // This is more likely and will therefor be checked first
478
+ if ( docsLowerCase . indexOf ( terms [ index ] ) !== - 1 ) {
382
479
continue ;
383
480
}
384
481
385
- if ( searchLint ( lint , terms [ index ] ) ) {
482
+ if ( lint . id . indexOf ( terms [ index ] ) !== - 1 ) {
386
483
continue ;
387
484
}
388
485
@@ -395,6 +492,8 @@ <h4 class="list-group-item-heading">
395
492
// Get data
396
493
$scope . open = { } ;
397
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" ;
398
497
399
498
if ( window . location . hash . length > 1 ) {
400
499
$scope . search = window . location . hash . slice ( 1 ) ;
@@ -407,12 +506,6 @@ <h4 class="list-group-item-heading">
407
506
$scope . data = data ;
408
507
$scope . loading = false ;
409
508
410
- // Initialize lint groups (the same structure is also used to enable filtering)
411
- $scope . groups = data . reduce ( function ( result , val ) {
412
- result [ val . group ] = true ;
413
- return result ;
414
- } , { } ) ;
415
-
416
509
var selectedGroup = getQueryVariable ( "sel" ) ;
417
510
if ( selectedGroup ) {
418
511
selectGroup ( $scope , selectedGroup . toLowerCase ( ) ) ;
0 commit comments