Problem/Motivation
It is hard to follow the code when it's not following the Drupal standard and Drupal Practice.
And that will be harder to commit or fix with MR or a patch.
Our eyes are used to read code with Drupal standards.
Standard check and linting tools are outdated.
And a new linting tool with yarn lint:yaml was added to Drupal core
#2591827: Add YAML linting to core coding standards checks
Very important to make sure that all .yml files are in the right format.
eslint-plugin-yml a good tool to lint with
Example: using not standard format
or check on any duplicate yaml elements
Proposed resolution
Add the yarn lint:yaml
and update all outdated check configs and the package.json file
Compiling Provided Component Styles
In case of wanting to add a new feature or fix a bug in styling.
Get Needed Yarn Development Dependencies
yarn installAfter any change of code please check the standards before uploading a patch or creating a MR.
Check Standards/Practice Coding And Linting
Check Drupal Standard And Practice Coding
Check Drupal standard and practice coding.
yarn phpcs
PHP Code Beautifier and Fixer
Fix many errors and warnings automatically.
yarn phpcbf
Linting YAML files
Check all .yml files with Drupal standard yaml format.
yarn lint:yaml
Linting JavaScript files
Check all JavaScript .js, .json files with Drupal standard scripting format.
yarn lint:js
Linting Styling
Check all styling .css files or css in twig or apps with Drupal standard styling format and order.
yarn lint:css
"scripts": { "phpcs": "phpcs --standard=./.phpcs.xml .", "phpcbf": "phpcbf --standard=./.phpcs.xml .", "lint:yaml": "node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.json --ext .yml .", "lint:js": "node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.json .", "lint:css": "npx stylelint --config=.stylelintrc.json ." },
Remaining tasks
- ✅ File an issue about this project
- ✅ Have
PSR,PHPCS,lint:js,lint:css,linkt:yaml - ❌ Fix all reported standard points to set the floor clean for more collaborative work
- ❌ Testing to ensure no regression
- ❌ Automated unit/functional testing coverage
- ❌ Developer Documentation support on feature change/addition
- ❌ User Guide Documentation support on feature change/addition
- ❌ Code review from core team member
- ❌ Full testing and approval
- ❌ Credit contributors
- ❌ Review
- ❌ Release
User interface changes
- None
API changes
- None
Data model changes
- None
| Comment | File | Size | Author |
|---|---|---|---|
| #35 | Captura de tela de 2022-07-08 09-38-42.png | 135.68 KB | elber |
| #14 | 3238572-14.patch | 33.99 KB | rajab natshah |
| #7 | Browse-Drupal-org-projects---dev-drupal9-c1-project_browser---25-09-2021--10-15.txt | 271.64 KB | rajab natshah |
| #6 | 3238572-6.patch | 488.11 KB | rajab natshah |
Issue fork project_browser-3238572
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
rajab natshahComment #3
rajab natshahIn case we are going to use PostCSS not SASS then the command for the needed dev packages needs to be changed.
Maybe this project does not have .css files at this time.
Tested only using Drupal core standard set of classes. it is the better option in all cases
Drupal core is using number of yarn commands at
https://git.drupalcode.org/project/drupal/-/blob/9.3.x/core/package.json
Comment #4
rajab natshahComment #5
rajab natshahComment #6
rajab natshahComment #7
rajab natshahAttached the output check report for
phpcs --standard=Drupal
rajab@vardot-dev:/var/www/html/products/project_browser$ phpcs --standard=Drupal --extensions=php,inc,install,test,profile,theme,css,info,txt,md,yml /var/www/html/products/project_browser/ --ignore="/var/www/html/products/project_browser/node_modules/ , /var/www/html/products/project_browser/sveltejs/node_modules/"phpcs --standard=DrupalPractice
rajab@vardot-dev:/var/www/html/products/project_browser$ phpcs --standard=DrupalPractice --extensions=php,inc,install,test,profile,theme,css,info,txt,md,yml /var/www/html/products/project_browser/ --ignore="/var/www/html/products/project_browser/node_modules/ , /var/www/html/products/project_browser/sveltejs/node_modules/"yarn phpcs
yarn phpcbf
yarn lint:yaml
yarn lint:js
yarn lint:css
Not sure if we should fix all reported standard issues in this issue.
Comment #8
rajab natshahComment #9
rajab natshahComment #10
gaurav.kapoor commented+1 to the fact that coding standards aren't as per Drupal in most of the files. The text file attached in #7 highlights all the issues as well. But do we need all the files provided in #6? I am not sure about it. Can't we just fix CS issues and push them and take care of them when new patches/MR are provided.
Comment #11
rajab natshahAgrees with Gaurav.
Updated the title to reflect that.
Comment #12
rajab natshahphpcs --standard=Drupal
phpcs --standard=DrupalPractice
Comment #13
rajab natshah#2770065: array_key_exists() micro-optimization
array_key_exists was used in number of places
one of them
Comment #14
rajab natshahComment #15
rajab natshahphpcs --standard=Drupal
phpcs --standard=Drupal --extensions=php,inc,install,test,profile,theme,css,info,txt,md,yml /var/www/html/products/project_browser/ --ignore="/var/www/html/products/project_browser/node_modules/ , /var/www/html/products/project_browser/sveltejs/node_modules/, /var/www/html/products/project_browser/sveltejs/public/build/bundle.css"phpcs --standard=DrupalPractice
phpcs --standard=DrupalPractice --extensions=php,inc,install,test,profile,theme,css,info,txt,md,yml /var/www/html/products/project_browser/ --ignore="/var/www/html/products/project_browser/node_modules/ , /var/www/html/products/project_browser/sveltejs/node_modules/, /var/www/html/products/project_browser/sveltejs/public/build/bundle.css"Comment #16
rajab natshahIt was hard to be sure that the right
@vartype is been used for the following properties in theclass
Comment #17
tim.plunkettI'd recommend waiting on this until after out hackathon this week. Lots of code changes in MRs that should be merged before this
Comment #18
rajab natshahNoted;
Postponed to after the hackathon this week.
I will send a new MR for phpcs fixes after that.
Anyone can do that too.
Comment #19
rajab natshahComment #20
tim.plunkettAlso I should note: I currently have the drupalci.yml set up to copy core's code checks. Core doesn't enforce full Drupal/DrupalPractice standards yet. We can of course work on improving this, but we have the bare minimum in place now.
Comment #21
rajab natshahNoticed that in:
#3238574: Add and activate Automated Testing for the Project Browser module
#3249483: Run core commit checks on code
That is better
Comment #22
chrisfromredfinShould this issue stay and be advanced, or be resolved as a duplicate then?
Comment #23
rajab natshahI'm ok with one more round after all changes
As I said in the summary
Comment #24
chrisfromredfinThe main 'sprint' work is mostly in, at least in Needs Review. It would be nice to have these standards ready to go in case we need to format the open MR's... ?
So feel free to resume on this one. :)
Comment #25
rajab natshahComment #27
rajab natshahComment #28
rajab natshahComment #29
gaurav.kapoor commentedStill, getting these errors when running PHPCS, are we planning to do changes in 2-3 commits?, is it still in WIP? or I am missing anything?
FILE: /Users/gauravkapoor/Desktop/Programming/Contribution/Drupal9/web/modules/contrib/project_browser/project_browser.module
-----------------------------------------------------------------------------------------------------------------------------
FOUND 11 ERRORS AND 2 WARNINGS AFFECTING 13 LINES
-----------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
8 | ERROR | [x] Missing function doc comment
19 | ERROR | [x] Missing function doc comment
21 | ERROR | [x] Expected one space after the comma, 0 found
24 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
31 | WARNING | [x] A comma should follow the last multiline array item. Found: '_project_browser_batch_finished'
35 | ERROR | [x] Expected 1 blank line after function; 2 found
38 | ERROR | [x] Missing function doc comment
54 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
85 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
86 | ERROR | [x] Expected 1 space(s) after cast statement; 0 found
90 | ERROR | [x] Expected 1 space after FOREACH keyword; 0 found
98 | ERROR | [x] Expected 1 newline at end of file; 0 found
-----------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 13 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------
FILE: /Users/gauravkapoor/Desktop/Programming/Contribution/Drupal9/web/modules/contrib/project_browser/README.md
----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 7 WARNINGS AFFECTING 7 LINES
----------------------------------------------------------------------------------------------------------------
19 | WARNING | Line exceeds 80 characters; contains 130 characters
60 | WARNING | Line exceeds 80 characters; contains 90 characters
61 | WARNING | Line exceeds 80 characters; contains 125 characters
62 | WARNING | Line exceeds 80 characters; contains 118 characters
64 | WARNING | Line exceeds 80 characters; contains 118 characters
65 | WARNING | Line exceeds 80 characters; contains 116 characters
66 | WARNING | Line exceeds 80 characters; contains 130 characters
----------------------------------------------------------------------------------------------------------------
FILE: /Users/gauravkapoor/Desktop/Programming/Contribution/Drupal9/web/modules/contrib/project_browser/src/DrupalOrg/DrupalOrgProject.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 101 ERRORS AFFECTING 62 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
18 | ERROR | Missing @var tag in member variable comment
20 | ERROR | Missing member variable doc comment
21 | ERROR | Missing member variable doc comment
22 | ERROR | Missing member variable doc comment
23 | ERROR | Class property $changed_ago should use lowerCamel naming without underscores
23 | ERROR | Missing member variable doc comment
24 | ERROR | Class property $field_project_images should use lowerCamel naming without underscores
24 | ERROR | Missing member variable doc comment
25 | ERROR | Missing member variable doc comment
26 | ERROR | Missing member variable doc comment
27 | ERROR | Missing member variable doc comment
28 | ERROR | Missing member variable doc comment
29 | ERROR | Missing member variable doc comment
30 | ERROR | Class property $project_usage should use lowerCamel naming without underscores
30 | ERROR | Missing member variable doc comment
31 | ERROR | Class property $project_usage_total should use lowerCamel naming without underscores
31 | ERROR | Missing member variable doc comment
32 | ERROR | Class property $field_security_advisory_coverage should use lowerCamel naming without underscores
32 | ERROR | Missing member variable doc comment
33 | ERROR | Class property $field_project_machine_name should use lowerCamel naming without underscores
33 | ERROR | Missing member variable doc comment
34 | ERROR | Class property $field_supporting_organizations should use lowerCamel naming without underscores
34 | ERROR | Missing member variable doc comment
35 | ERROR | Class property $flag_project_star_user_count should use lowerCamel naming without underscores
35 | ERROR | Missing member variable doc comment
39 | ERROR | Missing @var tag in member variable comment
40 | ERROR | Class property $taxonomy_vocabulary_3 should use lowerCamel naming without underscores
44 | ERROR | Missing @var tag in member variable comment
45 | ERROR | Class property $taxonomy_vocabulary_44 should use lowerCamel naming without underscores
49 | ERROR | Missing @var tag in member variable comment
50 | ERROR | Class property $taxonomy_vocabulary_46 should use lowerCamel naming without underscores
54 | ERROR | Missing @var tag in member variable comment
56 | ERROR | Missing member variable doc comment
57 | ERROR | Class property $edit_url should use lowerCamel naming without underscores
57 | ERROR | Missing member variable doc comment
58 | ERROR | Missing member variable doc comment
59 | ERROR | Class property $is_new should use lowerCamel naming without underscores
59 | ERROR | Missing member variable doc comment
60 | ERROR | Missing member variable doc comment
61 | ERROR | Class property $flag_project_star_user should use lowerCamel naming without underscores
61 | ERROR | Missing member variable doc comment
62 | ERROR | Class property $field_issue_summary_template should use lowerCamel naming without underscores
62 | ERROR | Missing member variable doc comment
63 | ERROR | Class property $field_replaced_by should use lowerCamel naming without underscores
63 | ERROR | Missing member variable doc comment
64 | ERROR | Class property $field_next_major_version_info should use lowerCamel naming without underscores
64 | ERROR | Missing member variable doc comment
65 | ERROR | Class property $field_project_ecosystem should use lowerCamel naming without underscores
65 | ERROR | Missing member variable doc comment
66 | ERROR | Class property $field_project_issue_version_opts should use lowerCamel naming without underscores
66 | ERROR | Missing member variable doc comment
67 | ERROR | Class property $field_project_components should use lowerCamel naming without underscores
67 | ERROR | Missing member variable doc comment
68 | ERROR | Class property $field_project_docs should use lowerCamel naming without underscores
68 | ERROR | Missing member variable doc comment
69 | ERROR | Class property $field_project_license should use lowerCamel naming without underscores
69 | ERROR | Missing member variable doc comment
70 | ERROR | Class property $field_project_screenshots should use lowerCamel naming without underscores
70 | ERROR | Missing member variable doc comment
71 | ERROR | Class property $field_project_documentation should use lowerCamel naming without underscores
71 | ERROR | Missing member variable doc comment
72 | ERROR | Class property $field_project_demo should use lowerCamel naming without underscores
72 | ERROR | Missing member variable doc comment
73 | ERROR | Missing member variable doc comment
74 | ERROR | Class property $field_project_changelog should use lowerCamel naming without underscores
74 | ERROR | Missing member variable doc comment
75 | ERROR | Class property $field_project_homepage should use lowerCamel naming without underscores
75 | ERROR | Missing member variable doc comment
76 | ERROR | Class property $field_release_version_format should use lowerCamel naming without underscores
76 | ERROR | Missing member variable doc comment
77 | ERROR | Class property $field_project_has_releases should use lowerCamel naming without underscores
77 | ERROR | Missing member variable doc comment
78 | ERROR | Class property $field_project_issue_guidelines should use lowerCamel naming without underscores
78 | ERROR | Missing member variable doc comment
79 | ERROR | Class property $field_project_default_component should use lowerCamel naming without underscores
79 | ERROR | Missing member variable doc comment
80 | ERROR | Class property $field_project_has_issue_queue should use lowerCamel naming without underscores
80 | ERROR | Missing member variable doc comment
81 | ERROR | Class property $field_project_type should use lowerCamel naming without underscores
81 | ERROR | Missing member variable doc comment
82 | ERROR | Class property $last_comment_timestamp should use lowerCamel naming without underscores
82 | ERROR | Missing member variable doc comment
83 | ERROR | Class property $has_new_content should use lowerCamel naming without underscores
83 | ERROR | Missing member variable doc comment
84 | ERROR | Class property $flag_tracker_follower_count should use lowerCamel naming without underscores
84 | ERROR | Missing member variable doc comment
85 | ERROR | Class property $feed_nid should use lowerCamel naming without underscores
85 | ERROR | Missing member variable doc comment
86 | ERROR | Class property $feeds_item_url should use lowerCamel naming without underscores
86 | ERROR | Missing member variable doc comment
87 | ERROR | Class property $feeds_item_guid should use lowerCamel naming without underscores
87 | ERROR | Missing member variable doc comment
88 | ERROR | Class property $comment_count_new should use lowerCamel naming without underscores
88 | ERROR | Missing member variable doc comment
89 | ERROR | Class property $comment_count should use lowerCamel naming without underscores
89 | ERROR | Missing member variable doc comment
90 | ERROR | Missing member variable doc comment
91 | ERROR | Missing member variable doc comment
92 | ERROR | Class property $book_ancestors should use lowerCamel naming without underscores
92 | ERROR | Missing member variable doc comment
94 | ERROR | Missing short description in doc comment
-----------------------------------------------------------------------------------------------------------------------------------------
Time: 625ms; Memory: 10MB
Comment #30
rajab natshahIn the older patch, I did them as in #16
They did not have the right
@vartype tho.But in the newer MR
Only kept JSON property mapping in the
DrupalOrgProjectclass as is.Followed with the list of fields and their types from the following link
https://www.drupal.org/api-d7/node.json?type=project_module
Types are:
The data for some fields needs custom
AbstractDataclasses which is not very clear to follow.Comment #31
rajab natshahComment #33
beatrizramos commentedNeeds work on @var type
Comment #34
fjgarlin commentedThis has evolved a lot since this issue was created. We are checking already coding standards and a few other things, so maybe we need to update the description of the issue first and see if it's still valid?
Comment #35
elberHi I couldn't to apply the changes made on the MR file, I followed this document: https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa... (see "Downloading a patch file from a merge request" section).
Comment #36
tim.plunkettThe module is now following the coding standards set by Drupal Core, and it enforced at the testbot level via drupalci.yml.
I feel that is sufficient, and this issue should be closed.
Comment #37
elberHi @tim plunkett were you able to apply the changes?
Comment #40
bnjmnmThe testbot checks code standards on every file that is changed in a given MR, so I created the
jul_2022_phpcs, which changes a testbot setting so EVERY php file is checked.Just to be 100% sure PHPCS is currently passing, I created the
jul_2022_phpcsbranch, which forces drupalci to test every PHP file.It checked a ton of files and responded with a reassuring
The code standards currently meet the drupalci testbot requirements, so we're good!
@elber there's no need to apply an MR as a patch, but I can see how the docs might lead you to believe that. You'll find it much easier to go to the "Issue Fork" area just below the issue summary, click "show commands" and copy/paste the commands to check out the branch that corresponds to the MR. Patch support still exists for legacy reasons, but it's not an everyday part of the Gitlab workflow.
It makes sense it wouldn't apply as it's based on a version of Project Browser from 7 months ago. This is a fast moving project, and many of the files that were changed no longer exist!