Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Change exit code if no files were scanned #147

Closed
DanielSchwiperich opened this issue May 12, 2017 · 6 comments
Closed

Change exit code if no files were scanned #147

DanielSchwiperich opened this issue May 12, 2017 · 6 comments
Assignees

Comments

@DanielSchwiperich
Copy link

phpcpd is giving an exit code of 1 if no files were found to scan.

This is different behaviour to similar tools like phpcs and phpmd.
It would be nice to have that behaviour changed so that's in line with those other tools.
(Useful in CI for example where the return values are evaluated and used to make a stage fail)

@renanmpimentel
Copy link

@DanielSchwiperich use:

phpcpd /path || echo 0

¯_(ツ)_/¯

@DanielSchwiperich
Copy link
Author

This will always return 0, also when files are scanned and errors / warnings are found.
So not helpful but thx

(Useful in CI for example where the return values are evaluated and used to make a stage fail)

@mvscheidt
Copy link

mvscheidt commented Aug 28, 2017

as @DanielSchwiperich said - the workaround as proposed in #147 (comment) would work differently than what he wants

He wants the command to exit with code 0 (success) if either of these two apply

  • there are no files to scan
  • there are no clones in the scanned files

Of course the command should fail (as it already does) when clones have been found.


Currently the phpcd command has two exit() statements which both return 1

Because both return code 1 you cannot separate the two - maybe if you log and parse the output to the console and check for No files found to scan additionally but that sounds rather dirty and convoluted.


IMO either exit with code 0 in case no files are found OR change the error code to 2 (or whatever number would be suitable - I am no expert on exit codes and the best practices).

On the other hand changing this behaviour seems to be a BC-Break to me because some people might actually expect "no files found" to return an error code - not sure what the stance of @sebastianbergmann on this is.

@mautz-et-tong
Copy link

Happens again in 6.0.3:
https://github.com/sebastianbergmann/phpcpd/blob/master/src/CLI/Application.php#L62

exit code is 1 when no files are found to scan.

If error code should be 0 as this was a bug in 2017, I can provide a PR.

@lukewhitmore
Copy link

I can confirm the same behaviour in 6.0.3.

@jklmnop
Copy link

jklmnop commented Jul 28, 2021

i'm experiencing the same thing with 6.0.3

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants