-
-
Notifications
You must be signed in to change notification settings - Fork 224
/
audit_blocks.js
58 lines (54 loc) · 1.73 KB
/
audit_blocks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* eslint-env mocha */
const fs = require('fs')
const path = require('path')
// checks for duplicates names and jumps in ids
require('./version_iterator')(function (p, versionString) {
describe('audit blocks ' + versionString, function () {
it('audit blocks', function () {
let blocks
const pFile = path.join(p, 'blocks.json')
if (fs.existsSync(pFile)) {
blocks = require(pFile)
} else {
// console.log('No blocks for version ' + versionString)
}
if (blocks) {
const all = []
blocks.forEach(block => {
all[block.id] = block
})
const displayNames = {}
const names = {}
for (let i = 0; i < all.length; ++i) {
const block = all[i]
if (block) {
if (block.displayName == null) {
// console.log('Missing displayName:', i)
} else {
const otherBlock = displayNames[block.displayName]
if (otherBlock) {
// console.log('Duplicate displayName:', otherBlock.id, 'and', block.id,
// 'both share', block.displayName)
} else {
displayNames[block.displayName] = block
}
}
if (block.name == null) {
console.log('Missing name:', i)
} else {
const otherBlock = names[block.name]
if (otherBlock) {
// console.log('Duplicate name:', otherBlock.id, 'and', block.id,
// 'both share', block.name)
} else {
names[block.name] = block
}
}
} else {
// console.log('Missing:', i)
}
}
}
})
})
})