Problem/Motivation
In last testing results we've got 155 coding standards messages
Here is full list of messages:
(EDIT: I removed all these messages, as it is not readable or usable the way they were formatted, is out-of-date, and is generally difficult to read and confusing to this issue. The current up-to-date list of coding standards problems may always be found by looking at the output of the automated tests at https://www.drupal.org/node/36041/qa)
Patches should NOT try to fix all issues at one time - instead they should focus on just one type of coding standards problem and fix that one type of problem for Voting API. Note that there are some issues that should probably NOT be fixed, like the line lengths in API.txt and CHANGELOG.txt for instance. Let's focus on getting the important things done first, like missing @param and documentation comments.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#42 | 3003096-40.patch | 16.89 KB | chaitanyadessai |
| |||
#40 | 3003096-39.patch | 16.72 KB | chaitanyadessai |
#38 | patchapplied.png | 147.16 KB | chaitanyadessai |
#32 | fixing-3331201-16.patch | 11.75 KB | rohit.rawat619 |
#29 | PHPCS - Apr 22th, 2023.txt | 6.97 KB | Diego_Mow |
Issue fork votingapi-3003096
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
pifagorComment #3
RomixuaComment #4
RomixuaComment #5
linichalexey CreditAttribution: linichalexey at EPAM Systems commentedComment #6
RomixuaComment #7
andralex CreditAttribution: andralex at EPAM Systems for EPAM Systems commentedComment #8
TR CreditAttribution: TR commentedComment #9
TR CreditAttribution: TR commentedComment #10
Suresh Prabhu Parkala CreditAttribution: Suresh Prabhu Parkala at Specbee commentedPlease review!
Comment #11
JordiK CreditAttribution: JordiK commentedThank you for the patch, Suresh!
There are still 11 coding standard errors...
Comment #12
TR CreditAttribution: TR commentedI would avoid making changes to code that will probably be removed: #3122497: Class name doesn't match filename
That will save us from having to review those changes time and again.
Likewise, some of these changes are already part of other pending patches, like #2791129: Vote rollover settings are missing the "Never" option and #3136360: Add support for Drush 9+. Those should be committed first. Coding standards are a low priority task, and should not be breaking other patches that are fixing bugs or fixing broken features. It's going to be a lot of work to re-roll all those other patches.
What is this?
Should be lower case. In many places.
+ * Delete votes for deleted entity everywhere in database.
Should be "Deletes"
You missed things that should be changed like
@param bool|true $update
I'm changing the status of this to "Postponed" because it's too disruptive at the moment until the pending issues in the queue get resolved.
Comment #13
TR CreditAttribution: TR commentedMost of the other changes have gone in - let's see if we can finish this off ...
Here's a re-roll of #10 against the current HEAD, with additional fixes added and no-longer-applicable fixes removed.
Comment #14
TR CreditAttribution: TR commentedI think we can reasonable fix a few more here.
Comment #15
jernejmramor CreditAttribution: jernejmramor at Agiledrop - Your Trusted Drupal Teammates commentedI have reviewed the patch from #14 and most of the coding standards errors are removed.
However there are still some left so I have attempted to fix them in the appended patch.
Please review.
Comment #16
TR CreditAttribution: TR commentedHi @jernejmramor:
I deliberately did not change the array type hints in function/method calls because that represents an API change, which is generally not allowed between minor point releases because that will break and/or cause problems for other modules like Fivestar which use the Voting API.
Like I said in #12, the MongoDB section of the votingapi.api.php documentation needs to be removed/rewritten - see the linked related issue #3122497: Class name doesn't match filename. I don't think it makes sense to spend effort on "improving" it when it is wrong and outdated - instead the effort should be spent on addressing that other issue.
There are a number of other problems that will exist even after this patch - most notably the line lengths in all the .txt files. I left out those line length changes because they are very messy and make these other changes difficult to review. I intend to post a second patch in this issue to take care of those separately, and after that we can see if any of the few remaining issues need to be addressed.
Comment #18
TR CreditAttribution: TR commentedCommitted #16.
Here's a patch to fix the line lengths in .txt files. The easiest way to review the changes is to apply the patch on your local system then do a
git diff --word-diff
which will show you just the actual changes, ignoring changes to whitespace (new lines, etc.). Because most of this patch is changes to whitespace, you will see only a small number of changes to spelling and punctuation.Comment #20
TR CreditAttribution: TR commentedCommitted #18 - it only affects documentation.
Comment #22
urvashi_vora CreditAttribution: urvashi_vora at Valuebound for Valuebound commentedHi,
I reviewed the patch and the module, for 8.x-3.x, I am getting this issues.
I will work on this and will provide a patch.
Thanks
Comment #23
urvashi_vora CreditAttribution: urvashi_vora at Valuebound for Valuebound commentedI resolved all errors, except these.
Providing a patch.
Comment #24
urvashi_vora CreditAttribution: urvashi_vora at Valuebound for Valuebound commentedPlease review this patch.
Thanks
Comment #25
mpauloThe last patch had some trailing whitespaces on some lines.
Also, a new violation was introduced since #24. Only these are left:
Comment #26
alexanderj CreditAttribution: alexanderj at CI&T commentedI will review it.
Comment #27
alexanderj CreditAttribution: alexanderj at CI&T commentedI did the patch review and according to what I read in the description and comments #12 and #16, it is not necessary for the changes to be applied in the MongoDB section of the
votesapi.api.php
, if it is right, the coding standards changes in this part should be reverted.Comment #28
TR CreditAttribution: TR commentedThe reason we address Coding Standards is NOT simply to satisfy the automated DrupalCI checks - those have false positives and sometimes suggest wrong changes. They are suggestions, and guidelines, and not absolute rules.
The whole point of Coding Standards is to make the code better, not just to make arbitrary DrupalCI warnings go away. It's perfectly fine to leave things unaddressed. For example "Only string literals should be passed to t() where possible", should be looked at then if it is not "possible" the code should NOT be changed. Yes, the CS warning will remain, and that's OK.
I think there are like only 3 lines in this patch that address coding standards. All the rest should NOT be done, or should be done in a separate issue. For example, dependency injection in the Drush command class is not a coding standard. It's also not needed - it's not wrong, but it's also not useful unless someone wants to write tests for the Drush commands. Since the Drush commands are just thin wrappers around Votingapi API functions, the normal tests of the API functions covers most of the operations, so I deliberately left the boilerplate dependency injection out in order to make updates easier (won't have to keep changing the constructor and drush.services.yml every time a new command is added). And BTW the dependency injection is done wrong in the above patch because drush.services.yml wasn't modified. If you want to address dependency injection in the Drush command class, that should be a separate issue where we can discuss that and make sure it is done correctly.
Likewise, t() shouldn't be used in tests, and {@inheritdoc} is only for when you actually have documentation in a parent class that you can inherit, and changing TODO to @todo doesn't actually help anything - if you want to help then you should actually write the missing documentation.
And please read everything I said above - most of what I said seems to have been ignored in this patch.
Comment #29
Diego_Mow CreditAttribution: Diego_Mow as a volunteer and at CI&T commentedUploading file PHPCS - Apr 22th, 2023.txt with latest PHPCS review and generated patch #29.
I read notes from #28 several times and those are some considerations while creating this patch:
Comment #30
apadernoTR said:
He did not suggest to add
@codingStandardsIgnoreLine
to all the lines that must not be changed. He said to ignore the warnings/errors for those lines that should not be changed, or that should be changed in a different issue.Comment #31
rohit.rawat619 CreditAttribution: rohit.rawat619 at TO THE NEW commentedComment #32
rohit.rawat619 CreditAttribution: rohit.rawat619 at TO THE NEW commentedComment #33
TR CreditAttribution: TR commentedComment #34
apadernoThe last patch is not for this project, since there is not any entity.module file in this project.
Leaving out the patch is not for this project, TR already explained that is the wrong type of changes to do. That documentation comment requires a short description, after the line containing
@file
; adding just the line containing@file
to avoid a PHP_CodeSniffer warning/error is not the type of changes he will accept.Comment #37
zkhan.aamir CreditAttribution: zkhan.aamir at Specbee for Drupal India Association commentedComment #38
chaitanyadessai CreditAttribution: chaitanyadessai at Specbee commentedPlease review patch.
Comment #40
chaitanyadessai CreditAttribution: chaitanyadessai at Specbee commentedPlease ignore #38.
Comment #42
chaitanyadessai CreditAttribution: chaitanyadessai at Specbee commentedPlease review patch.
Comment #43
TR CreditAttribution: TR commentedNo, and I really don't feel like repeating myself.
Comment #44
apadernoReplacing a full sentence with Voting API's is not a correct change, as it is not correct to split a sentence in a phrase and a sentence.
Furthermore, why is the class name changed?
If
$vote
is an object, it cannot be an integer.