Closed serundeputy closed 1 year ago
@quicksketch for core/module/X
on the X.info
files phpcs
reports:
geoff@yep backdrop (phpcs) exit code: [0] $ vendor/bin/phpcs --standard=./vendor/backdrop/coder/coder_sniffer/Backdrop core/modules/admin_bar/admin_bar.info
FILE: .../code/sites/backdrop-ops/backdrop/core/modules/admin_bar/admin_bar.info
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
1 | ERROR | "core" property is missing in the info file
--------------------------------------------------------------------------------
UPGRADE TO PHP_CODESNIFFER 2.0 TO FIX ERRORS AUTOMATICALLY
--------------------------------------------------------------------------------
should we be adding the core
property to the info files or write some magic into the phpcs
rules to ignore this for core
modules` but use it for custom and contrib?
@quicksketch there are probably going to be a fair amount of these lower_case class names; here is what I did so far:
// @codingStandardsIgnoreStart
// @TODO: Make all classes CamelCase and class methods lowerComelCase in 2.x.
class views_plugin_argument_default_book_root extends views_plugin_argument_default_node { class views_plugin_argument_default_book_root extends views_plugin_argument_default_node {
function get_argument() { function get_argument() {
// Use the argument_default_node plugin to get the nid argument. // Use the argument_default_node plugin to get the nid argument.
@@ -19,3 +21,4 @@ class views_plugin_argument_default_book_root extends views_plugin_argument_defa
} }
} }
} }
// @codingStandardsIgnoreEnd
seem appropriate? what do you think?
I successfully ran the command vendor/bin/phpcs --standard=./vendor/backdrop/coder/coder_sniffer/Backdrop core/modules/admin_bar/admin_bar.inc
and got FOUND 18 ERROR(S) AND 3 WARNING(S) AFFECTING 20 LINE(S)
plus the other output in that comment.
I like UPGRADE TO PHP_CODESNIFFER 2.0 TO FIX ERRORS AUTOMATICALLY
if that works? I'm all about being lazy :) Can that happen for the subtasks on the meta-issue?
I like UPGRADE TO PHP_CODESNIFFER 2.0 TO FIX ERRORS AUTOMATICALLY if that works? I'm all about being lazy :) Can that happen for the subtasks on the meta-issue?
I know the php version for that version of phpcs is > php 5.3 so i'm not sure we could do that
Mentioning #659
@drupol in https://github.com/backdrop/backdrop-issues/issues/3896#issuecomment-506693859:
Hi,
I started to do this project: drupol/backdrop-conventions, maybe it would be something to evaluate ?
It's based on Grumphp.
I commented re this on Gitter, but I was sure that we had an issue someplace for this 😄
I just came across https://github.com/marketplace/hound which seems to be free for open-source, public projects
Hound reviews your code then comments directly in Pull Requests, helping your team maintain consistent coding style and high code quality. ...integrates with your existing workflow by reviewing changes and commenting the moment a Pull Request is created or updated.
Supports phpcs: http://help.houndci.com/en/articles/2461415-supported-linters
...seems all we need is a subscription, and adding a .hound.yml
file to the repo.
...also https://github.com/marketplace/imgbot which is free!
@serundeputy What is needed to make this happen? i.e. Can/how can I help?
@serundeputy Part of the recent changes to the packager on BackdropCMS.org allows us to now exclude certain files from the ZIP package files on releases. It already excludes .zenci.yml and .gitlc.yml files.
I'd love to have us switch to a .zenci.yml
file (just copy the current .gitlc.yml off of backdropcms.org) and put it in the repository. And that way we'll be able to verify that the changes in the YML file work as expected all in one PR, since the code style checks will apply to the PR on which the new YML file is included. Could you rework this into a single PR just against Backdrop core?
On further thought, for something like this where we're just running code checks, could we use GitHub actions? We have actions enabled on the Backdrop repository, so you should be able to put scripting into a .github/workflows/phpcs.yml
file (or similarly named) and have it run. @jenlampton tried an example one on the backdrop-issues
repository a while back: https://github.com/backdrop/backdrop-issues/commit/fd6058d8a4476eaa9f039db9ec803a128b244c82
@quicksketch I don't think I ever got any actions working, but back then actions were new and maybe still had some issues.
Here's a PHPCS example file: https://github.com/marketplace/actions/phpcs-code-review
I started working on PHPCS reviews via github actions last week, and I was eventually able to get them working.
I jotted down some quick notes on the changes that were required in Let's get PHP_CodeSniffer working with Backdrop #10 since @alanmels was having the same problems.
edit: If it's of value, here's the yaml file my contrib project was using.
@serundeputy started looking at GH actions for this, but need more research … I’ve not determined where and how they actually load PHPCS into the action, so that I can inject
backdrop/coder
into it as well
The project is now named coder_review
for Backdrop, and from my testing a git clone
did not work, but a wget
did. I think I read somewhere that a curl
would also work, so to remove the specific version and grab latest, I was going to try something like curl --silent "https://api.github.com/repos/$1/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")'
instead, but I didn't get there last week.
In the rapidly changing landscape of GitHub Linters, GitHub has published their own official linter for use through GitHub Actions: https://github.blog/2020-06-18-introducing-github-super-linter-one-linter-to-rule-them-all/
Unfortunately it does not yet support PHP, but there's a lot of activity on that front: https://github.com/github/super-linter/issues/122
However regardless of which approach we use, we'll need to make sure that our linting rules for phpcs are up-to-date.
And the "super-linter" now supports PHP. Yay! But it's extremely rudimentary, just syntax checking, not code style. We may want to still pursue our own linter after all.
Heard some discussion about this in the dev meeting, and I was wondering, if we're going to be using this for all Backdrop core PRs etc., should the code styleguide be in Backdrop core rather than a contrib module...?
@serundeputy is doing this with Drush, and he uses his own repo: https://github.com/serundeputy/coder He basically forked the contrib module, then removed all the other stuff and just left the code sniffer stuff (the contrib module does a lot of different things it seems).
I was thinking we should standardise this by merging @serundeputy's repo into core (then Drush can use that too), and then removing that part of it from the contrib module. So the contrib module does everything else it currently does, and just the code sniffer part is in core.
Make sense?
Make sense?
It does to me.
The problem with having it in core is that it will be used by less than 20% of actual Backdrop sites, which goes against our principles. Maybe we can have the packager strip it out?
Also, the "code styleguide" isn't a generic set of instructions for Backdrop, it's specifically for PHPCS... (not sure if that matters, other than to say "it's useless" by itself)
Ok, so not core, but what about its own repo in backup-ops then?
My point being basically that as far as I'm aware, the code we need to integrate with PHP Code Sniffer (like all the Backdrop-specific styleguide stuff) in lumped in to a module that does other things too. Related things, sure, but not necessary, for example, when you're testing a core PR against our coding standards. I believe this is why @serundeputy forked the contrib module and pulled out all that other stuff, because it wasn't necessary to include all that each time you just want to check code on the command line.
So I suggest we pull that PHPCS stuff out of the Coder Review module, and then put it in its own repo (either backdrop-ops or its own contrib module). Then anyone that needs it (Backdrop core when testing PRs, Drush, Coder Review, etc.) can depend on it.
So I suggest we pull that PHPCS stuff out of the Coder Review module, and then put it in its own repo (either backdrop-ops or its own contrib module). Then anyone that needs it (Backdrop core when testing PRs, Drush, Coder Review, etc.) can depend on it.
I think that makes sense. This is essentially what the Drupal coder
contrib project is right now (there's no module-stuff in there anymore)
I was thinking that we might want to fork that one (instead of using what's in coder_review) because Drupal's project already works with PHPCS 3.x and with Drupal 7. Maybe we even call ours "coder" (to match Drupal) and leave it in backdrop-contrib?
Then comes the other question I've been struggling with: what version number do put on it? If we wanted to match the Drupal version numbering it would end up 8.3.9 -- which I have mixed feelings about.
what version number do put on it?
Does it need a version number...? As a "command line tool" and "not a module" (source: https://www.drupal.org/project/coder) can't we just have a 1.x branch that has Backdrop's up-to-date coding standards?
it's specifically for PHPCS
What if we called it something like backdrop_phpcs
then?
As a "command line tool" and "not a module"
Good catch, ...but even drush has versions: https://github.com/backdrop-contrib/backdrop-drush-extension/releases
What if we called it something like
backdrop_phpcs
then?
I like that 👍
Why change the name from coder though, if it's the same thing? Won't it be easier for people coming from Drupal?
it will be used by less than 20% of actual Backdrop sites
Won't it be easier for people coming from Drupal?
What percentage of Backdrop sites using Coder will be coming from Drupal...? :wink:
Edit: If it's easier to keep the name, that's fine. Was just a suggestion that made more sense to me.
In today's weekly meeting @quicksietch pointed out that in the future we may also want to include javascript testing, and that we might want the code for those js tests to live in the same project as the code for our PHP tests. That way, if we made a change to our coding standards that affected both, we could update the project with one PR.
So maybe including phpcs
in the project is too specific. What about something like backdrop_standards
? Though my preference is still to stick with coder
.
What percentage of Backdrop sites using Coder will be coming from Drupal...?
Right now: 100% of people using coder are coming from Drupal. But as Backdrop grows that number should decrease :)
Here're some thing that might be of interest:
If they don't suit, there are plenty of others: https://github.com/marketplace?type=actions&query=phpcs
It seems we got hung up on the name. But that aside...
I was thinking that we might want to fork that one (instead of using what's in coder_review) because Drupal's project already works with PHPCS 3.x and with Drupal 7.
We need to decide if we fork Drupal's Coder module, or if we just pull the coder_sniffer
directory out of coder_review
and make it its own project that others can depend on.
@docwilmot is the current maintainer for coder_review
. Thoughts?
I'm asking again now because I'm wanting to add PHPCS checks to Bee, and I'd rather not have to download the entire coder_review
module when all I need is what's in the coder_sniffer
subdirectory...
Just including the directory makes sense.
@docwilmot Do you want to do that, or you'd rather someone else maintain that part of the code...?
I'm not sure, where to add the PR, but it seems that I got some basic linter setup working, which only fires on updated/added files and adds annotations.
Example: https://github.com/backdrop/backdrop/pull/3749/files
That looks great @indigoxela! I'm a fan of the GitHub Actions to avoid a lot of custom scripting in our own repository. Now if we can work out applying Backdrop-specific code style.
@quicksketch is this https://github.com/backdrop/backdrop/pull/3749/files#diff-a036b60d22557d7f21abeaecaa42088f12680e7d72056f9d7de8c0db426984a6R32 not backdrop specific?
idk ... it's been a few years lolz;
Since this was originally raised for Zen.CI and since phpcs
has been implemented as a GitHub action, I'm closing this issue. The fixing of existing coding issues throughout core will be handled in https://github.com/backdrop/backdrop-issues/issues/6004
Describe your issue or idea
Run
phpcs
Backdrop code standards checks against all backdrop/backdrop PRs.Actual behavior (if reporting a bug)
Expected behavior (if reporting a bug)
phpcs
checks in ZenCIThere are two PRs on the table to enable this to happen:
To run the
phpcs
checks locally follow the instructions in the README.md here: https://packagist.org/packages/backdrop/coderHere is an example of running
phpcs
locally against one file:and the output:
https://github.com/backdrop/backdrop/tree/phpcs
rather than the1.x
branch until we get complete covergeEach participant should self assign themselves a core module and add it to the list here:
core/includes
database
@serundeputymysql
@serundeputyfiletransfer
core/modules
admin_bar
@serundeputyblock
@serundeputybook
@serundeputyckeditor
color
comment
config
contact
contextual
dashboard
date
dblog
email
entity
field
field_ui
file
filter
image
installer
language
layout
link
locale
menu
node
path
redirect
search
simpletest
syslog
system
taxonomy
translation
update
user
views
views_ui