{"record":{"id":"77eaeb6e1fa0dc4b","repo":"badges/shields","slug":"coverage-not-found","errorCode":null,"errorMessage":"coverage not found","messagePattern":"coverage not found","errorType":"exception","errorClass":"NotFound","httpStatus":null,"severity":"error","filePath":"services/scrutinizer/scrutinizer-coverage.service.js","lineNumber":54,"sourceCode":"    label: 'coverage',\n  }\n\n  static render({ coverage }) {\n    return {\n      message: `${coverage.toFixed(0)}%`,\n      color: scale(coverage),\n    }\n  }\n\n  transform({ json, branch }) {\n    const { value: rawCoverage } = this.transformBranchInfoMetricValue({\n      json,\n      branch,\n      metric: 'scrutinizer.test_coverage',\n    })\n\n    if (!rawCoverage) {\n      throw new NotFound({ prettyMessage: 'coverage not found' })\n    }\n\n    return { coverage: rawCoverage * 100 }\n  }\n\n  async makeBadge({ vcs, slug, branch }) {\n    const json = await this.fetch({ schema, vcs, slug })\n    const { coverage } = this.transform({ json, branch })\n    return this.constructor.render({ coverage })\n  }\n}\n\nclass ScrutinizerCoverage extends ScrutinizerCoverageBase {\n  static route = {\n    base: 'scrutinizer/coverage',\n    pattern: ':vcs(g|b)/:user/:repo/:branch*',\n  }\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/scrutinizer/scrutinizer-coverage.service.js#L36-L72","documentation":"NotFound thrown when the Scrutinizer metric value for scrutinizer.test_coverage comes back empty for the requested project/branch. The transform chain succeeded (branch info and index exist) but there is no coverage number, so a coverage badge cannot be rendered.","triggerScenarios":"Requesting a Scrutinizer coverage badge for a project/branch where the analysis completed but reported no test coverage metric — e.g. no tests detected by Scrutinizer, coverage not configured in .scrutinizer.yml, or metric_values missing scrutinizer.test_coverage.","commonSituations":"Repo analyzed but the test command/coverage reporter is not configured; new branch analyzed before CI uploaded coverage; project uses a CI setup Scrutinizer cannot collect coverage from.","solutions":["Configure coverage collection in .scrutinizer.yml (coverage: enabled, proper test commands) so scrutinizer.test_coverage is reported","Verify on the Scrutinizer project page that a coverage percentage is displayed for that branch","Re-run the analysis after enabling coverage and refresh the badge","If coverage genuinely doesn't exist for this repo, don't use the coverage badge — use the build/quality badge instead"],"exampleFix":"// before (.scrutinizer.yml without coverage)\nchecks:\n  javascript: true\n// after\nbuild:\n  tests:\n    override:\n      - command: npm test\n        coverage:\n          file: coverage/lcov.info\n          format: lcov","handlingStrategy":"try-catch","validationCode":"// Check that coverage is reported before using the coverage badge\nasync function hasCoverage(vcs, slug) {\n  const res = await fetch(`https://scrutinizer-ci.com/api/repositories/${vcs}/${slug}`)\n  const repo = await res.json()\n  const app = Object.values(repo.applications || {})[0]\n  const mv = app && app.index && app.index._embedded && app.index._embedded.project && app.index._embedded.project.metric_values\n  return Boolean(mv && mv['scrutinizer.test_coverage'] != null)\n}","typeGuard":"function hasCoverageMetric(metricValues) {\n  return metricValues != null && metricValues['scrutinizer.test_coverage'] != null\n}","tryCatchPattern":"try {\n  const badge = await fetchBadgeUrl(scrutinizerCoverageUrl)\n} catch (e) {\n  if (/coverage not found/.test(e.message)) {\n    console.warn('No coverage reported by Scrutinizer; omitting coverage badge')\n  } else throw e\n}","preventionTips":["Enable coverage collection in .scrutinizer.yml and upload an lcov/clover report from CI","Verify a coverage percentage is shown on the Scrutinizer project page before embedding the badge","Only use the coverage badge on projects with working test coverage pipelines","Remove the badge if the project intentionally has no tests"],"tags":["scrutinizer","coverage","not-found","badge"],"backgroundTag":"resource-not-found","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}