Up to now we have, I think, used a pretty loose coding standards rules file to avoid fails. Based on the one from Core, if I'm not mistaken.
However, Core is far more lax regarding coding standards than we are, so we should be fine running far more rules. This will also help us much better to avoid accidental regressions in our standards-compliance, which can now more easily happen due to explicitly excluded sniffer rules.
To this end, I'm also re-thinking my position on some of the "uglier" changes which me have to make to comply with some of the rules. This might still be the "lesser evil" than removing the rule altogether, leaving us open to unintended violations elsewhere.

Comments

drunken monkey created an issue. See original summary.

drunken monkey’s picture

Status: Active » Needs review

Actually, there were just three "problematic" points:

  1. Commented-out code will have to be indented like an actual comment, not with comment marks at the start of the line. I find that not as clean-looking as our current style, but – as outlined above – I'm fine with that trade-off. (Since we've already had wrong indentations at other points, too.)
  2. \Drupal\search_api\Query\Query::setDisplayPluginManager() didn't have a type hint for $display_manager. To avoid type-hinting on a class name, I created a new interface, DisplayPluginManagerInterface, for the class and type-hinted on that. Since the plugin manager adds a public method, this does make sense anyways. (Otherwise, I probably wouldn't have done this.) If we're gonna keep that, we just need a change record for this (hence the tag). Also, we should probably commit this immediately after the next release, so other modules have enough time to adjust, in case they need to. (Concerns a bunch of other places, where type hints were added, as well.)
  3. There were some complaints about missing parameter type hints in SearchApiFieldTrait, where we can't add a type hint because the field handler plugin base class (this being Views) doesn't have them, either. I think with normal inheritance, the sniffer would even be smart enough to realize this and refrain from complaining – however, with a trait, it can't of course know that this is the case.
    Long story short: In order to keep the sniff, but avoid the complaints, I changed the parameter doc in all cases to @param array|\ArrayAccess. Nonsense, of course (though technically true, I guess), but the best way I could think of of resolving this.

    I did the same for the $context parameters of our batch callbacks, by the way, but since Drush actually does call them with \ArrayAccess objects, it actually makes sense there.

OK. Reviews, comments and opinions welcome!

drunken monkey’s picture

StatusFileSize
new31.59 KB

Status: Needs review » Needs work

The last submitted patch, 3: 2907334-2--coding_standards.patch, failed testing. View results

borisson_’s picture

Status: Needs work » Reviewed & tested by the community

All these changes look solid!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 3: 2907334-2--coding_standards.patch, failed testing. View results

drunken monkey’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record
StatusFileSize
new5.42 KB
new37.26 KB

Thanks a lot for reviewing, good to hear that the code style changes look OK to you.
Obviously, though, they did break a few things here and there. The attached revision should fix that.
At least, though, this also gave me time to create a change record.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

  • drunken monkey committed 0559e9b on 8.x-1.x
    Issue #2907334 by drunken monkey: Fixed some more Drupal coding...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Great, thanks again for the review!
Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.