mnapoli / pretty Goto Github PK
View Code? Open in Web Editor NEW✨ CLI command with sane defaults to simplify CodeSniffer and PHP-CS-Fixer
Home Page: https://prettyci.com
License: MIT License
✨ CLI command with sane defaults to simplify CodeSniffer and PHP-CS-Fixer
Home Page: https://prettyci.com
License: MIT License
Pretty runs tools installed globally.
It would be great if it worked with tools (phpcs/php-cs-fixer) installed locally in the project, in the vendor/
directory.
Due to an undisclosed need, i had to run pretty on Windows.
When running pretty i got:
ERROR: PHP CodeSniffer does not seem to be installed because the 'phpcs' program cannot be found.
It was strange because i had phpcs installed and i could run it just fine. After looking trough this code i noticed that the error message comes from:
function commandExists($command)
{
$return = shell_exec('which ' . escapeshellarg($command));
return !empty($return);
}
which cannot be installed on Windows, so i just changed the above code to
function commandExists($command)
{
return true;
}
And poof everthing started working just fine :)
Hope this will help somebody else.
Just in case you'd like to use something else than default and not reinvent the wheel :)
https://github.com/Symplify/EasyCodingStandard#the-easiest-way-to-use-any-coding-standard
> pretty fix
PHP CodeSniffer configuration file found, running CodeSniffer with version
ERROR: PHP CodeSniffer does not seem to be installed because the 'phpcbf' program cannot be found.
You can install it by following the instructions here: https://github.com/squizlabs/PHP_CodeSniffer#installation
> composer global require "squizlabs/php_codesniffer=*"
(successfully installed)
> pretty fix
PHP CodeSniffer configuration file found, running CodeSniffer with version
PHP_CodeSniffer version 3.4.2 (stable) by Squiz (http://www.squiz.net)
ERROR: Referenced sniff "Doctrine" does not exist
Run "phpcbf --help" for usage information
Errors were found, run 'pretty fix' to fix them.
I have to somehow figure out that I must run composer global require doctrine/coding-standard
. (Or maybe there is another way?)
We are now a long way from php-fixer fix
which was something I liked with pretty ci
.
Anyhow, I maybe should have opened this issue on Bref. I just wanted to share some frustration.
I get this error when running pretty
:
No configuration file found, running PHP CodeSniffer with PSR-2
I have a .phpcs.xml
file in the project and I have also tried renaming it to .phpcs.xml.dist
but I get the same result and it defaults to PSR-2. When I execute phpcs using vendor/bin/phpcs .
it runs fine.
Is there something else I am missing?
→ pretty fix
PHP-CS-Fixer configuration file found, running PHP-CS-Fixer with version
PHP CS Fixer version 0.3-DEV by Fabien Potencier
[RuntimeException]
The "--allow-risky" option does not exist.
fix [--config="..."] [--dry-run] [--level="..."] [--fixers="..."] [--diff] [--format="..."] path
Errors were found, run 'pretty fix' to fix them.
When using Symfony rules the local will add the slash \array_key_exist but the CI want that you remove it. It seems like the CI is using an older version of the php-cs-fixer.
Don't know about phpcs, but cs-fixer will automatically create the cache file, if none exists, unless run with a --using-cache
. If someone switches from one fixer to the other; files like this would become mess...
PHP_CodeSniffer currently doesn't support autodetection of whether STDOUT is a TTY, so projects (e.g. doctrine/dbal) specify colors
in their configuration for developer’ convenience. If PHP_CodeSniffer with such settings runs on Travis, it’s fine because interprets ANSI output.
At the same time, it doesn't seem to be the case for GitHub Checks. So the colored output is displayed as control characters (example).
Would it make sense to force --no-colors
in the phpcs
command line arguments? It seems to suppress the color
argument from the XML configuration.
PrettyCI is returning errors from PHPCS when running PHPCS locally with the same .phpcs.xml
file reports no errors so I don't believe this is a PHPCS issue.
The errors themselves reported aren't issues, and if changed, would actually introduce changes no longer compliant with PSR12.
Here are the results of my latest run showing the two issues:
https://github.com/aran112000/Form-Generator/runs/418127387
Specifically, these are the issues being flagged:
Expected at least 1 space after "?"; 0 found
protected ?string $value = null;
Expected at least 1 space before ":"; 0 found
public function getId(): string
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.