{"record":{"id":"6655ade334905d45","repo":"gleam-lang/gleam","slug":"source-files-missing-spdx-licence-information-add-a-comment","errorCode":null,"errorMessage":"Source files missing SPDX licence information!\n\nAdd a comment like this:\n\n    // SPDX-License-Identifier: Apache-2.0\n    // SPDX-FileCopyrightText: 2026 The Gleam contributors\n\nTo these files:\n\n- {paths}\n","messagePattern":"Source files missing SPDX licence information!\n\nAdd a comment like this:\n\n    // SPDX-License-Identifier: Apache-2\\.0\n    // SPDX-FileCopyrightText: 2026 The Gleam contributors\n\nTo these files:\n\n- (.+?)\n","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"compiler-core/src/tests.rs","lineNumber":186,"sourceCode":"                \"html\" if path.starts_with(\"../compiler-core/templates/\") => (),\n\n                _ => panic!(\"Unexpected file extension for {path:?}\"),\n            };\n\n            let text = std::fs::read_to_string(&path).expect(\"read file\");\n            if text.contains(\"SPDX-License-Identifier: Apache-2.0\")\n                && text.contains(\"SPDX-FileCopyrightText: 20\")\n            {\n                // Licence information is present\n                return None;\n            }\n\n            Some(path.to_str().unwrap().to_string())\n        })\n        .join(\"\\n - \");\n\n    if !paths.is_empty() {\n        panic!(\n            \"Source files missing SPDX licence information!\n\nAdd a comment like this:\n\n    // SPDX-License-Identifier: Apache-2.0\n    // SPDX-FileCopyrightText: 2026 The Gleam contributors\n\nTo these files:\n\n- {paths}\n\"\n        )\n    }\n}\n","sourceCodeStart":168,"sourceCodeEnd":201,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-core/src/tests.rs#L168-L201","documentation":"This is a deliberate test-guard panic in the Gleam compiler's test suite (`all_files_have_copyright_notice`). It scans source files and panics when any file lacks the required SPDX licence header comments. It exists to enforce a repository-wide licensing policy: every source file must carry an `SPDX-License-Identifier` and `SPDX-FileCopyrightText` comment so licensing metadata is machine-readable.","triggerScenarios":"Running the Gleam test suite (the `all_files_have_copyright_notice` test, defined around compiler-core/src/tests.rs:186) after adding or generating a new .rs source file without SPDX header comments at the top of the file.","commonSituations":"A contributor creates a new module or test file and forgets the header; a code generator or scaffolding tool writes files without headers; files copied from another project retain a different (or no) licence header; a file header was accidentally removed during a refactor or merge conflict resolution.","solutions":["Add the two SPDX comment lines at the very top of each listed file: `// SPDX-License-Identifier: Apache-2.0` and `// SPDX-FileCopyrightText: 2026 The Gleam contributors`.","Set up an editor snippet, file template, or `cargo fmt`-adjacent pre-commit hook that inserts the header automatically for new .rs files.","If a listed file is generated code, add it to the test's allowlist/ignore list (or configure a licence header tool like `license-header` / `add-license-headers`) rather than editing generated output directly.","Re-run the test to confirm the panic no longer fires and the file list is empty."],"exampleFix":"// before (src/new_module.rs)\npub fn new_module() {}\n\n// after\n// SPDX-License-Identifier: Apache-2.0\n// SPDX-FileCopyrightText: 2026 The Gleam contributors\npub fn new_module() {}","handlingStrategy":"validation","validationCode":"#!/bin/sh\n# check-spdx.sh — run before committing\nfor f in $(git ls-files '*.rs'); do\n  head -n 3 \"$f\" | grep -q 'SPDX-License-Identifier' || echo \"missing SPDX: $f\"\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure an editor file-template or snippet that inserts the SPDX header into every new source file.","Run the licence-header check as a pre-commit hook or CI job so violations surface before the test suite.","Keep generated files in a directory the test ignores, or regenerate them with header emission enabled."],"tags":["licence","spdx","ci","test-suite","contribution"],"backgroundTag":"schema-validation-failed","analyzedSha":"15b07c783065c92bb016b1b74ed0995a5259850f","analyzedAt":"2026-09-14T11:14:59.388Z","contentChangedAt":"2026-09-14T11:14:59.388Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}