export function getSummary()

in common/output.ts [271:359]


export function getSummary(
  toolName: string,
  projectDir: string,
  sourceDir: string,
  problemsDescriptors: ProblemDescriptor[],
  coverageInfo: string,
  packages: number,
  licensesInfo: string,
  reportUrl: string,
  prMode: boolean,
  dependencyCharsLimit: number,
  reportViewOptionsHelp: string
): string {
  const contactBlock = wrapToToggleBlock('Contact Qodana team', SUMMARY_MISC)
  let licensesBlock = ''
  if (licensesInfo !== '' && licensesInfo.length < dependencyCharsLimit) {
    licensesBlock = wrapToToggleBlock(
      `Detected ${packages} ${getDepencencyPlural(packages)}`,
      licensesInfo
    )
  }
  let prModeBlock = ''
  if (prMode) {
    prModeBlock = SUMMARY_PR_MODE
  }
  if (reportUrl !== '') {
    const firstToolName = toolName.split(' ')[0]
    toolName = toolName.replace(
      firstToolName,
      `[${firstToolName}](${reportUrl})`
    )
  }
  const analysisScope = (
    projectDir === ''
      ? ''
      : ['Analyzed project: `', projectDir, '/`\n'].join('')
  ).concat(
    sourceDir === ''
      ? ''
      : ['Analyzed directory: `', sourceDir, '/`\n'].join('')
  )
  if (problemsDescriptors.length === 0) {
    return [
      `# ${toolName}`,
      analysisScope,
      '**It seems all right 👌**',
      '',
      'No new problems were found according to the checks applied',
      coverageInfo,
      prModeBlock,
      getViewReportText(reportUrl, reportViewOptionsHelp),
      licensesBlock,
      contactBlock
    ].join('\n')
  }

  return [
    `# ${toolName}`,
    analysisScope,
    `**${problemsDescriptors.length} ${getProblemPlural(
      problemsDescriptors.length
    )}** were found`,
    '',
    SUMMARY_TABLE_HEADER,
    SUMMARY_TABLE_SEP,
    [
      getRowsByLevel(
        problemsDescriptors.filter(a => a.level === FAILURE_LEVEL),
        '🔴 Failure'
      ),
      getRowsByLevel(
        problemsDescriptors.filter(a => a.level === WARNING_LEVEL),
        '🔶 Warning'
      ),
      getRowsByLevel(
        problemsDescriptors.filter(a => a.level === NOTICE_LEVEL),
        '◽️ Notice'
      )
    ]
      .filter(e => e !== '')
      .join('\n'),
    '',
    coverageInfo,
    prModeBlock,
    getViewReportText(reportUrl, reportViewOptionsHelp),
    licensesBlock,
    contactBlock
  ].join('\n')
}