Automated testing now reports on coding standards violations - see #1299710: [meta] Automate the coding-standards part of patch review. Any file which is altered by a patch gets a full list of standards faults, not just in the lines which are altered by the patch.
Here's an example from a patch which changed .module
It will be helpful if we gradually fix these faults over the entire Scheduler 8.x codebase. I think it is better to fix the standards separately from other bug-fix patches, so that the commit details do not get confusing by altering lines which are not related to the actual issue being addressed. The full dev branch test indicates that we have 553 coding standards faults (as at 19 March 2017). Takling all at once is too big a task, so maybe file by file, or groups of related files, using this issue to test and track the progress.
Comment | File | Size | Author |
---|
Comments
Comment #2
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHere's the first patch - just for the .module file.
Interestingly the full daily testing includes messages about requiring short array syntax, but the individual patch testing does not have these.
Comment #3
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedNot sure if this is right, but I've added
use Drupal\node\Entity\NodeType;
to fix the warning regarding line 495:$node_types = \Drupal\node\Entity\NodeType::loadMultiple();
Comment #4
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedGetting there.
Comment #6
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThe test output in https://www.drupal.org/pift-ci-job/626021 is empty for coding standards problems so I have committed these changes. It will be useful to see what the full -dev test shows for .module and whether it agrees that the file is clean.
[edit] Ha, I missed one array()
Comment #8
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedscheduler.module is now clean. Overall count reduced by 32, from 553 to 521.
I wonder why the short array syntax messages are not included in patch testing but are part of the standard and are included in the overall -dev daily/on commit tests. Bit annoying as it leads to more work if you miss one.
Comment #10
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThe next four files README.txt, /plugins/content_types/scheduler_form_pane.inc, /scheduler.admin.inc and /scheduler.api.php are now clean. Down to 468 coding messages in total.
Also using
phpcs --standard=DrupalPractice
it showed that there was an unused variable $entity in scheduler.module which I have now removed.Comment #12
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThe above commit for .drush.inc, .install, .tokens.inc, .views.inc and scheduler_handler_field_scheduler_countdown.inc take the violations count down to 398. All files in the root /scheduler directory are now clean.
Now going to work on the /scheduler_rules_integration folder files
Comment #14
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedNow down to 266 coding messages. All files in the module root folder are clean. Now going to do the
/tests
folder.Comment #19
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedNow only 49 coding standards violations remaining. All in
/src
files.Comment #21
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedNow we have zero coding standards violations. The entire Scheduler codebase is clean. Here is the output from
phpcs
with the file names removed.I have also run
phpcsp
to check and clean up Drupal Best Practice violations. There were hundreds of these but now just 25 warnings over 7 files. Apart from the 'dependencies' prefix in .info.yml which is not possible to fix for contrib modules all of the remaining 'best practice' warnings have @TODO notes marking them as needing fixing. It was out of scope to do those in this issue and will be followed up separately.Comment #22
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedFor the record, here is the checkstyle output from 19 March before any corrections - 553 warnings
https://dispatcher.drupalci.org/job/drupal_contrib/20253/checkstyleResult/
28th March after fixing all files in root folder and rules_integration, down to 266 warnings
https://dispatcher.drupalci.org/job/drupal_contrib/24228/checkstyleResult/
30th March after fixing /tests, down to 49 warnings
https://dispatcher.drupalci.org/job/drupal_contrib/25141/checkstyleResult/
Now all clean - if there are no warnings you do not get a separate output, just "Checkstyle: 0 warnings from one analysis" on the build front page
https://dispatcher.drupalci.org/job/drupal_contrib/25156/
Comment #23
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedI have raised #2868553: Fix the code to adhere to Drupal Best Practice as a follow-up. Our 8.x codebase is clean for the current set of coding standards so marking this issue fixed. Another follow-up for 7.x coding standards could be started, as the rules have changed since we last cleaned the 7.x code.
Comment #24
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedFor the record, here are screen shots of the test output and build output - in case these become unavailable on the links above.
Comment #26
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedFollowing from #3002206-37: Update the stable version of drupal/coder to ˆ8.3.1 Scheduler shows the same problem in the drupalci console
https://dispatcher.drupalci.org/job/drupal8_contrib_patches/53370/console
Here is a patch which creates coding standards fault - it will be useful to see if these are reported on d.o. now.
Comment #27
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commented"Needs Review" to allow patch testing
Comment #28
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedA fix has been applied to drupalci - see #3002206-44: Update the stable version of drupal/coder to ˆ8.3.1 and we no longer get the conflict, and hence coding standards are now being checked again.