File has no copyright or licence header

ID

apex.maintainability.license_header

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Header Hygiene

Language

Apex

Description

Reports a file whose first class, interface, enum or trigger declaration is not preceded by a copyright, licence or SPDX identifier.

Rationale

Apex is deployed as source: every class in a managed package or an unlocked package ships readable to the subscriber org, and every class in an org is visible to anyone with the Author Apex permission. A file with no header carries no statement of who owns it or on what terms it may be used, which is what an audit or an acquisition due-diligence review looks for first - and retrofitting headers across a package afterwards means touching every file and re-running every test.

The following code illustrates the pattern detected by this rule:

// FLAGGED: File has no copyright or licence header
public class UnlicensedService {
    public void run() {
        System.debug('no header above this class');
    }
}

Remediation

Put the project’s standard header at the top of the file, above the declaration. An SPDX-License-Identifier line is enough where the full text lives in a LICENSE file, and it is what automated licence scanners read.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved