Skip to content

Suppressing findings ​

In the code ​

Put a comment right before the statement or declaration:

php
// @custos-ignore OneTimeUseVariables
$total = compute();

/** @noinspection OneTimeUseVariablesInspection */
function legacy() { /* … */ }
  • @custos-ignore and @noinspection work the same way and accept a rule ID or, for EA rules, the PhpStorm name (<ID>Inspection). Comments written for Php Inspections (EA Extended) in PhpStorm therefore keep working. Native rules have no PhpStorm name: use their rule ID.

  • PossiblyNullAccess and PossiblyNullArgument take over the possible nulls NullPointerException would otherwise report, so a suppression of NullPointerException silences them too.

  • Names are case-sensitive: @custos-ignore onetimeusevariables suppresses nothing.

  • Several names can be listed: // @custos-ignore UnusedGotoLabel, UnnecessarySemicolon.

  • ALL suppresses every rule: // @custos-ignore ALL.

  • The rest of the line is read as names too; words that name no rule are ignored, so a short reason can follow, as in the example below. Keep ALL and rule IDs out of the reason.

  • UnknownInspection points out @noinspection names in block comments that match no rule, such as a typo or a removed rule.

  • Put the comment before the first statement of a file to suppress the rules for the whole file.

  • A comment right before a parameter, a property hook, a call argument or an array item suppresses the rules for that element only, even inside a statement that spans several lines:

    php
    return new SettingsRow(
        'Layout',
        // @noinspection JsonEncodingApiUsageInspection -- the value is display text
        value: (string) \json_encode($layout),
        hint: \json_encode($hint), // still reported
    );

In an editor, the language server offers a Suppress … for this statement action that writes the comment for you. See Editors.

Turning rules off ​

To stop a rule everywhere, disable it in custos.json:

json
{ "rules": { "StaticClosureCanBeUsed": { "enabled": false } } }

Baseline ​

On a legacy code base, a baseline records today's findings so that only new ones are reported:

sh
custos analyse --generate-baseline custos-baseline.json

Commit the file and reference it from custos.json, relative to the project root:

json
{ "baseline": "custos-baseline.json" }

analyse then hides the recorded findings, and so do the language server and the MCP server. A baseline named in custos.json that does not exist yet suppresses nothing. You can also pass --baseline FILE (relative to the current directory), which must exist. --generate-baseline writes its file relative to the current directory too. --stats prints how many findings the baseline suppressed.

Baseline entries match on file, rule, message and the text of the flagged line, not on line numbers, so they survive code moving around. Each entry counts its occurrences: a second identical finding on an identical line is new. Regenerate the baseline after fixing old findings to keep it small. A possible null that NullPointerException recorded and that PossiblyNullAccess or PossiblyNullArgument now reports on the same line (or the reverse) stays covered, whatever the message. PossiblyNullAccess reports a value once, after its first reported access; a baseline entry of that access does not count as reported, so a later access is reported (the baseline you generate records them all).

The file is JSON, sorted so that it diffs well:

json
{
  "version": 1,
  "entries": [
    { "path": "src/Legacy.php", "rule": "OneTimeUseVariables", "message": "…", "line": "$total = compute();", "count": 1 }
  ]
}

Entry paths are relative to the baseline file's own directory: move the file and its entries no longer match, so regenerate it instead. Tool findings (syntax, io, internal) are never recorded.

Released under the MIT License. Native rules and rules modeled on Php Inspections (EA Extended); independent clean-room implementation.