Skip to content

Commit 74e94b0

Browse files
committed
fix: code revies fixes
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
1 parent dee4ffc commit 74e94b0

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

  • services/apps/packages_worker/src/security-contacts/extractors/registry

services/apps/packages_worker/src/security-contacts/extractors/registry/rubygems.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ export function mapRubygemsOwners(
4646
const contacts: RawContact[] = []
4747
const seen = new Set<string>()
4848
for (const owner of owners) {
49-
const email = owner && typeof owner === 'object' ? (owner as any).email : undefined
49+
const o = (owner ?? {}) as Record<string, unknown>
50+
const email = o.email
5051
if (typeof email !== 'string' || !isEmail(email)) continue
5152
const key = email.toLowerCase()
5253
if (seen.has(key)) continue
5354
seen.add(key)
54-
const handle = typeof (owner as any).handle === 'string' ? (owner as any).handle : undefined
55+
const handle = typeof o.handle === 'string' ? o.handle : undefined
5556
contacts.push({
5657
channel: 'email',
5758
value: email,
@@ -83,14 +84,10 @@ export async function fetchRubygems(
8384

8485
if (!gemResult.json) return { contacts: [], policies: {} }
8586

86-
const contacts = mapRubygems(gemResult.json, gemUrl, fetchedAt)
87-
const seen = new Set(contacts.map((c) => c.value.toLowerCase()))
88-
for (const ownerContact of mapRubygemsOwners(ownersResult.json, ownersUrl, fetchedAt)) {
89-
const key = ownerContact.value.toLowerCase()
90-
if (seen.has(key)) continue
91-
seen.add(key)
92-
contacts.push(ownerContact)
93-
}
87+
const contacts = [
88+
...mapRubygems(gemResult.json, gemUrl, fetchedAt),
89+
...mapRubygemsOwners(ownersResult.json, ownersUrl, fetchedAt),
90+
]
9491

9592
return { contacts, policies: {} }
9693
}

0 commit comments

Comments
 (0)