Running Custom Checks

Scrutinizer allows you to run custom analysis commands on each inspection. Each command can

  • add comments/warnings to files
  • suggest patches for files; for example to auto-fix styling issues
  • collect metrics

Configuration

To run your custom checks, you can simply configure your command as follows:

build:
    tests:
        override:
            -
                command:  check.sh # your custom check script.
                analysis:
                    file:   # The output filename
                    format: 'general-checkstyle'     # The supported format by Scrutinizer

If you have custom output file in your command, you need to specify the file path in the file option. Otherwise you can also ignore file option, in this case, the result is expected to be sent to STDOUT, and we will take the output from STDOUT as result.

Output

The output of the command is expected to be checkstyle xml file with the following structure:

<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="1.0.0">
    <file name="/path/to/code/myfile.php">
        <error line="2"  message="msg1" source="Ruleset.RuleName"/>
        <error line="20"  message="msg2" source="Generic.Constant"/>
        <error line="47"  message="msg3" source="ScopeIndent"/>
        <error line="47" message="msg4" source="Format.MultipleAlignment"/>
        <error line="51" message="msg5" source="Comment.FunctionComment"/>
    </file>
</checkstyle>

the source attribute can be formatted as Ruleset.RuleName or simply RuleName

Installing Dependencies

If your custom command requires some set-up before it can perform its checks, you can either let it do this set-up itself, or move these commands to the dependencies section. The latter is generally preferable:

build:
    dependencies:
        before:
            -
                command: npm install /plugin

    tests:
        override:
            -
                command: check.sh