Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sort_findings_by_file.js « utils « diffs « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3a285e80ace22f26134d9026a11520b5a7fd7b09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export function sortFindingsByFile(newErrors = []) {
  const files = {};
  newErrors.forEach(({ filePath, line, description, severity }) => {
    if (!files[filePath]) {
      files[filePath] = [];
    }
    files[filePath].push({ line, description, severity: severity.toLowerCase() });
  });

  const sortedFiles = Object.keys(files)
    .sort()
    .reduce((acc, key) => {
      acc[key] = files[key];
      return acc;
    }, {});
  return { files: sortedFiles };
}