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

Error on line with comment #226

Open
solracsf opened this issue Jan 31, 2018 · 1 comment
Open

Error on line with comment #226

solracsf opened this issue Jan 31, 2018 · 1 comment

Comments

@solracsf
Copy link

Test case:

<?php
catch (Exception $e) { $result = false; } // suppress exception in case of SQL error, we will print it below

This looks to be due to a conflict between the Joomla.Commenting.SingleComment and Squiz.WhiteSpace.ControlStructureSpacing sniffs.

Relevant debug code:

---START FILE CONTENT---
1|<?php
2|catch (Exception $e)
3|{
4|	$result = false;
5|
6|} // Suppress exception in case of SQL error, we will print it below
7|
--- END FILE CONTENT ---
	E: [Line 5] Blank line found at end of control structure (Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose)
	=> Changeset started by PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ControlStructureSpacingSniff (line 214)
		Q: PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ControlStructureSpacingSniff (line 224) replaced token 19 (T_WHITESPACE) "\n}" => "}"
		A: PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ControlStructureSpacingSniff (line 227) replaced token 19 (T_WHITESPACE) "\n}" => "}"
	=> Changeset ended: 1 changes applied
	* fixed 1 violations, starting loop 7 *
---START FILE CONTENT---
1|<?php
2|catch (Exception $e)
3|{
4|	$result = false;
5|} // Suppress exception in case of SQL error, we will print it below
6|
--- END FILE CONTENT ---
	E: [Line 5] Please consider a blank line preceding your comment. (Joomla.Commenting.SingleComment.BlankBefore)
	Joomla\Sniffs\Commenting\SingleCommentSniff (line 171) replaced token 18 (T_WHITESPACE) "\n}" => "\n\n}"
	* fixed 1 violations, starting loop 8 *
---START FILE CONTENT---
1|<?php
2|catch (Exception $e)
3|{
4|	$result = false;
5|
6|} // Suppress exception in case of SQL error, we will print it below
7|
--- END FILE CONTENT ---

I suspect the fix is detecting that the comment is on the same line as a closing token and changing the fix to put the comment on a new line, or just allowing this.

@mbabker
Copy link
Contributor

mbabker commented Jan 31, 2018

This is by design. Our coding standard does not allow a trailing comment on a line of executable code.

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