Code Monkey home page Code Monkey logo

coveragechecker's Issues

Class 'PhpParser\ParserFactory' not found

Full error:

PHP Fatal error:  Class 'PhpParser\ParserFactory' not found in .../vendor/exussum12/coverage-checker/src/FileParser.php on line 21
PHP Stack trace:
PHP   1. {main}() .../vendor/exussum12/coverage-checker/bin/diffFilter:0
PHP   2. require() .../vendor/exussum12/coverage-checker/bin/diffFilter:3
PHP   3. exussum12\CoverageChecker\CoverageCheck->getCoveredLines() .../vendor/exussum12/coverage-checker/src/Runners/generic.php:76
PHP   4. exussum12\CoverageChecker\PhpCsLoader->parseLines() .../vendor/exussum12/coverage-checker/src/CoverageCheck.php:72
PHP   5. exussum12\CoverageChecker\PhpCsLoader->addInvalidLine() .../vendor/exussum12/coverage-checker/src/PhpCsLoader.php:87
PHP   6. exussum12\CoverageChecker\PhpCsLoader->handleLookupError() .../vendor/exussum12/coverage-checker/src/PhpCsLoader.php:130
PHP   7. exussum12\CoverageChecker\PhpCsLoader->getFileParser() .../vendor/exussum12/coverage-checker/src/PhpCsLoader.php:166
PHP   8. exussum12\CoverageChecker\FileParser->__construct() .../vendor/exussum12/coverage-checker/src/PhpCsLoader.php:184

I've found #33 which says the issue has been fixed in 0.9.0, but I'm running 0.11.0.

Here's the script I'm running locally (PHP 5.6.39: yes, I know):

CI_MERGE_REQUEST_TARGET_BRANCH_NAME=develop
FILES=$(git diff --name-only --diff-filter=ACMR HEAD origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} -- '*.php' '*.inc')
FILES=${FILES//$'\n'/ }

[[ -z "$FILES" ]] && { echo "Nothing to check": exit 0; }

echo "Checking ${FILES}"
echo "${FILES}" > ./files.txt

echo "Running checks..."
./vendor/bin/phpcs --standard=./phpcs.xml --report=json --file-list=files.txt > ./phpcs.json
echo "Parsing results..."

./vendor/bin/diffFilter --phpcs files.txt ./phpcs.json 100

Notice that I'm not using ./vendor/bin/phpcs --standard=./phpcs.xml --report=json --file-list=./files.txt || true > ./phpcs.json because that generates an empty phpcs.json.

CI_MERGE_REQUEST_TARGET_BRANCH_NAME exists to make it easy for me to port the script in the CI.

With this script, I can see that both files.txt and phpcs.json are properly generated:

  • files.txt contains the only PHP file changed from the source branch
  • phpcs.json contains a good number data (not included here to not pollute the issue, but I can do it if that's needed) which is expected, as I intentionally used a file with a lot of legacy code, but made a one-line change.

I've spent a good time trying to figure out what the issue could be, but I couldn't.

Out of curiosity, I've tried the script in GitLab-CI, which runs on PHP 7.3.2:

- composer install
- FILES=$(git diff --name-only --diff-filter=ACMR HEAD origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} -- '*.php' '*.inc')
- FILES=${FILES//$'\n'/ }
- '[[ -z "$FILES" ]] && { echo "Nothing to check": exit 0; }'
- echo "Checking ${FILES}"
- echo "${FILES}" > ./files.txt
- cat ./files.txt
- echo "Running checks..."
- ./vendor/bin/phpcs --standard=./phpcs.xml --report=json --file-list=./files.txt || true > ./phpcs.json
- cat ./phpcs.json
- echo "Parsing results..."
- ./vendor/bin/diffFilter --phpcs files.txt ./phpcs.json 100

Again, both files are properly generated, but on ./vendor/bin/diffFilter --phpcs files.txt ./phpcs.json 100 I get this generic error: Can't Parse phpcs json - Syntax error.

Full output:

$ FILES=$(git diff --name-only --diff-filter=ACMR HEAD origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} -- '*.php' '*.inc')
$ FILES=${FILES//$'\n'/ }
$ [[ -z "$FILES" ]] && { echo "Nothing to check": exit 0; }
$ echo "Checking ${FILES}"
Checking sitepress.php
$ echo "${FILES}" > ./files.txt
$ cat ./files.txt
sitepress.php
$ echo "Running checks..."
Running checks...
$ ./vendor/bin/phpcs --standard=./phpcs.xml --report=json --file-list=./files.txt || true > ./phpcs.json
{"totals":{"errors":39,"warnings":7,"fixable":12},"files":{"\/builds\/wpml\/sitepress-multilingual-cms\/sitepress.php":{"errors":39,"warnings":7,"messages":[{"message":"You must use \"\/**\" style comments for a file comment","source":"Squiz.Commenting.FileComment.WrongStyle","severity":5,"fixable":false,"type":"ERROR","line":2,"column":1},{"message":"Empty line required before block comment","source":"Squiz.Commenting.BlockComment.NoEmptyLineBefore","severity":5,"fixable":false,"type":"ERROR","line":2,"column":1},{"message":"No space found before comment text; expected \"\/\/ define('ICL_SITEPRESS_DEV_VERSION', '3.4-dev');\" but found \"\/\/define('ICL_SITEPRESS_DEV_VERSION', '3.4-dev');\"","source":"Squiz.Commenting.InlineComment.NoSpaceBefore","severity":5,"fixable":true,"type":"ERROR","line":25,"column":1},{"message":"Inline comments must end in full-stops, exclamation marks, or question marks","source":"Squiz.Commenting.InlineComment.InvalidEndChar","severity":5,"fixable":false,"type":"ERROR","line":25,"column":1},{"message":"Missing short description in doc comment","source":"Generic.Commenting.DocComment.MissingShort","severity":5,"fixable":false,"type":"ERROR","line":31,"column":1},{"message":"Missing short description in doc comment","source":"Generic.Commenting.DocComment.MissingShort","severity":5,"fixable":false,"type":"ERROR","line":33,"column":1},{"message":"Missing short description in doc comment","source":"Generic.Commenting.DocComment.MissingShort","severity":5,"fixable":false,"type":"ERROR","line":35,"column":1},{"message":"Missing short description in doc comment","source":"Generic.Commenting.DocComment.MissingShort","severity":5,"fixable":false,"type":"ERROR","line":37,"column":1},{"message":"No space found before comment text; expected \"\/\/ PHP 5.2 backward compatibility\" but found \"\/\/PHP 5.2 backward compatibility\"","source":"Squiz.Commenting.InlineComment.NoSpaceBefore","severity":5,"fixable":true,"type":"ERROR","line":40,"column":1},{"message":"Inline comments must end in full-stops, exclamation marks, or question marks","source":"Squiz.Commenting.InlineComment.InvalidEndChar","severity":5,"fixable":false,"type":"ERROR","line":40,"column":1},{"message":"Variable \"WPML_Dependencies\" is not in valid snake_case format","source":"WordPress.NamingConventions.ValidVariableName.NotSnakeCase","severity":5,"fixable":false,"type":"ERROR","line":54,"column":1},{"message":"\"require_once\" is a statement not a function; no parentheses are required","source":"PEAR.Files.IncludingFile.BracketsNotRequired","severity":5,"fixable":true,"type":"WARNING","line":97,"column":1},{"message":"Inline comments must end in full-stops, exclamation marks, or question marks","source":"Squiz.Commenting.InlineComment.InvalidEndChar","severity":5,"fixable":false,"type":"ERROR","line":120,"column":1},{"message":"No space found before comment text; expected \"\/\/ Set cron job to update WPML config index file from CDN\" but found \"\/\/Set cron job to update WPML config index file from CDN\"","source":"Squiz.Commenting.InlineComment.NoSpaceBefore","severity":5,"fixable":true,"type":"ERROR","line":147,"column":5},{"message":"Inline comments must end in full-stops, exclamation marks, or question marks","source":"Squiz.Commenting.InlineComment.InvalidEndChar","severity":5,"fixable":false,"type":"ERROR","line":147,"column":5},{"message":"Missing short description in doc comment","source":"Generic.Commenting.DocComment.MissingShort","severity":5,"fixable":false,"type":"ERROR","line":150,"column":1},{"message":"Missing short description in doc comment","source":"Generic.Commenting.DocComment.MissingShort","severity":5,"fixable":false,"type":"ERROR","line":151,"column":1},{"message":"Missing short description in doc comment","source":"Generic.Commenting.DocComment.MissingShort","severity":5,"fixable":false,"type":"ERROR","line":239,"column":1},{"message":"Missing short description in doc comment","source":"Generic.Commenting.DocComment.MissingShort","severity":5,"fixable":false,"type":"ERROR","line":246,"column":1},{"message":"Missing short description in doc comment","source":"Generic.Commenting.DocComment.MissingShort","severity":5,"fixable":false,"type":"ERROR","line":268,"column":5},{"message":"Found precision alignment of 3 spaces.","source":"WordPress.WhiteSpace.PrecisionAlignment.Found","severity":5,"fixable":false,"type":"WARNING","line":275,"column":1},{"message":"Tabs must be used to indent lines; spaces are not allowed","source":"Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed","severity":5,"fixable":true,"type":"ERROR","line":275,"column":1},{"message":"Inline comments must end in full-stops, exclamation marks, or question marks","source":"Squiz.Commenting.InlineComment.InvalidEndChar","severity":5,"fixable":false,"type":"ERROR","line":279,"column":1},{"message":"Variable \"WPML_Users_Languages_Dependencies\" is not in valid snake_case format","source":"WordPress.NamingConventions.ValidVariableName.NotSnakeCase","severity":5,"fixable":false,"type":"ERROR","line":284,"column":1},{"message":"Missing doc comment for function wpml_init_language_switcher()","source":"Squiz.Commenting.FunctionComment.Missing","severity":5,"fixable":false,"type":"ERROR","line":286,"column":1},{"message":"Missing doc comment for function wpml_mlo_init()","source":"Squiz.Commenting.FunctionComment.Missing","severity":5,"fixable":false,"type":"ERROR","line":293,"column":1},{"message":"Missing short description in doc comment","source":"Generic.Commenting.DocComment.MissingShort","severity":5,"fixable":false,"type":"ERROR","line":301,"column":1},{"message":"Missing parameter comment","source":"Squiz.Commenting.FunctionComment.MissingParamComment","severity":5,"fixable":false,"type":"ERROR","line":302,"column":4},{"message":"There must be exactly one blank line before the tags in a doc comment","source":"Generic.Commenting.DocComment.SpacingBeforeTags","severity":5,"fixable":true,"type":"ERROR","line":311,"column":8},{"message":"Found precision alignment of 1 spaces.","source":"WordPress.WhiteSpace.PrecisionAlignment.Found","severity":5,"fixable":false,"type":"WARNING","line":314,"column":1},{"message":"Tabs must be used to indent lines; spaces are not allowed","source":"Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed","severity":5,"fixable":true,"type":"ERROR","line":314,"column":1},{"message":"Found precision alignment of 1 spaces.","source":"WordPress.WhiteSpace.PrecisionAlignment.Found","severity":5,"fixable":false,"type":"WARNING","line":315,"column":1},{"message":"Tabs must be used to indent lines; spaces are not allowed","source":"Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed","severity":5,"fixable":true,"type":"ERROR","line":315,"column":1},{"message":"No space before closing parenthesis is prohibited","source":"WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis","severity":5,"fixable":true,"type":"ERROR","line":315,"column":67},{"message":"Missing doc comment for function wpml_integrations_requirements()","source":"Squiz.Commenting.FunctionComment.Missing","severity":5,"fixable":false,"type":"ERROR","line":334,"column":1},{"message":"Missing doc comment for function wpml_troubleshoot_action_load()","source":"Squiz.Commenting.FunctionComment.Missing","severity":5,"fixable":false,"type":"ERROR","line":341,"column":1},{"message":"Missing doc comment for function wpml_init_language_cookie_settings()","source":"Squiz.Commenting.FunctionComment.Missing","severity":5,"fixable":false,"type":"ERROR","line":352,"column":1},{"message":"Found precision alignment of 1 spaces.","source":"WordPress.WhiteSpace.PrecisionAlignment.Found","severity":5,"fixable":false,"type":"WARNING","line":358,"column":1},{"message":"Tabs must be used to indent lines; spaces are not allowed","source":"Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed","severity":5,"fixable":true,"type":"ERROR","line":358,"column":1},{"message":"Found precision alignment of 2 spaces.","source":"WordPress.WhiteSpace.PrecisionAlignment.Found","severity":5,"fixable":false,"type":"WARNING","line":359,"column":1},{"message":"Tabs must be used to indent lines; spaces are not allowed","source":"Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed","severity":5,"fixable":true,"type":"ERROR","line":359,"column":1},{"message":"Missing doc comment for function wpml_check_php_version()","source":"Squiz.Commenting.FunctionComment.Missing","severity":5,"fixable":false,"type":"ERROR","line":377,"column":1},{"message":"Comma not allowed after last value in single-line array declaration","source":"WordPress.Arrays.CommaAfterArrayItem.CommaAfterLast","severity":5,"fixable":true,"type":"ERROR","line":383,"column":52},{"message":"Missing doc comment for function wpml_core_loads_first()","source":"Squiz.Commenting.FunctionComment.Missing","severity":5,"fixable":false,"type":"ERROR","line":389,"column":1},{"message":"Variable assignment found within a condition. Did you mean to do a comparison?","source":"WordPress.CodeAnalysis.AssignmentInCondition.Found","severity":5,"fixable":false,"type":"WARNING","line":392,"column":27},{"message":"Assignments must be the first block of code on a line","source":"Squiz.PHP.DisallowMultipleAssignments.Found","severity":5,"fixable":false,"type":"ERROR","line":392,"column":27}]}}}$ cat ./phpcs.json
$ echo "Parsing results..."
Parsing results...
$ ./vendor/bin/diffFilter --phpcs files.txt ./phpcs.json 100
Can't Parse phpcs json - Syntax error
Job succeeded

I hope this is enough data to help me figure out what's wrong here.

git merge-base is missing an argument

In the documentation, the recommended approach for building a diff file is to use git diff $(git merge-base origin/master...HEAD).

However, git merge-base origin/master...HEAD is missing an argument and always displays a usage helper.

I'm not familiar with git merge-base and I couldn't figure how to make it right.

Like in the example, I'm trying to do build the diff file so that it works both locally and in the CI.

In the CI, I will replace master with the actual target branch (from a GitLab environment variable called CI_MERGE_REQUEST_TARGET_BRANCH_NAME).

Any advice?

Release a new version to address PHP 7.4 issue

Hi πŸ‘‹,

We're seeing this error with ver 0.11.2 with PHP 8.0, which was released on 2019-04-17 (also the latest version for now).

PHP Fatal error: Array and string offset access syntax with curly braces is no longer supported in /home/runner/work/Edit-Flow/Edit-Flow/vendor/exussum12/coverage-checker/src/ArgParser.php on line 25

Our test is here https://github.com/Automattic/Edit-Flow/runs/2407816247?check_suite_focus=true

I see that this error was fixed on b5c7b7f

But there is no release for it. Could you consider releasing it?

Thanks in advance.

`diffFilter` outputs in incorrect format if there are no changes

When I call diffFilter on an empty change set, it logs a "No lines found!" error but returns a 0 success code.

For example:

diffFilter --phpcsStrict < (git diff HEAD...HEAD)  phpcs.json --report=phpcs 0

outputs an empty string, instead of a JSON object.

In my scripting, when a command returns success code, I assume it produced the output in expected format as it does for any successful input and run.
If the command encounters an error, making it unable to proceed to produce meaningful output, it should return error code, so I could catch that and act accordingly.

But, the line

error_log('No lines found!');
return;

logs an error, does not produce any output, and returns "successfully".
IMHO, it should either

  • log a successful JSON response - if there are no lines, there are no phpCS errors as well. #73
  • return error code - if it's unable to produce a meaningful, compliant result, if it got invalid arguments, it should fail in an observable manner. #74

Would it be possible to get a PHAR?

Hey Scott. Looks exactly like a tool I was looking for for some time. But: I'd rather use it as phar-file so that it doesn't break my dependencies when running composer install.

Would it be possible to get one?

I'd be happy to provide ideas on how to automate that ;)

compatibility with phpunit ^9.*

Hello,

my team and I have used this package to check uncovered classes. Now with phpunit 9, it isn't correctly anymore.
Can we expect a future update?

diffFilter reporting incorrect errors for lines

We have the coverage checker setup in a pre-commit hook. phpcs.json gets created only for changed files:

relevant part of `pre-commit`
define('GIT_ROOT', trim(shell_exec('git rev-parse --show-toplevel')));
define('PHPCS_BIN', sprintf('%1$s%2$svendor%2$sbin%2$sphpcs', GIT_ROOT, DIRECTORY_SEPARATOR));
define('PHPCBF_BIN', sprintf('%1$s%2$svendor%2$sbin%2$sphpcbf', GIT_ROOT, DIRECTORY_SEPARATOR));

// check if there are files to commit.
$files = [];
exec(sprintf('git diff --diff-filter=d --cached --name-only -- "*.php" ":(exclude)vendor%s*"', DIRECTORY_SEPARATOR), $files);
if (empty($files)) {
    exit();
}

echo 'Generating Diff...' . Colors::color('OK', 'green') . "\n";
shell_exec(sprintf('git diff --diff-filter=d --cached -- "*.php" ":(exclude)vendor%s*" > .phpcs-diff.txt', DIRECTORY_SEPARATOR));

echo 'Running PHP_CodeSniffer...';
// phpcs:ignore Generic.Files.LineLength.TooLong
$p    = popen(PHPCS_BIN . ' --cache  -pv --report=json --report-file=".phpcs.json" ' . implode(
        ' ',
        $files
    ) . ' || true', 'rb');
$last = microtime(true);
while (!feof($p)) {
    fgets($p);
    if ($last + .750 < microtime(true)) {
        echo '.';
        $last = microtime(true);
    }
}
flush();
pclose($p);
echo Colors::color('OK', 'green') . "\n";

echo 'Comparing Diffs...';
$diff = [];
exec(sprintf('vendor%1$sbin%1$sdiffFilter --phpcs .phpcs-diff.txt .phpcs.json 100', DIRECTORY_SEPARATOR), $diff);

$phpcs_errors = (empty($diff) || '100.00% Covered' === $diff[0]) ? 0 : 1;
if (0 !== $phpcs_errors) {
    echo Colors::color('failed', 'red') . "\n\n";
    echo Colors::color('Please fix these errors before committing:', 'black', 'red') . "\n\n";
    echo implode("\n", $diff);
} else {
    echo Colors::color('OK', 'green');
}
echo "\n";

exit($phpcs_errors);
part of diff
diff --git a/admin/admin.php b/admin/admin.php
index 936c67c..51e0ec3 100755
--- a/admin/admin.php
+++ b/admin/admin.php
@@ -724,8 +724,8 @@ class Advanced_Ads_Tracking_Admin {
             'advanced_ads_tracking_setting_section'
         );
 
-		if ($this->show_stats()) {
-			// open database management field
+		if ( $this->show_stats() ) {
+			// open database management field.
 			add_settings_field(
 				'tracking-db-mgmt',
 				__( 'Database Management', 'advanced-ads-tracking' ),
@@ -734,7 +734,7 @@ class Advanced_Ads_Tracking_Admin {
 				$advanced_section
 			);
 
-			// timeout for impressions sum transient
+			// timeout for impressions sum transient.
 			add_settings_field(
 				'sum-timeout',
 				__( 'Recalculate sums', 'advanced-ads-tracking' ),
@@ -742,6 +742,15 @@ class Advanced_Ads_Tracking_Admin {
 				$hook,
 				$advanced_section
 			);
+
+			// tracking for bots.
+			add_settings_field(
+				'tracking-bots',
+				__( 'Track bots', 'advanced-ads-tracking' ),
+				array( $this, 'render_settings_track_bots' ),
+				$hook,
+				$advanced_section
+			);
 		}
 
         // link base for public stats
@@ -753,15 +762,6 @@ class Advanced_Ads_Tracking_Admin {
             'advanced_ads_tracking_setting_section'
         );
 
-        // tracking for bots
-        add_settings_field(
-            'tracking-bots',
-            __( 'Track bots', 'advanced-ads-tracking' ),
-            array( $this, 'render_settings_track_bots' ),
-            $hook,
-            $advanced_section
-        );
Extract of `phpcs.json`
{
  "totals": {
    "errors": 2972,
    "warnings": 514,
    "fixable": 2857
  },
  "files": {
    "...\/admin\/admin.php": {
      "errors": 2149,
      "warnings": 198,
      "messages": [
        // more errors
        {
          "message": "Parameter comment must end with a full stop",
          "source": "Squiz.Commenting.FunctionComment.ParamCommentFullStop",
          "severity": 5,
          "fixable": false,
          "type": "ERROR",
          "line": 624,
          "column": 8
        },
        {
          "message": "Tabs must be used to indent lines; spaces are not allowed",
          "source": "Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed",
          "severity": 5,
          "fixable": true,
          "type": "ERROR",
          "line": 625,
          "column": 1
        },
        // more errors
        {
          "message": "Missing space before array closer.",
          "source": "WordPress.Arrays.ArrayDeclarationSpacing.NoSpaceBeforeArrayCloser",
          "severity": 5,
          "fixable": true,
          "type": "ERROR",
          "line": 722,
          "column": 66
        },
        {
          "message": "Tabs must be used to indent lines; spaces are not allowed",
          "source": "Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed",
          "severity": 5,
          "fixable": true,
          "type": "ERROR",
          "line": 723,
          "column": 1
        },
        {
          "message": "Tabs must be used to indent lines; spaces are not allowed",
          "source": "Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed",
          "severity": 5,
          "fixable": true,
          "type": "ERROR",
          "line": 724,
          "column": 1
        },
        {
          "message": "Tabs must be used to indent lines; spaces are not allowed",
          "source": "Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed",
          "severity": 5,
          "fixable": true,
          "type": "ERROR",
          "line": 725,
          "column": 1
        },
        {
          "message": "Tabs must be used to indent lines; spaces are not allowed",
          "source": "Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed",
          "severity": 5,
          "fixable": true,
          "type": "ERROR",
          "line": 756,
          "column": 1
        },
        {
          "message": "Tabs must be used to indent lines; spaces are not allowed",
          "source": "Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed",
          "severity": 5,
          "fixable": true,
          "type": "ERROR",
          "line": 757,
          "column": 1
        },
        {
          "message": "Tabs must be used to indent lines; spaces are not allowed",
          "source": "Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed",
          "severity": 5,
          "fixable": true,
          "type": "ERROR",
          "line": 758,
          "column": 1
        },
        {
          "message": "Tabs must be used to indent lines; spaces are not allowed",
          "source": "Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed",
          "severity": 5,
          "fixable": true,
          "type": "ERROR",
          "line": 759,
          "column": 1
        },
        {
          "message": "Tabs must be used to indent lines; spaces are not allowed",
          "source": "Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed",
          "severity": 5,
          "fixable": true,
          "type": "ERROR",
          "line": 760,
          "column": 1
        },
        // more errors
      ]
}

This is the output:
image

It seems that the diff hangs on some errors and keeps on reporting that error for multiple changed lines, even though these changed lines don't have an error and specifically not that error.

I'm looking forward to any hints on why this is happening and how to prevent it.

0 flag and pass fail status.

So I tested this a bit more and this is what I found.

If you use a 0 on the command line to not trigger the failure you get an output of status 'Passed' even though there were violations found. See output below:

stdClass Object
(
    [coverage] => 20.00
    [status] => Passed
    [violations] => stdClass Object
        (
            [app/Http/Controllers/CountyController.php] => Array
                (
                    [0] => stdClass Object
                        (
                            [lineNumber] => 27
                            [message] => Array
                                (
                                    [0] => Expected 1 space between comma and argument "$state"; 0 found
                                )

                        )

                )

            [app/Http/Controllers/PaymentController.php] => Array
                (
                    [0] => stdClass Object
                        (
                            [lineNumber] => 31
                            [message] => Array
                                (
                                    [0] => Expected 1 space after comma in function call; 2 found
                                )

                        )

                )

        )

)

When I don't use the 0, and using the --report=json flag, I get:

**Failing due to coverage being lower than threshold**
stdClass Object
(
    [coverage] => 20.00
    [status] => Failed
    [violations] => stdClass Object
        (
            [app/Http/Controllers/CountyController.php] => Array
                (
                    [0] => stdClass Object
                        (
                            [lineNumber] => 27
                            [message] => Array
                                (
                                    [0] => Expected 1 space between comma and argument "$state"; 0 found
                                )

                        )

                )

            [app/Http/Controllers/PaymentController.php] => Array
                (
                    [0] => stdClass Object
                        (
                            [lineNumber] => 31
                            [message] => Array
                                (
                                    [0] => Expected 1 space after comma in function call; 2 found
                                )

                        )

                )

        )

)

notice the output at the top 'Failing due to coverage being lower than threshold' shows up. Ideally it would be nice if one can still pass 0 on the command line. And get similar pass/fail status so that you don't have to worry about the 'Failing due to coverage being lower than threshold' message. What do you think?

File path issue when using on windows

Context: using on windows, phpcs.
phpcs.json will contain file paths in "windows like" path separators, for example

(...)
"files":{
    "D:\\wamp\\www\\project\\application\\views\\backend\\report.php":{
         "errors":6 
(...)

The git diff.txt will contain file paths in "unix like" path separators, for example

(...)
diff --git a/application/views/backend/report.php b/application/views/backend/report.php
index 747f7bd89..626aaf004 100644
--- a/application/views/backend/report.php
+++ b/application/views/backend/report.php
(...)

Issue
The EndsWith FileMatcher will try to match haystack D:\wamp\www\project\application\views\backend\report.php, needle: application/views/backend/report.php (notice the inverse slashes) and won't find a match, thus giving falsy 100% covered answers (finding no modified files with issues).

Do you have any trivial solution?
If no trivial workaround then will try to fix it and PR it.
Thanks

PHAR has issues with path

When I download the PHAR-file and rename it from diffFilter.phar to something else like diffFilter (note the missing .phar) I am not able to use it any more due to the following error:

    PHP Warning:  require(phar://diffFilter.phar/src/Runners/generic.php): failed to open stream: phar error: invalid url or non-existent phar "phar://diffFilter.phar/src/Runners/generic.php" in /path/to/diffFilter on line 3
PHP Stack trace:
PHP   1. {main}() /path/to/diffFilter:0

Warning: require(phar://diffFilter.phar/src/Runners/generic.php): failed to open stream: phar error: invalid url or non-existent phar "phar://diffFilter.phar/src/Runners/generic.php" in /path/to/diffFilter on line 3

Call Stack:
    0.0014     394744   1. {main}() /path/to/diffFilter:0

PHP Fatal error:  require(): Failed opening required 'phar://diffFilter.phar/src/Runners/generic.php' (include_path='.:/usr/local/Cellar/php/7.2.3_2/share/pear') in /path/to/diffFilter on line 3
PHP Stack trace:
PHP   1. {main}() /path/to/diffFilter:0

Fatal error: require(): Failed opening required 'phar://diffFilter.phar/src/Runners/generic.php' (include_path='.:/usr/local/Cellar/php/7.2.3_2/share/pear') in /path/to/diffFilter on line 3

Call Stack:
    0.0014     394744   1. {main}() /path/to/diffFilter:0

Renaming the file back to diffFilter.phar causes the error to disappear.

Why is that an issue? I'm usually installing such PHARs without the .phar-extension and call them like any unix-tool…

Removing a phpdoc will not checked by the diffFilter

I have an issue, I tested this scenario where we remove a php comment docs. But that doc is needed for phpcs to check.
But what happen it went out it passed the checker.

diff.text

diff --git a/<path>/country_controller.php b/<path>/country_controller.php
index 0965de3e93..73afffd042 100644
--- a/<path>/country_controller.php
+++ b/<path>/country_controller.php
@@ -1,13 +1,4 @@
 <?php
-/**
- * Controller to retrieve information about a country
- *
- * PHP version 5
- *
- * @author    Sample Author <[email protected]>
- * @copyright Sample Copyright
- */
 namespace <namespace>;
 
 class Country_Controller extends Base_Controller {

phpcs.json

{
  "totals": {
    "errors": 3,
    "warnings": 0
  },
  "files": {
     "<path>\/country_controller.php": {
      "errors": 1,
      "warnings": 0,
      "messages": [
        {
          "message": "Missing file doc comment",
          "source": "CSNStores.Commenting.FileComment.Missing",
          "severity": 5,
          "type": "ERROR",
          "line": 2,
          "column": 1
        }
      ]
    }
  }
}

the output of the difffilter will be

php ./.ci/diffFilter.phar --phpcsStrict diff.txt phpcs.json
    100.00% Covered

The expected for this, it should have an error.

Fix generic errors

When using phpcs, a whole file error shows as "no coverage" (the generic message)

This ideally should show why it really failed.

This would also be useful for the range based errors rather than putting 1 per line, we could use the range in memory and just save it once.

No current .phar version

The readme says "The latest Phar can be found Here."

But recent releases only contain zipped source code.

Tiny issue I know, but I'm eager to bundle the phar into a dockerfile. Thanks!

Slightly confused about coverage related messages

Hello,

first and foremost thank you for your work. This is highly useful.

Slightly confused about the coverage related messages as part of the output. For example I am using the phpcs example and on certain files I get '0.00% Covered, Missed lines'. Is that related only to the phpunit coverage or is that somehow related to the PHPCS functionality ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.