"Fossies" - the Fresh Open Source Software Archive

Member "cli-1.1280.1/packages/snyk-fix/src/plugins/python/map-entities-per-handler-type.ts" (20 Feb 2024, 1136 Bytes) of package /linux/misc/snyk-cli-1.1280.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 import * as debugLib from 'debug';
    2 
    3 import { EntityToFix, WithUserMessage } from '../../types';
    4 import { getHandlerType } from './get-handler-type';
    5 import { SUPPORTED_HANDLER_TYPES } from './supported-handler-types';
    6 
    7 const debug = debugLib('snyk-fix:python');
    8 
    9 export function mapEntitiesPerHandlerType(
   10   entities: EntityToFix[],
   11 ): {
   12   skipped: Array<WithUserMessage<EntityToFix>>;
   13   entitiesPerType: {
   14     [projectType in SUPPORTED_HANDLER_TYPES]: EntityToFix[];
   15   };
   16 } {
   17   const entitiesPerType: {
   18     [projectType in SUPPORTED_HANDLER_TYPES]: EntityToFix[];
   19   } = {
   20     [SUPPORTED_HANDLER_TYPES.REQUIREMENTS]: [],
   21     [SUPPORTED_HANDLER_TYPES.PIPFILE]: [],
   22     [SUPPORTED_HANDLER_TYPES.POETRY]: [],
   23   };
   24 
   25   const skipped: Array<WithUserMessage<EntityToFix>> = [];
   26 
   27   for (const entity of entities) {
   28     const type = getHandlerType(entity);
   29     if (type) {
   30       entitiesPerType[type].push(entity);
   31       continue;
   32     }
   33     const userMessage = `${entity.scanResult.identity.targetFile} is not supported`;
   34     debug(userMessage);
   35     skipped.push({ original: entity, userMessage });
   36   }
   37 
   38   return { entitiesPerType, skipped };
   39 }