rtCamp / action-phpcs-code-review

Github Action to perform automated code review on pull requests
https://github.com/rtCamp/github-actions-library
MIT License
101 stars 26 forks source link

How to autoload committed files if custom xml is presented? #25

Open MDaskalovAtBE opened 4 years ago

MDaskalovAtBE commented 4 years ago

How to make my own xml file that when picked it will resolve the committed files auto and there will be no need of <file>/path/to/file/</file> foreach file that has been changed?

In my .xml I have

<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
    <description>The coding standard for PHP_CodeSniffer itself.</description>

    <arg name="basepath" value="."/>
    <arg name="colors"/>

    <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
    <rule ref="Generic.Commenting.Todo"/>
    <rule ref="Generic.ControlStructures.DisallowYodaConditions"/>
    <rule ref="Generic.ControlStructures.InlineControlStructure"/>
    <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
    <rule ref="Generic.Formatting.SpaceAfterCast"/>
    <rule ref="Generic.NamingConventions.ConstructorName"/>
    <rule ref="Generic.PHP.DeprecatedFunctions"/>
    <rule ref="Generic.PHP.LowerCaseKeyword"/>
    <rule ref="Generic.Strings.UnnecessaryStringConcat"/>
    <rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
    <rule ref="PSR2.Classes.PropertyDeclaration"/>
    <rule ref="PSR2.Methods.MethodDeclaration"/>
    <rule ref="PSR2.Files.EndFileNewline"/>
    <rule ref="PSR12.Files.OpenTag"/>
    <rule ref="Zend.Files.ClosingTag"/>

    <!-- We use custom indent rules for arrays -->
    <rule ref="Generic.Arrays.ArrayIndent"/>
    <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
        <severity>0</severity>
    </rule>
    <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
        <severity>0</severity>
    </rule>
    <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
        <severity>0</severity>
    </rule>
    <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine">
        <severity>0</severity>
    </rule>

    <!-- Have 12 chars padding maximum and always show as errors -->
    <rule ref="Generic.Formatting.MultipleStatementAlignment">
        <properties>
            <property name="maxPadding" value="12"/>
            <property name="error" value="true"/>
        </properties>
    </rule>

    <!-- Private methods MUST not be prefixed with an underscore -->
    <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
        <type>error</type>
    </rule>

    <!-- Private properties MUST not be prefixed with an underscore -->
    <rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
        <type>error</type>
    </rule>

    <!-- The testing bootstrap file uses string concats to stop IDEs seeing the class aliases -->
    <rule ref="Generic.Strings.UnnecessaryStringConcat"/>

</ruleset>

When I committed this file

<?php

$something = array(
    'asd' => 'asd',
    'asdss'   => 'sss'
);

echo $something;

I was expecting it will fail, but it returned green, if I use the default PSR2 as arg in the .yml and remove the xml the file fails as it should.

Thanks.