blob: 9884ccff291cc13e65469a2097eeed4ca30c4fd2 [file] [log] [blame]
Evan Siroky081c8e42017-05-29 14:53:52 -07001const osmBoundarySources = require('./osmBoundarySources.json')
2const zoneCfg = require('./timezones.json')
3
4let numErrors = 0
5
6const sourcesUsage = {}
7Object.keys(osmBoundarySources).forEach(source => {
8 sourcesUsage[source] = false
9})
10
11Object.keys(zoneCfg).forEach(zone => {
Evan Siroky628ba252017-07-04 10:46:14 -070012 zoneCfg[zone].forEach((operation, idx) => {
Evan Siroky081c8e42017-05-29 14:53:52 -070013 if (operation.source === 'overpass') {
14 // check if source is defined
15 if (!osmBoundarySources[operation.id]) {
16 numErrors++
17
18 console.error(`No osmBoundarySources config found for entry: ${operation.id}`)
19 } else {
20 sourcesUsage[operation.id] = true
21 }
Evan Siroky628ba252017-07-04 10:46:14 -070022 } else if (operation.source.indexOf('manual') > -1 &&
23 (!operation.description ||
24 operation.description.length < 3)) {
25 numErrors++
26
27 console.error(`No description of ${operation.source} for operation ${idx} of zone: ${zone}`)
Evan Siroky081c8e42017-05-29 14:53:52 -070028 }
29 })
30})
31
32// check for sources not used in timezone building
33Object.keys(sourcesUsage).forEach(source => {
34 if (!sourcesUsage[source]) {
35 numErrors++
36 console.error(`osmBoundarySources config "${source}" is never used in timezone boundary building`)
37 }
38})
39
40if (numErrors > 0) {
41 console.error(`${numErrors} errors found`)
42 process.exit(1)
43} else {
44 console.log('No linting errors!')
45}