Note this only applies to Fivestar in Drupal 7. For Drupal 8, see #3133101: [D8] Coding standards
Fivestar 7.x-2.x was written under a previous set of coding standards - Drupal core has changed standards drastically since then, with many new standards aimed primarily at D8 code. Drupal core policy is this:
All new code should follow the current standards, regardless of (core) version. Existing code in older versions may be updated, but doesn't necessarily have to be. Especially for larger code-bases (like Drupal core), updating the code of a previous version for the current standards may be too huge of a task. However, code in current versions should follow the current standards.
There are more reasons than just "may be too huge of a task" to leave the 7.x-2.x code mostly untouched - modifying class names, variable names, etc. has a great potential to break code and break our integration with modules like Views. Likewise, coding standards patches touch many parts of the code base, so have a great potential to break other work-in-progress patches that address real problems (bug reports) or make real improvements (feature requests) - coding standards changes are extremely minor in importance related to these.
Because of this, I am not very interested in putting in a lot of effort to change anything EXCEPT for things that may / are known to cause problems (like extra whitespace or missing EOL at ends of files) and things that will actually HELP people who use Fivestar (like missing or incomplete documentation comments).
If you would like to submit patches here, make sure they are restricted to one and only one type of standards violation - that will make them easier to review. We don't need multiple issues for this - all coding standards patches should be posted in this issue.
Comment | File | Size | Author |
---|---|---|---|
#38 | coding_standards.patch | 9.03 KB | Shreyas gowda |
#34 | Codestnd-3137082-34.patch | 10.29 KB | Amit.Rawat777 |
#27 | fix_coding_standard.patch | 35.09 KB | kartiktandon |
#20 | interdiff-13-20.txt | 2.66 KB | nitin_lama |
#20 | 3137082-updating-cs-20.patch | 21.58 KB | nitin_lama |
|
Issue fork fivestar-3137082
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
TR CreditAttribution: TR commentedLine length.
Comment #4
urvashi_vora CreditAttribution: urvashi_vora at Valuebound for Valuebound commentedComment #5
urvashi_vora CreditAttribution: urvashi_vora at Valuebound for Valuebound commentedHi,
Please review this patch.
Thanks
Comment #7
TR CreditAttribution: TR commentedThank you for wanting to help, but coding standards changes can be tricky because phpcs reports a lot of false problems and because making coding standards changes in the code can't improve functionality, but CAN break things. Because of this, you can't simply change the code just to make the errors go away - you have to understand first what phpcs is complaining about and why, and make an informed decision whether something should be changed or not, and decide HOW it should be changed. Not every reported violation should be fixed.
As I said in the issue summary:
But this patch tries to address too many things, and it would take to long to point out every single problem then re-review the patch when you fixed all those problems. Please try to fix only one type of standards violation - you can submit other patches after that to fix other types.
Right at the start of the patch there's a problem - you modify fivestar.api.php to remove coding standards messages similar to "Hook implementations should not duplicate @return documentation". This is a false positive. The fivestar.api.php file is where all hooks are documented. This IS the primary hook documentation, this is NOT duplicate documentation. If you remove this documentation in the api.php file, then the Fivestar hooks won't have any documentation.
Also, right at the end of the patch there's a problem - you do this:
Three things wrong with this:
There are many other problems with the patch - like adding @inheritdoc to functions that don't/can't inherit documentation, Instead you should be writing actual documentation.
Also, when you do something like
you make the coding standards message disappear, but you also BREAK all the translations for this module because you've removed the old strings from the translation table and added new strings which don't have translations. That is not something that should be changed, especially since the D7 version of this module has been around for so long and D7 is close to obsolescence.
Please submit a new patch that only tries to address one type of coding standards message.
Comment #8
urvashi_vora CreditAttribution: urvashi_vora at Valuebound for Valuebound commentedHi @TR,
Thanks for your valuable feedback. I will provide another patch.
Comment #9
urvashi_vora CreditAttribution: urvashi_vora at Valuebound for Valuebound commentedComment #10
urvashi_vora CreditAttribution: urvashi_vora at Valuebound for Valuebound commentedHi @TR,
Here is the patch for "The array declaration extends to column 128 (the limit is 80). The array content should be split up over multiple lines" errors.
Please review this patch.
Thanks
Comment #11
urvashi_vora CreditAttribution: urvashi_vora at Valuebound for Valuebound commentedHi @TR,
Here is the patch for the "Line exceeds 80 characters" error.
Please review the patch.
Thanks
Comment #12
urvashi_vora CreditAttribution: urvashi_vora at Valuebound for Valuebound commentedHi @TR,
Here is the patch for "Doc comment is empty"
Please review. Thanks
Comment #13
urvashi_vora CreditAttribution: urvashi_vora at Valuebound for Valuebound commentedHi @TR,
Here is the patch for "Missing @var tag in member variable comment" and "Missing parameter type".
Please review this patch.
Thanks
Comment #14
erikaagp CreditAttribution: erikaagp at CI&T commentedComment #15
apadernoThat is not how a class constructor is documented.
A method that extends a parent method or that implements an interface method is documented with
{@inheritdoc}
.That is not what a function documentation comment should say. It misses the parameters declaration too.
Comment #16
nitin_lamaComment #17
nitin_lamaFixed remaining coding standards and addressed #15
Comment #18
apadernoThe short description needs to be 80 characters or less; that change is correct. The long description needs to be a sentence too, while Along with exposed fivestar formatters is a phrase. The long description can repeat what the short description already said.
That still isn't how constructors are documented.
That isn't how methods are documented.
That change isn't required from the Drupal coding standards. Drupal 7 doesn't require PHP 7 as minimum PHP version; the null coalescing operator cannot be used.
That documentation comment isn't correct: It doesn't add any information that isn't already given from the code, nor does it explain what the purpose of the function is.
While there are similar comments for other functions, adding that documentation comment where there is no documentation comment is useless. Eventually, the other documentation comments should be changed.
The short description for a function must describe what that function does or, in the case of hook implementations, which hook the function implements.
While this change could be correct, it's not a change required from Drupal coding standards.
That isn't a necessary change, nor a change that Drupal coding standards require.
list()
isn't a deprecated function, and the coding standards don't require that change.The existing comment only needs a period.
That is not how a hook is documented.
A class short description should say what the class purpose is.
user
is not a correct datatype. The Drupal coding standards say what can be used after@var
and that isn't an allowed value.Comment #19
nitin_lamaComment #20
nitin_lamarerolled patch #17 and addressed #15 & #18 except constructor documentation.
Comment #21
nitin_lamaComment #22
apadernoWhat reported in comments #15 and #18 hasn't been yet addressed.
Comment #23
kartiktandon CreditAttribution: kartiktandon as a volunteer and at TO THE NEW commentedI am Working on it
Comment #26
TR CreditAttribution: TR commentedWell I don't know what to do with this - it keeps getting worse.
The latest MR has all sorts of new problems. It looks to me like it was forked from a version of Fivestar that is over 2.5 YEARS out of date. For example:
The permissions on that file were fixed (by me) by commit d9b735be8d6ac4038 on 3 May 2020.
Likewise, as far as I can tell ALL the changes to the CSS files are out of scope of this issue - those changes are NOT coding standards changes, they change the actual properties and selectors. These changes have not been discussed and do not belong here.
While improvements to the advanced help are appreciated, again those go far beyond a "coding standards" change. And they should be done in the CURRENT version of the module. The current version of the module needs to be fixed first, then those changes can be backported to the amost-obsolete D7 version. Fixing it in D7 first is a good way to waste effort, because that version (along with the improvements) will disappear soon.
There's also a lot of D8 code in there. For example the new file
fivestar.php
which hasclass Fivestar extends FormElement {
- this is not Drupal 7 code.Comment #27
kartiktandon CreditAttribution: kartiktandon as a volunteer and at TO THE NEW commentedComment #28
kartiktandon CreditAttribution: kartiktandon as a volunteer and at TO THE NEW commentedComment #29
kartiktandon CreditAttribution: kartiktandon as a volunteer and at TO THE NEW commentedComment #30
TR CreditAttribution: TR commentedPatch does not apply and patch introduces new coding standards problems (trailing whitespace).
Please post an interdiff with any patch so we can see what you changed.
Short array syntax can't be used in D7 because it doesn't work with PHP 5.3. Drupal 7 still supports PHP 5.3.
Comment #31
TR CreditAttribution: TR commented@apaderno: As you said in #18:
and
Agreed, HOWEVER the results from PHPCS run by DrupalCI report these as errors. See for example https://www.drupal.org/pift-ci-job/2502899
DrupalCI is using sniffs that apply standards that haven't been adopted by Drupal and aren't enforced in Drupal core. This is an ongoing problem for contributed modules.
I consider those false positives, which should not be "fixed". As I said in #7 , when creating coding standards patches one has to "make an informed decision whether something should be changed or not, and decide HOW it should be changed. Not every reported violation should be fixed."
Comment #32
lalitkyttn CreditAttribution: lalitkyttn as a volunteer and at TO THE NEW commentedI am working on this
Comment #33
TR CreditAttribution: TR commented@lalitkyttn: Still working on it?
Comment #34
Amit.Rawat777 CreditAttribution: Amit.Rawat777 at TO THE NEW commentedfixed some coding standard issues.
Comment #35
apadernoThe module name is Fivestar.
The issue has been created for the 7.x-1.x branch, which does not contain that code. That is code from the Drupal 8 branch (and this explains why the patch fails to apply).
Comment #36
TR CreditAttribution: TR commentedComment #38
Shreyas gowda CreditAttribution: Shreyas gowda commentedComment #39
apadernoMR!12 has merge conflicts that must be manually resolved.
Comment #40
zkhan.aamir CreditAttribution: zkhan.aamir at Specbee for Drupal India Association commented