You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When declaring two Javascript functions, with the first one having a default value assigned to its parameter, a warning is thrown targeting the line of the second function declaration stating that the equals sign is not aligned.
So the following code
aVerylongFunctionName=function(arg=null){// Some code here.}testFun=function(){// Some code here.}
The sniff throws the warning:
5 | WARNING | [x] Equals sign not aligned with surrounding assignments; expected 15 spaces but found 1 space
While the same code with the default value for the argument removed:
aVerylongFunctionName=function(arg){// Some code here.}testFun=function(){// Some code here.}
does not throw any warning.
I could be missing something but this does not seem right.
Any explanation of why this is happening is much appreciated.
Environment
Question
Answer
PHP version
5.6.40
PHP_CodeSniffer version
3.6.1
WPCS version
2.3.0
The text was updated successfully, but these errors were encountered:
kassemEzz
changed the title
Wrong reporting After decalring function with default argument value
Confusing Warning After Declaring Function With Default Argument Value
Nov 22, 2021
Based on your report as-is, this is not an issue with WPCS, but with one of the upstream sniffs and therefore should have been reported upstream to PHP_CodeSniffer.
I suspect it may be a similar/the same issue as this one, which was reported upstream a while ago and already has a PR open to fix it. I suggest you test that PR to verify.
I'll be closing this issue now. If you are sure this is a WPCS issue and can come up with a code sample with which this would be reproducable for one of the WPCS sniffs, please add the extra information and the issue can be reopened.
Bug Description
When declaring two Javascript functions, with the first one having a default value assigned to its parameter, a warning is thrown targeting the line of the second function declaration stating that the equals sign is not aligned.
So the following code
The sniff throws the warning:
5 | WARNING | [x] Equals sign not aligned with surrounding assignments; expected 15 spaces but found 1 space
While the same code with the default value for the argument removed:
does not throw any warning.
I could be missing something but this does not seem right.
Any explanation of why this is happening is much appreciated.
Environment
The text was updated successfully, but these errors were encountered: