MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-workbench / flattenFile

Function flattenFile

src/services/models/flatFile.ts:322–418  ·  view source on GitHub ↗
(file: Resource)

Source from the content-addressed store, hash-verified

320}
321
322export function flattenFile(file: Resource): FlattenedFile {
323 return {
324 id: file.id,
325 fileId: file.id,
326 path: file.path,
327 level: getPathDepth(file.path),
328 parent: parentPath(file.path),
329 copyright_statements: getCopyrightValues(file.copyrights, "copyright"),
330 copyright_holders: getCopyrightValues(file.holders, "holder"),
331 copyright_authors: getCopyrightValues(file.authors, "author"),
332 copyright_start_line: getValues(file.holders, "start_line"),
333 copyright_end_line: getValues(file.holders, "end_line"),
334
335 detected_license_expression: file.detected_license_expression,
336 detected_license_expression_spdx: file.detected_license_expression_spdx,
337 percentage_of_license_text:
338 file?.type === "file" ? file?.percentage_of_license_text : null,
339 license_clues: file.license_clues,
340 license_policy: getLicensePolicyLabel(file.license_policy),
341 license_detections: file.license_detections,
342
343 email: getValues(file.emails, "email"),
344 email_start_line: getValues(file.emails, "start_line"),
345 email_end_line: getValues(file.emails, "end_line"),
346 url: getValues(file.urls, "url"),
347 url_start_line: getValues(file.urls, "start_line"),
348 url_end_line: getValues(file.urls, "end_line"),
349 type: file.type,
350 name: file.name || path.basename(file.path),
351 extension: file.extension || path.extname(file.path),
352 date: file.date,
353 size: file.size,
354 sha1: file.sha1,
355 md5: file.md5,
356 file_count: file.files_count,
357 mime_type: file.mime_type,
358 file_type: file.file_type,
359 programming_language: file.programming_language,
360 for_packages: file.for_packages,
361 is_binary: file.is_binary,
362 is_text: file.is_text,
363 is_archive: file.is_archive,
364 is_media: file.is_media,
365 is_source: file.is_source,
366 is_script: file.is_script,
367 scan_errors: file.scan_errors,
368 package_data_type: getValues(file.package_data, "type"),
369 package_data_namespace: getValues(file.package_data, "namespace"),
370 package_data_name: getValues(file.package_data, "name"),
371 package_data_version: getValues(file.package_data, "version"),
372 package_data_qualifiers: getValues(file.package_data, "qualifiers"),
373 package_data_subpath: getValues(file.package_data, "subpath"),
374 package_data_purl: getValues(file.package_data, "purl"),
375 package_data_primary_language: getValues(
376 file.package_data,
377 "primary_language"
378 ),
379 package_data_code_type: getValues(file.package_data, "code_type"), // @QUERY - Does exist ?

Callers 1

_addFlattenedFilesMethod · 0.90

Calls 5

getPathDepthFunction · 0.90
parentPathFunction · 0.90
getCopyrightValuesFunction · 0.85
getValuesFunction · 0.85
getLicensePolicyLabelFunction · 0.85

Tested by

no test coverage detected