Checks if a specific copyright notice is found in the checked files. A copyright notice can be used as a deterrent against copyright infringement. There are a few configurable parameters for this check. If a copyright notice is lengthy, it may be split across multiple lines in the checked file(s). This is supported by this check. It is required to have your copyright notice on a separate line, so without any code on it.

Configurable parameters

  • Notice (string): The copyright notice that must be included in the files. In order to facilitate checking for a copyright notice of different years, use #YEAR# in the configuration parameter to indicate any year in this century. This will match copyright notices containing a year such as 2011-2018, 2019, 2001 - 2008. In the configuration file, define the copyright notice on a single line, without line breaks or % characters to indicate a comment. For example, a notice defined as Copyright #YEAR# My Company. All rights reserved. will pass this check if your checked file contains %% Copyright 2016-2019 My Company. All rights reserved..

  • Location (list): Indicate the expected location of the copyright notice. May be one of the following:

    • Top: Place the copyright notice at the top of the file, even before any function or classdef headers.

    • BeforeMainCode: Place the copyright notice right after the function or classdef header, but before other code. If the checked file is a script, the copyright notice is searched for at the top of the file.

    • Bottom: Place the copyright notice at the bottom of the file, after all code (also after local functions).

    • Any: All three locations described before are allowed.

This check has an auto-fixer. Clicking the Fix all button in the report fixes all violations for this check, clicking the Fix for this file button fixes the violation for one file.

Exemption tag: %@ok<COPYR>