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