@@ -18,14 +18,14 @@ export async function main(load, display) {
18
18
// Wait for DOM to be ready before displaying
19
19
await DOM_READY ;
20
20
await display ( data ) ;
21
- monitor_options ( ) ;
21
+ monitorOptions ( ) ;
22
22
23
23
// Full workflow, loading then displaying data
24
24
// used for following updates
25
25
const full = async function ( ) {
26
26
const data = await load ( ) ;
27
27
await display ( data ) ;
28
- monitor_options ( ) ;
28
+ monitorOptions ( ) ;
29
29
} ;
30
30
31
31
// React to url changes
@@ -36,13 +36,13 @@ export async function main(load, display) {
36
36
37
37
const COVERAGE_BACKEND_HOST = process . env . BACKEND_URL ;
38
38
39
- function cache_get ( cache , key ) {
39
+ function cacheGet ( cache , key ) {
40
40
if ( key in cache ) {
41
41
return cache [ key ] . val ;
42
42
}
43
43
}
44
44
45
- function cache_set ( cache , key , value ) {
45
+ function cacheSet ( cache , key , value ) {
46
46
const now = new Date ( ) . getTime ( ) / 1000 ;
47
47
48
48
// If the cache got too big, remove all elements that were added more
@@ -61,10 +61,10 @@ function cache_set(cache, key, value) {
61
61
} ;
62
62
}
63
63
64
- const path_coverage_cache = { } ;
65
- export async function get_path_coverage ( path , changeset , platform , suite ) {
66
- const cache_key = `${ changeset } _${ path } _${ platform } _${ suite } ` ;
67
- let data = cache_get ( path_coverage_cache , cache_key ) ;
64
+ const pathCoverageCache = { } ;
65
+ export async function getPathCoverage ( path , changeset , platform , suite ) {
66
+ const cacheKey = `${ changeset } _${ path } _${ platform } _${ suite } ` ;
67
+ let data = cacheGet ( pathCoverageCache , cacheKey ) ;
68
68
if ( data ) {
69
69
return data ;
70
70
}
@@ -87,20 +87,20 @@ export async function get_path_coverage(path, changeset, platform, suite) {
87
87
}
88
88
data = await response . json ( ) ;
89
89
90
- cache_set ( path_coverage_cache , cache_key , data ) ;
90
+ cacheSet ( pathCoverageCache , cacheKey , data ) ;
91
91
92
92
return data ;
93
93
}
94
94
95
- const history_cache = { } ;
96
- export async function get_history ( path , platform , suite ) {
95
+ const historyCache = { } ;
96
+ export async function getHistory ( path , platform , suite ) {
97
97
// Backend needs path without trailing /
98
98
if ( path && path . endsWith ( "/" ) ) {
99
99
path = path . substring ( 0 , path . length - 1 ) ;
100
100
}
101
101
102
- const cache_key = `${ path } _${ platform } _${ suite } ` ;
103
- let data = cache_get ( history_cache , cache_key ) ;
102
+ const cacheKey = `${ path } _${ platform } _${ suite } ` ;
103
+ let data = cacheGet ( historyCache , cacheKey ) ;
104
104
if ( data ) {
105
105
return data ;
106
106
}
@@ -115,7 +115,7 @@ export async function get_history(path, platform, suite) {
115
115
const response = await fetch ( `${ COVERAGE_BACKEND_HOST } /v2/history?${ params } ` ) ;
116
116
data = await response . json ( ) ;
117
117
118
- cache_set ( history_cache , cache_key , data ) ;
118
+ cacheSet ( historyCache , cacheKey , data ) ;
119
119
120
120
// Check data has coverage values
121
121
// These values are missing when going above 2 levels right now
@@ -130,41 +130,41 @@ export async function get_history(path, platform, suite) {
130
130
return data ;
131
131
}
132
132
133
- const zero_coverage_cache = { } ;
134
- export async function get_zero_coverage_data ( ) {
135
- let data = cache_get ( zero_coverage_cache , "" ) ;
133
+ const zeroCoverageCache = { } ;
134
+ export async function getZeroCoverageData ( ) {
135
+ let data = cacheGet ( zeroCoverageCache , "" ) ;
136
136
if ( data ) {
137
137
return data ;
138
138
}
139
139
140
140
const response = await fetch (
141
- "https://index.taskcluster.net/v1/task/project.releng.services.project.production.code_coverage_bot.latest/artifacts/public/zero_coverage_report .json"
141
+ "https://index.taskcluster.net/v1/task/project.releng.services.project.production.code_coverage_bot.latest/artifacts/public/zeroCoverage_report .json"
142
142
) ;
143
143
data = await response . json ( ) ;
144
144
145
- cache_set ( zero_coverage_cache , "" , data ) ;
145
+ cacheSet ( zeroCoverageCache , "" , data ) ;
146
146
147
147
return data ;
148
148
}
149
149
150
- const filters_cache = { } ;
151
- export async function get_filters ( ) {
152
- let data = cache_get ( filters_cache , "" ) ;
150
+ const filtersCache = { } ;
151
+ export async function getFilters ( ) {
152
+ let data = cacheGet ( filtersCache , "" ) ;
153
153
if ( data ) {
154
154
return data ;
155
155
}
156
156
157
157
const response = await fetch ( `${ COVERAGE_BACKEND_HOST } /v2/filters` ) ;
158
158
data = await response . json ( ) ;
159
159
160
- cache_set ( filters_cache , "" , data ) ;
160
+ cacheSet ( filtersCache , "" , data ) ;
161
161
162
162
return data ;
163
163
}
164
164
165
165
// Option handling.
166
166
167
- export function is_enabled ( opt ) {
167
+ export function isEnabled ( opt ) {
168
168
const route = readRoute ( ) ;
169
169
let value = "off" ;
170
170
if ( route [ opt ] ) {
@@ -175,7 +175,7 @@ export function is_enabled(opt) {
175
175
return value === "on" ;
176
176
}
177
177
178
- function monitor_options ( ) {
178
+ function monitorOptions ( ) {
179
179
// Monitor input & select changes
180
180
const fields = document . querySelectorAll ( "input, select" ) ;
181
181
for ( const field of fields ) {
@@ -205,7 +205,7 @@ function monitor_options() {
205
205
206
206
// hgmo.
207
207
208
- export async function get_source ( file ) {
208
+ export async function getSource ( file ) {
209
209
const response = await fetch (
210
210
`https://hg.mozilla.org/mozilla-central/raw-file/tip/${ file } `
211
211
) ;
@@ -214,24 +214,24 @@ export async function get_source(file) {
214
214
215
215
// Filtering.
216
216
217
- const get_third_party_paths = ( function ( ) {
217
+ const getThirdPartyPaths = ( function ( ) {
218
218
let paths = null ;
219
219
return async function ( ) {
220
220
if ( ! paths ) {
221
- const response = await get_source ( "tools/rewriting/ThirdPartyPaths.txt" ) ;
221
+ const response = await getSource ( "tools/rewriting/ThirdPartyPaths.txt" ) ;
222
222
paths = response . split ( "\n" ) . filter ( path => path !== "" ) ;
223
223
}
224
224
225
225
return paths ;
226
226
} ;
227
227
} ) ( ) ;
228
228
229
- export async function filter_third_party ( files ) {
230
- if ( is_enabled ( "third_party" ) ) {
229
+ export async function filterThirdParty ( files ) {
230
+ if ( isEnabled ( "third_party" ) ) {
231
231
return files ;
232
232
}
233
233
234
- const paths = await get_third_party_paths ( ) ;
234
+ const paths = await getThirdPartyPaths ( ) ;
235
235
236
236
return files . filter ( file => {
237
237
for ( const path of paths ) {
@@ -244,9 +244,9 @@ export async function filter_third_party(files) {
244
244
} ) ;
245
245
}
246
246
247
- export function filter_languages ( files ) {
248
- const cpp = is_enabled ( "cpp" ) ;
249
- const cpp_extensions = [
247
+ export function filterLanguages ( files ) {
248
+ const cpp = isEnabled ( "cpp" ) ;
249
+ const cppExtensions = [
250
250
"c" ,
251
251
"cpp" ,
252
252
"cxx" ,
@@ -258,68 +258,68 @@ export function filter_languages(files) {
258
258
"inl" ,
259
259
"inc"
260
260
] ;
261
- const js = is_enabled ( "js" ) ;
262
- const js_extensions = [ "js" , "jsm" , "xml" , "xul" , "xhtml" , "html" ] ;
263
- const java = is_enabled ( "java" ) ;
264
- const java_extensions = [ "java" ] ;
265
- const rust = is_enabled ( "rust" ) ;
266
- const rust_extensions = [ "rs" ] ;
261
+ const js = isEnabled ( "js" ) ;
262
+ const jsExtensions = [ "js" , "jsm" , "xml" , "xul" , "xhtml" , "html" ] ;
263
+ const java = isEnabled ( "java" ) ;
264
+ const javaExtensions = [ "java" ] ;
265
+ const rust = isEnabled ( "rust" ) ;
266
+ const rustExtensions = [ "rs" ] ;
267
267
268
268
return files . filter ( file => {
269
269
if ( file . type === "directory" ) {
270
270
return true ;
271
- } else if ( cpp_extensions . find ( ext => file . path . endsWith ( "." + ext ) ) ) {
271
+ } else if ( cppExtensions . find ( ext => file . path . endsWith ( "." + ext ) ) ) {
272
272
return cpp ;
273
- } else if ( js_extensions . find ( ext => file . path . endsWith ( "." + ext ) ) ) {
273
+ } else if ( jsExtensions . find ( ext => file . path . endsWith ( "." + ext ) ) ) {
274
274
return js ;
275
- } else if ( rust_extensions . find ( ext => file . path . endsWith ( "." + ext ) ) ) {
275
+ } else if ( rustExtensions . find ( ext => file . path . endsWith ( "." + ext ) ) ) {
276
276
return rust ;
277
- } else if ( java_extensions . find ( ext => file . path . endsWith ( "." + ext ) ) ) {
277
+ } else if ( javaExtensions . find ( ext => file . path . endsWith ( "." + ext ) ) ) {
278
278
return java ;
279
279
}
280
280
console . warn ( "Unknown language for " + file . path ) ;
281
281
return false ;
282
282
} ) ;
283
283
}
284
284
285
- export function filter_headers ( files ) {
286
- if ( is_enabled ( "headers" ) ) {
285
+ export function filterHeaders ( files ) {
286
+ if ( isEnabled ( "headers" ) ) {
287
287
return files ;
288
288
}
289
289
290
290
return files . filter ( file => ! file . path . endsWith ( ".h" ) ) ;
291
291
}
292
292
293
- export function filter_completely_uncovered ( files ) {
294
- if ( ! is_enabled ( "completely_uncovered" ) ) {
293
+ export function filterCompletelyUncovered ( files ) {
294
+ if ( ! isEnabled ( "completely_uncovered" ) ) {
295
295
return files ;
296
296
}
297
297
298
298
return files . filter ( file => file . uncovered ) ;
299
299
}
300
300
301
- export function filter_last_push_date ( files ) {
301
+ export function filterLastPushDate ( files ) {
302
302
const elem = document . getElementById ( "last_push" ) ;
303
- const upper_limit = new Date ( ) ;
304
- let lower_limit = new Date ( ) ;
303
+ const upperLimit = new Date ( ) ;
304
+ let lowerLimit = new Date ( ) ;
305
305
306
306
if ( elem . value === "one_year" ) {
307
- lower_limit . setFullYear ( upper_limit . getFullYear ( ) - 1 ) ;
307
+ lowerLimit . setFullYear ( upperLimit . getFullYear ( ) - 1 ) ;
308
308
} else if ( elem . value === "two_years" ) {
309
- upper_limit . setFullYear ( upper_limit . getFullYear ( ) - 1 ) ;
310
- lower_limit . setFullYear ( lower_limit . getFullYear ( ) - 2 ) ;
309
+ upperLimit . setFullYear ( upperLimit . getFullYear ( ) - 1 ) ;
310
+ lowerLimit . setFullYear ( lowerLimit . getFullYear ( ) - 2 ) ;
311
311
} else if ( elem . value === "older_than_two_years" ) {
312
- upper_limit . setFullYear ( upper_limit . getFullYear ( ) - 2 ) ;
313
- lower_limit = new Date ( "1970-01-01T00:00:00Z" ) ;
312
+ upperLimit . setFullYear ( upperLimit . getFullYear ( ) - 2 ) ;
313
+ lowerLimit = new Date ( "1970-01-01T00:00:00Z" ) ;
314
314
} else {
315
315
return files ;
316
316
}
317
317
318
318
return files . filter ( file => {
319
- const last_push_date = new Date ( file . last_push_date ) ;
319
+ const lastPushDate = new Date ( file . lastPushDate ) ;
320
320
if (
321
- last_push_date . getTime ( ) <= upper_limit . getTime ( ) &&
322
- last_push_date . getTime ( ) >= lower_limit . getTime ( )
321
+ lastPushDate . getTime ( ) <= upperLimit . getTime ( ) &&
322
+ lastPushDate . getTime ( ) >= lowerLimit . getTime ( )
323
323
) {
324
324
return true ;
325
325
}
@@ -328,7 +328,7 @@ export function filter_last_push_date(files) {
328
328
}
329
329
330
330
// Build the urls for a breadcrumb Navbar from a path
331
- export function build_navbar ( path , revision ) {
331
+ export function buildNavbar ( path , revision ) {
332
332
if ( path . endsWith ( "/" ) ) {
333
333
path = path . substring ( 0 , path . length - 1 ) ;
334
334
}
0 commit comments