Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add suport for php-cs-fixer #94

Closed
sasezaki opened this issue Aug 7, 2021 · 4 comments
Closed

Add suport for php-cs-fixer #94

sasezaki opened this issue Aug 7, 2021 · 4 comments

Comments

@sasezaki
Copy link
Contributor

sasezaki commented Aug 7, 2021

Hi.

As feature request, I want php-cs-fixer support.
https://github.com/FriendsOfPHP/PHP-CS-Fixer

@sasezaki sasezaki changed the title Add suport php-cs-fixer Add suport for php-cs-fixer Aug 7, 2021
@sasezaki
Copy link
Contributor Author

sasezaki commented Aug 7, 2021

Like cs2pr https://github.com/staabm/annotate-pull-request-from-checkstyle,
checkstyle support would be get benefit as portable for other static analysis tool.

@sasezaki
Copy link
Contributor Author

sasezaki commented Aug 7, 2021

checkstyle support would be get benefit as portable for other static analysis tool.

I noticed, php-cs-fixer would not print Line Number.
PHP-CS-Fixer/PHP-CS-Fixer#3601

So, currently we could not support php-cs-fixer simply via checkstyle.

$ vendor/bin/php-cs-fixer fix src/Person.php --dry-run --diff --rules=@PSR12 --format=checkstyle
Loaded config default.
Using cache file ".php-cs-fixer.cache".
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle>
  <file name="src/Person.php">
    <error severity="warning" source="PHP-CS-Fixer.braces" message="Found violation(s) of type: braces"/>
  </file>
</checkstyle>

line number could be get only with --diff

$ vendor/bin/php-cs-fixer fix src/Person.php --dry-run --diff --rules=@PSR12 --format=xml 1>&2 2> /dev/null
<?xml version="1.0" encoding="UTF-8"?>
<report>
  <files>
    <file id="1" name="src/Person.php">
      <diff><![CDATA[--- /mnt/d/dev/sarb-demo/src/Person.php
+++ /mnt/d/dev/sarb-demo/src/Person.php
@@ -18,5 +18,4 @@
     {
         return $this->name;
     }
-
 }
]]></diff>
    </file>
  </files>
  <time unit="s">
    <total value="0.026"/>
  </time>
  <memory value="12" unit="MB"/>
</report>

@DaveLiddament
Copy link
Owner

Hi @sasezaki thanks for the feature request and for links to research you've already done. I'm not sure I'll be able to add this due to issue that php-cs-fixer does not supply line number. We might have to wait until there is support from the php-cs-fixer before progressing.

I'll take a bit more of a look at this and the diffs later this evening (I'm on UK time).

@DaveLiddament
Copy link
Owner

DaveLiddament commented Aug 7, 2022

Without line numbers it is not going to be possible to implement this. The relevant issue is PHP-CS-Fixer/PHP-CS-Fixer#3601

If a PR for this, or a similar PR that adds line numbers to an output gets merged then I'll happily create a ResultsParser for the format.

For now I'll close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants