Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Often the code review reorts the error "Docblock should be immediately above ..." althougth there is one.
Comment | File | Size | Author |
---|---|---|---|
#14 | 1984908_-14.coder_crlf.patch | 1.37 KB | jonathan1055 |
Comments
Comment #1
BeyersdorferTJ CreditAttribution: BeyersdorferTJ commentedCoder seems to work fine in "normal" module files but *.inc files.
Comment #2
DuaelFrThis bug still exists in 2.x.
This patch is part of the #1day1patch initiative.
Comment #3
fprevos2 CreditAttribution: fprevos2 commentedConfirming patch works.
Comment #4
asghar CreditAttribution: asghar commentedHi Guys
I have spent two to three hours tracing this issue because i was considering it is my module code formatting issue then i debug coder module there i found bug in coder module, here is few important info.
OS: Window 7
PHP: 5.4.3
drupal : 7.23
coder: 7.x-2.0
coder file :sites\all\modules\coder\coder_review\includes\coder_review_comment.inc and line 271
SNIP:
The following portion of the code * substr($alllines[$lineno - 1][0], -2)* returning only back slash "/" but actually there is "*/" then i printed the last two characters of the ASCII code then it returned two ascii code values
0 => /, ASCII ===>47
1 => , ASCII ===>13
It means that substr also considering enter value as character which we cannot see as normal routine so that at that stage our condition statement goes to false and we see warning messages on coder review page.
Comment #5
asghar CreditAttribution: asghar commentedSolution
we can solve this issue with rtrim or trim functions.
rtirm
or
only trim
Comment #6
asghar CreditAttribution: asghar commentedComment #7
fprevos2 CreditAttribution: fprevos2 commentedYour patch is identical to the one in #2.
Comment #8
asghar CreditAttribution: asghar commentedyes you are right.
Comment #9
fprevos2 CreditAttribution: fprevos2 commentedComment #10
BeyersdorferTJ CreditAttribution: BeyersdorferTJ commentedI installed the patch but still see functions listed as without doc-block.
Comment #11
stephenhendry CreditAttribution: stephenhendry commentedJust to confirm coder-docblock-immediately-1984908-5.patch is working great for me.
Comment #12
asghar CreditAttribution: asghar commented@stephenhendry thanks for confirmation.
Comment #13
jonathan1055 CreditAttribution: jonathan1055 commentedI discovered this error when I switched to using Git for some of my modules. Previously they did not have this problem, so it was caused by the CRLF setting which Git introduced. If I change a file's CRLF setting from Windows back to Unix then it fixes the problem, and I also discovered the unprintable character being counted in the substring. Hence I agree with the diagnosis above.
I also found other coder_review warnings incorrectly displayed, due to the same cause (that CRLF are considered to be real characters at the end of the line). In addition, when a file has this problem then the tests for trailing spaces do not work, as the blanks are not 'at the end' of the line.
Even though the patch files in #2 and #6 fix this individual error I think the problem is bigger and should be solved in a way which fixes it for all these issues.
Jonathan
Comment #14
jonathan1055 CreditAttribution: jonathan1055 commentedThe same cause also creates the following incorrect result:
when the @see reference is correct.
The code which detects a newline and pre-processes the content currently only detects '\n' but to cater for both type of line end, we also need to look ahead to the next character and test for '\r\n'. This covers both of the errors and also future-proofs it for new checks which might use the same logic.
With the new code, the following test function was used to create the debug below:
Linefeed set to UNIX LF
Linefeed set to Windows CRLF
The attached patch was against 7.x-2.2 but it should also apply ok to the dev version.
Jonathan
Comment #15
jonathan1055 CreditAttribution: jonathan1055 commentedHas anyone tried my patch in #14? I am finding it so much more helpful with code reviews now, with all the incorrect messages gone I can see the real problems.
Also has anyone checked D8? I do not know if this problem exists there. If so I guess I should download the 8.x dev and make the changes there first.
Jonathan
Comment #16
apperceptions CreditAttribution: apperceptions commentedFYI, this is still an open issue in Drupal 7.29 using coder 7.x-2.x-dev.
None of these patches succeed with 7.x-2.x-dev (or 7.x-2.2).
Executing patch < 1984908_-14.coder_crlf.patch produces the following output:
Hunk #1 FAILED at 447.
Hunk #2 FAILED at 507.
Hunk #3 FAILED at 522.
Comment #17
jonathan1055 CreditAttribution: jonathan1055 commentedThanks for testing this, and sorry to hear it does not work for you.
I guess the dev module has moved on, so I will re-cut the patch.
Comment #18
jonathan1055 CreditAttribution: jonathan1055 commentedI have just checked the patch in #14 and it applies cleanly to the latest dev, 7.x-2.x-dev, dated 2014-06-01
Your 'failed at' line numbers are slightly different to what they should be, so I think you must have an altered version of the code.
Jonathan
Comment #19
jonathan1055 CreditAttribution: jonathan1055 commentedI've been trying to get a D8 version of Coder Review working, specifically to test and create a patch for this issue, as per my patch in 14. However the module is missing all of the menu and routing .yml files, so is not currently useable. Is anyone else working on this?
I presume that any issue patches should be made to the D8 code-base first, but as it's not currently operational that is a bit hard to do. Just wondering what the plan was, ie are we going to re-cut the entire D8 code base at some point, based on the latest D7 at that time?
Jonathan
Comment #20
jonathan1055 CreditAttribution: jonathan1055 commentedJust checked and the patch in #14 still applies ok to 7.x-2.3 and to the latest 7.x dev of 29th Nov. Please can someone confirm it solves the CR/LF 'Docblock should be immediately above ...' problem, then the maintainers can commit it. Thanks very much.
Comment #21
jonathan1055 CreditAttribution: jonathan1055 commentedMy patch in #14 still applies ok at 7.x-2.4
Comment #22
jvandooren CreditAttribution: jvandooren commentedConfirming that patch #14 still applies and fixes the issue.
Comment #23
jonathan1055 CreditAttribution: jonathan1055 commentedThanks for testing Ozmodiar. If you are happy this fixes the problem please could you mark it RTBC.
The patch is #14 still applies at the new release 7.x-2.5. Would be nice to get it committed :-)
Comment #25
klausiCommitted, thanks!
Comment #26
jonathan1055 CreditAttribution: jonathan1055 commentedGreat to have this fixed. Thank you for committing my patch and for giving me the authorship credit. Cheers!
Jonathan