Closed (fixed)
Project:
Feeds
Version:
8.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Jan 2018 at 08:30 UTC
Updated:
17 Mar 2024 at 13:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
megachrizInside the Feeds code base I executed the following command on the command line:
phpcbf --standard=Drupal .Then reviewed all the changes and corrected some of the automated fixes. For example: code that is commented out I want to leave untouched.
Comment #3
megachrizIn the patch some code was included I was still working on. New patch.
Comment #5
megachrizNothing known was broken, so committed #3!
Back to active for the remaining style fixes.
Comment #7
megachrizCoding standards for code in tests.
Comment #9
megachrizFixing test failures and more coding standard fixes in the tests.
Comment #10
megachrizComment #11
megachrizComment #13
megachrizCommitted #11.
Back to active for the remaining style fixes.
Comment #14
megachrizSome more coding standard fixes in tests.
Comment #16
megachrizComment #17
megachrizComment #19
megachrizCommitted #17.
And back to active again.
Comment #20
megachrizA large amount of coding standard fixes. Let's see if these cause any issues or if I skipped over a few coding standards issues.
Comment #21
megachrizSome more fixes.
Comment #22
megachrizCommitted #21. There are a few still left, so back to "active" again.
Comment #24
megachrizClosed #2984083: There are lot of coding standard issues please fix as a duplicate.
Comment #25
megachrizFixes for coding standard violations that slipped in lately.
Comment #26
megachrizCommitted #25. Back to "active" for remaining coding standard issues.
Comment #28
mohit.bansal623 commentedComment #29
darvanenThanks for this patch @mohit.bansal623 but it is simply too big to review. As you can see @MegaChriz has been addressing this issue in bite-sized pieces. Can I suggest that you supply a patch for just a few files, or even just one if the changes are large? As a guide let's try to keep the patches below 50KB.
Comment #31
urvashi_vora commentedI tried reducing the patch size @darvanen. Uploading a patch for some files.
Comment #32
megachrizThanks for the patch. I could be wrong, but it looks like that the patch is adding more coding standard issues than it fixes. Or did I miss changes in the Drupal coding standards?
Examples:
If I'm not mistaken, Drupal coding standards say that the opening accolade should be on the same line as the function name.
Drupal uses two spaces for indenting instead of 4.
Drupal uses uppercase for boolean values in code (in docblocks they may be lowercase).
Missing indentation for the arrays.
So I suspect that maybe a different coding standards profile was used when checking the code (not the Drupal one). If you use Coder Sniffer, you need to explicitly specify you want to use one of the Drupal rulesets. See https://www.drupal.org/docs/contributed-modules/code-review-module/insta...
Comment #33
urvashi_vora commentedHi, I worked on the patch, uploading it, please review it.
Comment #34
irinaz commentedComment #35
irinaz commentedComment #36
Guilherme Rabelo commentedHi, i will review this last patch.
Comment #37
Guilherme Rabelo commentedI found some erros and i cant apply this last patch. So i will unassigned and wait for the updates patch
Comment #38
darvanenHi @Guilherme Rabelo and welcome to the Drupal community :)
Thanks for reviewing the patch, to make the most of the time you spent doing so, any information you can provide on the problems you encountered will help those working on it be able to fix it - or potentially help you with it.
For instance: I'd like to check that you were applying the patch to the 8.x -3.x-dev version of the module, and that you used the
-p1flag on the patch command from within themodules/feeds/folder?Comment #39
joelpittetThese issues can be tricky because they touch code potentially modified by other patches.
Here is the current output when trying to apply the patch.
Where a couple failed to apply.
And here are some of the remaining changes:
But note some changes are API changes when renaming things for example so we can't make those changes easily.
Comment #40
Guilherme Rabelo commentedI rerolled the #33 patch and after that i was able to apply the patch. Now i will work on the issues to fixe.
Comment #41
Guilherme Rabelo commentedI cound't apply #33 patch.
So i rerolled the module from 8.x-3.x and after that i can run the phpcs and shows me a lot of issues about coding standadrs. The problems are in issuesPatch-41.txt file. So i fixed almost of the issues. Still have some unused variable problems, that i think its more interesting to someone who knows more about this module fixe this issues.
Needs to review this patch.
Comment #42
megachrizThanks for working on fixing the coding standards!
Here are my remarks on the patch. Since it was a big patch, I might not have spotted everything yet.
I'm not sure if I want to change this as it would break implementations in other modules.
I like these message to remain translatable. Perhaps they shouldn't be thrown in the form of an exception.
This isn't indented because it applies on what happens in `while()` in the line below. Having it indented looks like some code is missing in my opinion. What should we do about this one?
If two question marks are used, you would write it like this:
$var ?? '';instead of
isset($var) ?? $var : '';Overwriting the
$rowvariable here looks wrong.Aren't these breaks needed in order for code to go to the correct case? Not sure though.
I'd like these messages somehow to be displayed translated to the end user.
Some of these properties could use more useful descriptions, I think.
'drupal' is not the correct project. 'feeds' is not part of Drupal core.
I think it should be 'feeds:feeds' instead.
There is debug code here.
Why is PathautoTestHelperTrait removed here? I think that it is needed for the test?
Comment #43
darvanenMy 2c where there was a question or similar opening:
#42.0: "This is a big patch" - I think contributers would have more luck getting a patch through if you focussed on a single file at a time as I've previously encouraged.
#42.1: This is not a coding standards change, the code standards allow for either snake or camel case. I agree they should not be altered.
#42.3: I don't mind this change on a Do-While, the comment is inside the brackets and therefore *to me* makes sense to be indented. If it's bothersome perhaps consider changing to a While loop instead?
#42.6: There are return commands so the breaks are inaccessible, it's fine to remove them.
#42.9: I agree that
feeds:feedsis the right name to use.I agree with all the points I did not mention.
Comment #44
amanire commentedThat is true for Drupal 8, but we are running Drupal 9 and trying to update some custom code that extends
SyndicationItemto be in conformance with PHPCS Drupal. But we are stuck with snake case-related errors until this patch gets merged.Maybe this requires a major version increment to indicate that it is backwards incompatible?
Comment #45
megachriz@amanire
Changing the annotation properties for FeedsTarget plugins will break a lot of Feeds plugins in contrib though. I'm not sure if that break is worth it - even when upping the major version. Upping the major version is what I want to do soon anyway (as soon as Drupal 10 support is added), to indicate that Drupal 8 support is dropped.
I agree it is nice if the code fully complies with the Drupal coding standards, but I think that the impact/costs are too high. I don't have the resources to respond to all support requests that this change will generate.
Comment #46
bruno.bicudoI'll work on it :)
Comment #47
bruno.bicudoI worked on #41's patch to correct some Dependency Injection issues which were causing the module to break when adding new feeds.
Also worked on
FeedsAnnotationFactoryto correct the trigger_error message, referencing it to #3136615: Remove deprecated FeedsAnnotationFactory class as to match the relaxed standard format.Most "unusable variables" weren't touched, as it's more suitable for someone with more knowledge about the module to check.
Note that the content inside [ ] on each patch references to the folder where i worked on for that single patch.
Feed patch was also sent to #3248925-11: Dependency injection for \Drupal calls in classes correcting dependency injection issues.
Comment #48
megachrizThanks for the patches!
My review:
Why is StringTranslationTrait imported here? What coding standard issue does that fix? Also I think it is more common to only use the trait name inside the class and the full namespaced trait in the top of the file. So as follows:
Here I have the same question about the StringTranslationTrait.
The version where FeedsAnnotationFactory got deprecated is in 8.x-3.0-alpha6. Not 8.x-3.0 (alpha6). Perhaps the word 'Feeds' can be removed.
But maybe it is not much worth to fix it anymore. I'm planning to remove FeedsAnnotationFactory soon - at the moment where Drupal 10 support will be added.
I skip this one because it is already handled in #3248925: Dependency injection for \Drupal calls in classes
I think that this should not be changed as it is required for PHP 8.1 compatibility.
Rest of the patch looks okay.
I see not everything from #41 is included yet, so the issue would need to be left open after above issues are handled/resolved.
Comment #49
bruno.bicudoHi MegaChriz, thanks for the feedback.
Undefined method 't'on thegetLabelmethod's return. I'll be correcting this one to reflect your sample.@trigger_erroronly allows the standardproject:n.x-n.n. With-alpha6it only displays a warning (which i think is not a problem). It also requires a%cr-link%, that's why I included the link to #3136615. Should i keep the link to the issue and edit this to reflect-alpha6as it only generates a warning?#[\ReturnTypeWillChange]before the function comment block. Leaving it below the comment block generates an error on the comments. I just moved it above, but it's still declared right before the function itself with a special comment only for it :)I'll double check #41 and try to apply what's stated on your feedback at #42, including keeping snake case variables to avoid breaking other contrib modules.
So, I'll be working on it :)
Comment #50
megachriz@bruno.bicudo
#[\ReturnTypeWillChange]to be declared right before the function and thus after the docblock.Drupal Core also does this. See for example
Drupal\Component\Render\FormattableMarkup::count():It sounds like that the coding standards need to be updated for this behavior in PHP 8.1.
Comment #51
bruno.bicudoHi @MegaChriz,
I worked on this issue following what you pointed in #42, #48 and #50.
Some points i didn’t touch:
#42.3 – I agree with @darvanen that
#42.5 – I couldn’t understand why $row is being overwritten here, so i’ll leave this one for someone with better understanding.
#42.6 – I agree with @darvanen that
#42.8 – I couldn’t think of more useful descriptions for these properties, as they have a very simple context.
I also worked on every Dependency Injection that were missing on these files, but i’ll review it in details on #3248925: Dependency injection for \Drupal calls in classes
Every change was also tested on the UI to make sure nothing is breaking and that translations are working as intended.
Needs review :)
Comment #52
bruno.bicudoI'm sending a new patch to correct the DruschCommands kernel tests errors regarding the exit code (which i forgot to check before).
Comment #53
bruno.bicudoAdds
const EXIT_ERROR = 1;and returnsself::EXIT_ERROR;after eachlogger()->error()message to match the expected error code onKernel Tests.Comment #54
Johnny Santos commentedIm going to review it
Comment #55
megachriz@bruno.bicudo
I see some of your patches fail to apply. Can it be that they are a diff against an earlier patch? It would be better to create a diff against 8.x-3.x. For example, "2939688-51[Annotation].patch" looks like it only undoes some change in an earlier patch, but effectively doesn't change anything for 8.x-3.x.
Comment #56
bruno.bicudo@MegaChriz
I indeed diffed them against #41. I'll create the diffs against 8.x-3.x as pointed.
Thanks for the feedback :)
Working on it.
Comment #57
bruno.bicudoOk, so i broke #41 patch into smaller pieces (to keep sanity) and worked on the content of the patches so that it applies against 8.x-3.x as pointed.
I tested everything again to make sure nothing is broken, and so far everything is ok.
Unused variables remains untouched.
Needs review :)
Comment #58
bruno.bicudoSilly me, forgot to change status and unassign :P
Comment #63
bruno.bicudoCorrects exit code for
--import-disablederror message on [Commands] patch.I couldn't fix the errors in
[Feeds],[src]and[results]:/Comment #64
bruno.bicudoOkay, so... I focused on studying and understanding the tests, and I realized that some changes, despite fixing the CS, were causing some strange errors not only in the tests, but in the module itself.
I then reworked all the patches (now with a better understanding of it), and I think this time it's ok for review.
As the number of patches was large in my last upload (14 patches) and most were just small changes, this time I split it into just 4 patches to keep things organized (sorry for cluttering the feed with too many patches :P).
Unused variables and
#[\ReturnTypeWillChange]remains untouched (seesniffer.txtfor details).Needs review.
PS.: Failed tests due to addition of dependency injection of services on classes.
Tests.patchcontains all the changes made on those tests.Comment #66
bruno.bicudoComment #68
megachrizI've committed the patch "2939688-64[Form_Plugin].patch" with one small change:
Here we only needed to remove the second semicolon. No need to add a new line with just a semicolon.
I hope to look at the other patches later.
Comment #69
megachrizFrom #64, from the patch 2939688-64[Others].patch I specifically picked the Drush commands part as that part looked mostly good, but I saw some minor things to change. For example, I saw you added
@throws \Drush\Exceptions\UserAbortExceptionand I figured it would be good to add that to the other methods too that throw that exception. Other change is that I put an array on multiple lines.Let's see what the testbot says.
Comment #70
megachrizReview for "2939688-64[Others].patch" - excluding the FeedsDrushCommands part (see #69).
These should remain 'TRUE'. External resources should be able to push data to these paths and for that there should be no access restriction.
These intentionally start with an underscore to avoid possible collisions with classes that use the trait.
I think that this change is not necessary.
The deprecation happened in feeds:8.x-3.0-alpha11, not drupal:8.7.0. I think I'll remove it in the 4.0.0 version.
Good to add a link to an issue, but the link is wrong. The deprecation happened in https://www.drupal.org/project/feeds/issues/3152178.
Comment #71
megachrizOK, in #69 I got the indentation wrong. New patch.
Comment #73
megachrizThe patch in #71 is now committed. Three patches from #64 still need work.
Comment #74
bruno.bicudoI'll work on it.
Comment #75
bruno.bicudoHi @MegaChriz
I worked on everything that was pointed on #70.
I also reverted the changes to exceptions where i was passing a variable (
$errorMessage) as pointed in #70.4 on other classes.I split the bigger patch in 4 new patches with the naming
<className>+Testsso that it's easier for you to check them :). Those will (for sure) have errors, but that's because they need the editions made in the test (Mocking of injected services).Unused variables keep untouched and, as we didn't (yet) find a good way to translate exceptions, phpcs will keep warning about them :/
All that said, needs review. :)
Comment #77
bruno.bicudoFixes
EntityProcessorBasespecifically requiring themysqldatabase. Changed to a gereric database requirement.Fixes
Fileservice dependency injection offile.repository, provided that this service only exists from D9.3 onwards.Needs review together with the other patches on #75 :)
Comment #78
megachrizReview of 2939688-77[EntityProcessorBase+Tests].patch
It is recommended to require interfaces instead of classes, if they are available. This makes the code more flexible and also easier to test in unit tests.
Note: for the database service I haven't found a suitable interface, so there it's okay to require a class instead.
It looks like the messenger property isn't used in the class, so we don't need it here, I think.
I think it is okay to shorten these property names: leave out the words 'Service' and 'Interface'. I have come across cases where I found it more convenient to add the word 'Service', but I think it isn't needed here.
I've updated that patch.
Other
From the 'Files' info on this issue, it would be good to uncheck "Display" for those that are no longer relevant. Especially now that there are multiple patches to review it becomes harder for me to see which are still relevant. And since it now has been a few weeks that I last visited this issue. I've unchecked "2939688-75[EntityProcessorBase+Tests].patch" and "2939688-77[EntityProcessorBase+Tests].patch" now, since I posted a new patch for that one here.
Comment #79
bruno.bicudoRight! Sorry for the mess, I'm still learning how to (correctly) use drupal.org, but I'm really grateful for your feedback @MegaChriz
Comment #80
megachrizFor the EntityProcessorBase patch I made a few small corrections in the code comments. One being the wrong class/interface mentioned in the docblock. If this passes tests (and has no more code style issues), I think that one is ready for commit.
I think for better overview of what's left to review, I'd like to switch from patches to issue forks. Then I hope it easier to see which parts are still open.
Comment #88
megachrizCommitted #80.
I created several issues forks now, so now I can hide the patches that they are based on + the patches that look no longer relevant.
@bruno.bicudo
If I missed a few patches, let me know!
Comment #89
bruno.bicudoGreat @MegaChriz, indeed i sent a lot of patches to this one hahaha
I checked the list and looks like all of them are included. Thanks!
Comment #91
jayesh.d commentedHi @MegaChriz,
reviewing your patch. Thanks!!!
Comment #92
jayesh.d commentedHi @MegaChriz,
I tested your patch. But patch test is failing.
Comment #93
Munavijayalakshmi commented#80 failed because #80 patch with 8.x-3.x branch is up to date with 'origin/8.x-3.x'.
so please closed or fixed this issue.
otherwise some developer spent time to re-rolled patch.
Comment #94
Munavijayalakshmi commentedComment #95
megachrizI said in #88 that #80 was committed! And I hided all patch files to indicate that they are no longer relevant.
There are now 6 merge requests left to review. They are listed underneath the issue summary. Originally, these changes were in one big patch but I had requested to split them, so I can review and commit them in smaller chunks.
Comment #96
kunal_sahu commentedComment #100
rohit.rawat619 commentedtry to fixing some coding standard
Comment #101
rohit.rawat619 commentedComment #102
arpitk commentedHi the patch #101 applied cleanly. However there are still many issues reported by phpcs. Working on and providing updated patch.
Thanks!
Comment #103
megachriz@arpitk
I think that the first step is to review the three remaining merge requests that are open. Or if you want to write a patch, only make changes that are not covered by the MR's. When I've time to review this issue again, I'll first handle off the open merge requests.
Comment #104
avpadernoComment #105
zkhan.aamir commentedComment #106
avpadernoComment #107
isa.belHello, after updating to the latest version of this module (beta4), which includes this MR originated from this issue I began to have this error:
Therefore I created a patch specifically for this, if you guys can review it, I really appreciate it.
Comment #108
megachriz@isa.bel
Thanks for the patch, but I think it would be better to update this in #2928904: Add a mapping target to media field, as the code you are changing is not yet part of Feeds.
Looking at #2928904: Add a mapping target to media field, it looks like your changes are already applied to the latest patch that is provided there. So I think all you need is to update to a newer patch from that issue.
Comment #109
isa.belHi @MegaChriz, thank you for your reply, we were already using that patch, but from comment #56 so it was outdated, I already updated it and applied it, and now the code is already in place. Thanks again!
Comment #123
megachrizThe remaining phpcs issues have been fixed!
Since this issue started, we now also have eslint, phpstan and styleint issues to fix, but let's do that in a follow-up.
Comment #124
megachrizTwo follow-ups have been opened:
#3425218: Fix PHPStan errors
#3425219: Fix eslint and styleint issues