MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / validateRawFile

Function validateRawFile

lib/properties-validator.ts:189–598  ·  view source on GitHub ↗
(
    parsed: ParsedPropertiesFile,
    options: RawValidatorOptions = {},
)

Source from the content-addressed store, hash-verified

187 * Validate a parsed properties file for various issues.
188 */
189export function validateRawFile(
190 parsed: ParsedPropertiesFile,
191 options: RawValidatorOptions = {},
192): RawFileValidationResult {
193 const result: RawFileValidationResult = {
194 duplicateKeys: [],
195 emptyListElements: [],
196 typoCompilers: [],
197 invalidPropertyFormat: [...parsed.parseErrors], // Copy parse errors from library
198 suspiciousPaths: [],
199 duplicatedCompilerRefs: [],
200 duplicatedGroupRefs: [],
201 orphanedCompilerExe: [],
202 orphanedCompilerId: [],
203 orphanedGroups: [],
204 orphanedFormatterExe: [],
205 orphanedFormatterId: [],
206 orphanedToolExe: [],
207 orphanedToolId: [],
208 orphanedLibIds: [],
209 orphanedLibVersions: [],
210 invalidDefaultCompiler: [],
211 noCompilersList: false,
212 };
213
214 // Track what we've seen
215 const seenKeys = new Set<string>();
216 const listedCompilers = new Map<string, number>(); // id -> line number
217 const listedGroups = new Map<string, number>(); // group name -> line number
218 const seenCompilersExe = new Map<string, number>();
219 const seenCompilersId = new Set<string>();
220 const seenGroups = new Set<string>();
221
222 const listedFormatters = new Map<string, number>();
223 const seenFormattersExe = new Map<string, number>();
224 const seenFormattersId = new Set<string>();
225
226 const listedTools = new Map<string, number>();
227 const seenToolsExe = new Map<string, number>();
228 const seenToolsId = new Set<string>();
229
230 const listedLibsIds = new Map<string, number>();
231 const seenLibsIds = new Set<string>();
232
233 const listedLibVersions = new Map<string, number>(); // "libid version" -> line
234 const seenLibVersions = new Set<string>(); // "libid version"
235
236 let defaultCompiler: {id: string; line: number} | undefined;
237
238 const checkSuspicious =
239 options.checkSuspiciousPaths &&
240 !parsed.filename.endsWith('.defaults.properties') &&
241 !parsed.filename.endsWith('.local.properties');
242
243 // First pass: collect all data
244 for (const prop of parsed.properties) {
245 const {key, value, line} = prop;
246 const fullLine = `${key}=${value}`;

Callers 3

validateFunction · 0.85
collectIssuesFunction · 0.85

Calls 8

parseCompilersListFunction · 0.85
isSuspiciousPathFunction · 0.85
pushMethod · 0.80
testMethod · 0.80
matchMethod · 0.80
findMethod · 0.80
setMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected