Evan Siroky | 081c8e4 | 2017-05-29 14:53:52 -0700 | [diff] [blame] | 1 | const osmBoundarySources = require('./osmBoundarySources.json') |
| 2 | const zoneCfg = require('./timezones.json') |
| 3 | |
| 4 | let numErrors = 0 |
| 5 | |
| 6 | const sourcesUsage = {} |
| 7 | Object.keys(osmBoundarySources).forEach(source => { |
| 8 | sourcesUsage[source] = false |
| 9 | }) |
| 10 | |
| 11 | Object.keys(zoneCfg).forEach(zone => { |
Evan Siroky | 628ba25 | 2017-07-04 10:46:14 -0700 | [diff] [blame^] | 12 | zoneCfg[zone].forEach((operation, idx) => { |
Evan Siroky | 081c8e4 | 2017-05-29 14:53:52 -0700 | [diff] [blame] | 13 | 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 Siroky | 628ba25 | 2017-07-04 10:46:14 -0700 | [diff] [blame^] | 22 | } 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 Siroky | 081c8e4 | 2017-05-29 14:53:52 -0700 | [diff] [blame] | 28 | } |
| 29 | }) |
| 30 | }) |
| 31 | |
| 32 | // check for sources not used in timezone building |
| 33 | Object.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 | |
| 40 | if (numErrors > 0) { |
| 41 | console.error(`${numErrors} errors found`) |
| 42 | process.exit(1) |
| 43 | } else { |
| 44 | console.log('No linting errors!') |
| 45 | } |