mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-09-16 21:55:37 -05:00
Some Sonar code smell suggestions
This commit is contained in:
@@ -34,17 +34,17 @@ describe('flattenTags', () => {
|
||||
expect(flat.map((t) => t.orderIndex)).toEqual([0, 1, 2, 3, 4, 5, 6])
|
||||
|
||||
// Children are rebuilt
|
||||
const aRoot = flat.find((t) => t.name === 'A-root')!
|
||||
const aRoot = flat.find((t) => t.name === 'A-root')
|
||||
expect(new Set(aRoot.children?.map((c) => c.name))).toEqual(
|
||||
new Set(['child 2', 'Child 10'])
|
||||
)
|
||||
|
||||
const bRoot = flat.find((t) => t.name === 'B-root')!
|
||||
const bRoot = flat.find((t) => t.name === 'B-root')
|
||||
expect(new Set(bRoot.children?.map((c) => c.name))).toEqual(
|
||||
new Set(['Alpha', 'beta'])
|
||||
)
|
||||
|
||||
const child2 = flat.find((t) => t.name === 'child 2')!
|
||||
const child2 = flat.find((t) => t.name === 'child 2')
|
||||
expect(new Set(child2.children?.map((c) => c.name))).toEqual(
|
||||
new Set(['Sub 1'])
|
||||
)
|
||||
|
@@ -8,7 +8,7 @@ export function flattenTags(all: Tag[]): Tag[] {
|
||||
for (const t of map.values()) {
|
||||
if (t.parent) {
|
||||
const p = map.get(t.parent)
|
||||
p && p.children.push(t)
|
||||
p?.children.push(t)
|
||||
}
|
||||
}
|
||||
const roots = Array.from(map.values()).filter((t) => !t.parent)
|
||||
@@ -29,6 +29,7 @@ export function flattenTags(all: Tag[]): Tag[] {
|
||||
}
|
||||
}
|
||||
}
|
||||
roots.sort(sortByName).forEach((r) => walk(r, 0))
|
||||
roots.sort(sortByName)
|
||||
roots.forEach((r) => walk(r, 0))
|
||||
return ordered
|
||||
}
|
||||
|
Reference in New Issue
Block a user