diff --git a/src/analyser/__snapshots__/index.test.ts.snap b/src/analyser/__snapshots__/index.test.ts.snap index a78cd236..7b47c1cd 100644 --- a/src/analyser/__snapshots__/index.test.ts.snap +++ b/src/analyser/__snapshots__/index.test.ts.snap @@ -746,7 +746,7 @@ exports[`analyser > should run correctly 1`] = ` "AMPL": 1, "HCL": 1, "JSON": 1, - "YAML": 2, + "YAML": 3, }, "name": "fake", "path": [ @@ -759,7 +759,7 @@ exports[`analyser > should run correctly 1`] = ` "matched file: .github", "matched file: docker-compose.yml", "matched file: package.json", - "matched file: /.github/workflows/test.yaml", + "matched file: /.github/workflows/invalid.yml", "matched file: deno.lock", "matched file: go.mod", "matched file: Gemfile", @@ -1158,7 +1158,7 @@ exports[`analyser > should run correctly 2`] = ` "JSON": 4, "SCSS": 1, "TOML": 1, - "YAML": 2, + "YAML": 3, }, "name": "fake", "path": [ @@ -1808,7 +1808,7 @@ exports[`analyser > should run correctly 2`] = ` "JSON": 11, "SCSS": 3, "TOML": 3, - "YAML": 4, + "YAML": 6, }, "name": "flatten", "path": [ diff --git a/src/rules/spec/deno/lockfile.ts b/src/rules/spec/deno/lockfile.ts index 9eff5559..f1f91121 100644 --- a/src/rules/spec/deno/lockfile.ts +++ b/src/rules/spec/deno/lockfile.ts @@ -27,11 +27,11 @@ export const detectDenoLockfile: ComponentMatcher = async (files, provider) => { json = JSON.parse(content); } catch (e) { l.warn('Failed to parse deno.lock', file.fp, e); - return false; + continue; } if (!json.version) { - return false; + continue; } const deps = { diff --git a/src/rules/spec/docker/component.ts b/src/rules/spec/docker/component.ts index 42b84a50..553b4c08 100644 --- a/src/rules/spec/docker/component.ts +++ b/src/rules/spec/docker/component.ts @@ -7,6 +7,11 @@ import type { ComponentMatcher } from '../../../types/rule.js'; const FILES_REG = /^docker-compose(.*)?\.y(a)?ml$/; +interface DockerCompose { + services: { + [key: string]: DockerComposeService; + }; +} interface DockerComposeService { image?: string; container_name?: string; @@ -26,10 +31,16 @@ export const detectDockerComponent: ComponentMatcher = async ( continue; } - const parsed = parse(content, {}); - if (!parsed?.services) { - l.warn('Failed to parse Docker file', file.fp); - return false; + let parsed: DockerCompose; + try { + parsed = parse(content, {}); + if (!parsed?.services) { + l.warn('Failed to parse Docker file', file.fp); + continue; + } + } catch (err) { + l.warn('Failed to parse', file.fp, err); + continue; } const pl = new Payload({ name: 'virtual', folderPath: file.fp }); diff --git a/src/rules/spec/githubActions/component.ts b/src/rules/spec/githubActions/component.ts index 32beca4b..49a9250c 100644 --- a/src/rules/spec/githubActions/component.ts +++ b/src/rules/spec/githubActions/component.ts @@ -55,11 +55,11 @@ export const detectGithubActionsComponent: ComponentMatcher = async ( parsed = parse(content, {}); if (!parsed?.jobs) { l.warn('No jobs in GitHub Actions', file.fp); - return false; + continue; } } catch (err) { l.warn('Failed to parse', file.fp, err); - return false; + continue; } const pl = new Payload({ name: 'virtual', folderPath: file.fp }); diff --git a/src/rules/spec/nodejs/component.ts b/src/rules/spec/nodejs/component.ts index 136ef23c..1e760f72 100644 --- a/src/rules/spec/nodejs/component.ts +++ b/src/rules/spec/nodejs/component.ts @@ -27,11 +27,11 @@ export const detectNodeComponent: ComponentMatcher = async ( json = JSON.parse(content); } catch (e) { l.warn('Failed to parse package.json', file.fp, e); - return false; + continue; } if (!json.name) { - return false; + continue; } const deps = { diff --git a/src/rules/spec/php/component.ts b/src/rules/spec/php/component.ts index c39b12aa..d98bd326 100644 --- a/src/rules/spec/php/component.ts +++ b/src/rules/spec/php/component.ts @@ -28,11 +28,11 @@ export const detectPhpComponent: ComponentMatcher = async (files, provider) => { json = JSON.parse(content); } catch (e) { l.warn('Failed to parse composer.json', file.fp, e); - return false; + continue; } if (!json.name) { - return false; + continue; } const deps = { diff --git a/src/rules/spec/rust/component.ts b/src/rules/spec/rust/component.ts index fec6baf5..dc9dd1a3 100644 --- a/src/rules/spec/rust/component.ts +++ b/src/rules/spec/rust/component.ts @@ -42,7 +42,7 @@ export const detectRustComponent: ComponentMatcher = async ( json = toml.parse(content); } catch (e) { l.warn('Failed to parse Cargo.toml', file.fp, e); - return false; + continue; } let pl: Payload; diff --git a/src/rules/spec/terraform/lockfile.ts b/src/rules/spec/terraform/lockfile.ts index 7edb67c6..b4b093d0 100644 --- a/src/rules/spec/terraform/lockfile.ts +++ b/src/rules/spec/terraform/lockfile.ts @@ -30,11 +30,11 @@ export const detectTerraformLockfile: ComponentMatcher = async ( json = await parse(file.fp, content); } catch (err) { l.warn('Failed to parse HCL', file.fp, err); - return false; + continue; } if (!('provider' in json)) { - return false; + continue; } const pl = new Payload({