blob: 95f2f5515824624a833a8e0c59ffb36120dcc403 [file] [log] [blame]
Evan Siroky081c8e42017-05-29 14:53:52 -07001const osmBoundarySources = require('./osmBoundarySources.json')
2const zoneCfg = require('./timezones.json')
evansiroky92c15c42018-11-15 20:58:18 -08003const expectedZoneOverlaps = require('./expectedZoneOverlaps.json')
Evan Siroky081c8e42017-05-29 14:53:52 -07004
5let numErrors = 0
6
7const sourcesUsage = {}
8Object.keys(osmBoundarySources).forEach(source => {
9 sourcesUsage[source] = false
10})
11
12Object.keys(zoneCfg).forEach(zone => {
Evan Siroky628ba252017-07-04 10:46:14 -070013 zoneCfg[zone].forEach((operation, idx) => {
Evan Siroky081c8e42017-05-29 14:53:52 -070014 if (operation.source === 'overpass') {
15 // check if source is defined
16 if (!osmBoundarySources[operation.id]) {
17 numErrors++
18
19 console.error(`No osmBoundarySources config found for entry: ${operation.id}`)
20 } else {
21 sourcesUsage[operation.id] = true
22 }
Evan Siroky628ba252017-07-04 10:46:14 -070023 } else if (operation.source.indexOf('manual') > -1 &&
24 (!operation.description ||
25 operation.description.length < 3)) {
26 numErrors++
27
28 console.error(`No description of ${operation.source} for operation ${idx} of zone: ${zone}`)
Evan Siroky081c8e42017-05-29 14:53:52 -070029 }
30 })
31})
32
33// check for sources not used in timezone building
34Object.keys(sourcesUsage).forEach(source => {
35 if (!sourcesUsage[source]) {
36 numErrors++
37 console.error(`osmBoundarySources config "${source}" is never used in timezone boundary building`)
38 }
39})
40
evansiroky92c15c42018-11-15 20:58:18 -080041// Make sure all expected zone overlaps have a description
42Object.keys(expectedZoneOverlaps).forEach(zoneOverlap => {
43 expectedZoneOverlaps[zoneOverlap].forEach((overlapBounds, idx) => {
44 if (!overlapBounds.description || overlapBounds.description.length < 3) {
45 numErrors++
46 console.error(`Expected overlap #${idx} of zones ${zoneOverlap} missing description`)
47 }
48 })
49})
50
Evan Siroky081c8e42017-05-29 14:53:52 -070051if (numErrors > 0) {
52 console.error(`${numErrors} errors found`)
53 process.exit(1)
54} else {
55 console.log('No linting errors!')
56}