SlideShare a Scribd company logo
1 of 44
QUALITY CODE IN
WORDPRESS
RAN BAR-ZIK, HEWLETT PACKARD ENTERPRISE (HPE) 2016
WHO AM I
• Web developer at HPE Live Network Content Marketplace.
• Working on LAMP MEAN stacks.
• Working on WordPress since V1.5
• Owner of internet-Israel.com.
• Father of 4 children.
• @barzik
TARGET AUDIENCE
• Devs – Do it.
• People that pay devs – Demand it.
QUALITY CODE
• Fact #1 – everyone say that quality is important.
• Fact #2 – most dev doesn’t do anything to improve their
quality.
• Fact #3 – Most clients doesn’t care about quality.
• Fact #4 – Clients that does, will pay for it.
WHY DO WE NEED QUALITY?
1. maintainable.
2. robust.
3. Secured.
4. Fast.
WHO WILL NOT NEED IT
• Landing pages.
• Small scale sites.
• People that love to pay for modification of cod.
WHO WILL NEED IT
• Real products.
• Big sites (really big) that we need to maintain for a long time.
• Secured sites.
QUALITY CAN BE MEASURED
• Show Demand it:
• Your boilerplatesgenerators
• Your CI process.
• Your static analysis data.
• Your security tests results.
• Your automated tests data:
• Code coverage report
• E2E scenario
• Your performance:
• Benchmark reports.
FOUNDATION
Foundation, foundation, foundation
Good foundation prevents a lot of headache
DIFFERENCE BETWEEN DESIGN AND
FUNCTIONAL CODE
• Do not mix those!
MEET THE BOILERPLATES FOR THEMES AND
PLUGINS
• The leading boilerplate for plugins is:
https://github.com/DevinVinson/WordPress-Plugin-Boilerplate
[Or just search WordPress plugin boilerplate]
WHY IT IS BEST TO USE BOILERPLATE?
• Based on experience of 59 contributors.
• Updated frequently.
• OOP, made with the best practices.
USE SASS OR LESS IN YOUR TEMPLATES
• Much easier to maintain (if it is a big website or something that
will be maintained and developed for a long time).
• All modern web products built with it.
• All CSS frameworks compiled from it.
WRITING GOOD CODE
WORDPRESS CODING STANDARDS
• Created by Matt Mullenweg himself.
• For PHP, CSS, JavaScript and HTML.
• Can be found it WordPress Core developer’s handbook
WHY DO WE NEED IT?
• avoid common coding errors
• improve the readability of code
• simplify modification
They ensure that files within the project appear as if they were
created by a single person.
MEET STATIC CODE ANALYSIS FOR PHP–
PHPCS
• PHP_CodeSniffer module.
• Can be installed with pear.
• Will test WordPress code combined with WordPress-Coding-
Standards plugin.
INSTALL IS EASY
> pear install PHP_CodeSniffer
> phpcs -i
The installed coding standards are PHPCS, Squiz, PSR2, MySource,
PEAR, Zend and PSR1
> cd c:wpcs
> git clone -b master https://github.com/WordPress-Coding-
Standards/WordPress-Coding-Standards.git wpcs
> phpcs --config-set installed_paths c:pathtowpcs
> phpcs -i
The installed coding standards are PHPCS, Squiz, PSR2, MySource,
PEAR, Zend, PSR1, WordPress, WordPress-VIP, WordPress-Core,
WordPress-Docs and WordPress-Extra
RUNNING PHPCS + WORDPRESS IS EASY
FILE: /var/www/html/github/wp-notice/tests/bootstrap.php
----------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 5 LINES
----------------------------------------------------------------------
2 | ERROR | [ ] Missing file doc comment
4 | ERROR | [x] First condition of a multi-line IF statement must
| | directly follow the opening parenthesis
19 | ERROR | [ ] Missing function doc comment
19 | ERROR | [ ] Function name "_manually_load_plugin" is invalid;
| | only private methods should be prefixed with an
| | underscore
21 | ERROR | [x] File is being conditionally included; use "include"
| | instead
22 | ERROR | [x] File is being conditionally included; use "include"
| | instead
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
MORE DATA ON INSTALLING CAN BE
FOUND HERE;
• https://internet-israel.com/?p=5980
MEET JAVASCRIPT CODING STANDARDS
• Jshint or eslint (I prefer eslint).
• Working with npm directly from the command line.
• Working with gruntgulp.
YOU CAN DO STATIC CODE ANALYSIS ON
EVERYTHING
• SCSSlint will test your SCSS code against code standards.
• HTML linters will lint your HTML templates.
All can be run from console or with gruntgulp.
SECURITY STATIC TEXT ANALYSIS
• phpcs is testing against CSRF, XSS and SQL injection.
• Use watchtower static code analysis tools to highlight code
issues.
FORGET ALL THE CONSOLE COMMANDS!
USE GRUNT OR GULP
Use task runner
> phpcs --standard=WordPress ./**/*.php
> eslint -c ~/my-eslint.json ./**/*.js
> scss-lint ./**/*.css.scss
JAVASCRIPT TASKS RUNNER WILL HELP YOU
RUN EVERYTHING!
• Create a build process for WordPress.
• Orchestrate all static code analysis.
• Print out a report.
• Do it on local or on remote!
PRO TIPS
• Using intellij? There is native support of WordPress coding
conventions in PHP, JS or HTML
• Tie in the gruntgulp with githooks or SVN hooks.
AUTOMATED TESTING
• Help fight regression.
• Help verifying that everything will work against new versions of
WordPress.
• Help testing it in different version of PHP, Linux updates, etc.
UNIT TESTING
• Unit testing tests the code it self, functions, class, etc.,
• It should be separated from 3rd party and emulating those.
PHP UNIT TESTING
• PHP unit testing is done by PHPUnit + WordPress Develop.
• WordPress develop is like all WordPress + automated tests suite
that you can mount plugin and template to.
• Mounting is easy with this example:
https://github.com/tierra/wordpress-plugin-tests
It is done by ONE XML file and ONE bootstrap PHP
JAVASCRIPT UNIT TESTING
• In WordPress it is done by Qunit, but there are a lot of
JavaScript testing framework and runner.
• I use karma runner + Jasmine Mocha.
MEASURING THE AUTOMATIC TESTS
• Meet coverage report!
• Generate it by small tweaks to the XML of the phpUnit
ANALYZE THE PHPUNIT CODE COVERAGE
REPORT
SOME TIPS REGARDING COVERAGE REPORT
• You cannot achieve 100%
• Google engineers stated that above 85% is more than enough.
• Branches are very important.
• Demand minimum coverage!
END TO END TESTS
• Emulate users
• Done against mock database sandbox 3rd party API
• Done on multiple browsers
LEADING TOOLS
• Selenium (easy to custom & install & to run, limited
functionality)
• LeanFT (Easy to install & run, full functionality, costs money)
TESTING CAN BE RUN ON DIFFERENT
ENVIRONMENTS
• You can run The testing on every WordPress dev version that
you want.4
• You can orchestrate those with automatic build process.
MEET WORDPRESS BUILD PROCESS
BUILD SYSTEMS
• Travis is used for CI – it is fast to work with, very easy to set up
and work with WordPress.
• Jenkins is CICD tool and it is quite complicated and require
devop knowledge.
TRAVIS CI REPORT
PERFORMANCE
• Performance can be tested and measured by several tools.
• Meet apache benchmark.
• Easy to install and run (on Linux)
ab -n 100 -c 5 http://mysite.dev/?p=10
C is concurrent user,
n is number of pings.
PERFORMANCE REPORT
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 2.1 0 11
Processing: 733 5078 1515.8 4786 13425
Waiting: 599 4097 1138.2 3871 11915
Total: 735 5079 1515.6 4786 13435
More information on report
can be found at my site:
SUMMARY
• Quality does not mean anything without defining means to
achieve it.
There is HUGE difference between saying “My product is in the
best quality” and “My product is based on the most modern
boilerplates, using SASS, tested with static code analysis for
standards and security and have more than 70% coverage”.
• Some quality is better than no quality.
CONNECT WITH ME!
• Just search “Ran Bar-Zik” On Facebook, Twitter, LinkedIn or
GitHub :)
Q&A

More Related Content

What's hot

Drupal Continuous Integration (European Drupal Days 2015)
Drupal Continuous Integration (European Drupal Days 2015)Drupal Continuous Integration (European Drupal Days 2015)
Drupal Continuous Integration (European Drupal Days 2015)Eugenio Minardi
 
DevOpsDays Singapore Habitat Ignite
DevOpsDays Singapore Habitat IgniteDevOpsDays Singapore Habitat Ignite
DevOpsDays Singapore Habitat IgniteMatt Ray
 
Drupal Continuous Integration with Jenkins - Deploy
Drupal Continuous Integration with Jenkins - DeployDrupal Continuous Integration with Jenkins - Deploy
Drupal Continuous Integration with Jenkins - DeployJohn Smith
 
Effective Testing with Ansible and InSpec
Effective Testing with Ansible and InSpecEffective Testing with Ansible and InSpec
Effective Testing with Ansible and InSpecNathen Harvey
 
Drupal Continuous Integration and devops - Beyond Jenkins
Drupal Continuous Integration and devops - Beyond JenkinsDrupal Continuous Integration and devops - Beyond Jenkins
Drupal Continuous Integration and devops - Beyond JenkinsPromet Source
 
Developing better PHP projects
Developing better PHP projectsDeveloping better PHP projects
Developing better PHP projectsMohammad Emran Hasan
 
Continuous delivery with open source tools
Continuous delivery with open source toolsContinuous delivery with open source tools
Continuous delivery with open source toolsSebastian Helzle
 
Bay Area Chef Meetup February
Bay Area Chef Meetup FebruaryBay Area Chef Meetup February
Bay Area Chef Meetup FebruaryJessica DeVita
 
Continuous integration using Jenkins and Sonar
Continuous integration using Jenkins and SonarContinuous integration using Jenkins and Sonar
Continuous integration using Jenkins and SonarPascal Larocque
 
Continuous delivery made
Continuous delivery madeContinuous delivery made
Continuous delivery mademimmozzo_
 
JUC Europe 2015: Continuous Integration and Distribution in the Cloud with DE...
JUC Europe 2015: Continuous Integration and Distribution in the Cloud with DE...JUC Europe 2015: Continuous Integration and Distribution in the Cloud with DE...
JUC Europe 2015: Continuous Integration and Distribution in the Cloud with DE...CloudBees
 
Infrastructure and Compliance Delight with Chef Automate
Infrastructure and Compliance Delight with Chef AutomateInfrastructure and Compliance Delight with Chef Automate
Infrastructure and Compliance Delight with Chef AutomateMatt Ray
 
Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)Paul Jones
 
Infrastructure as Code for Network
Infrastructure as Code for NetworkInfrastructure as Code for Network
Infrastructure as Code for NetworkDamien Garros
 
Take your CFML Legacy Apps to Modernization
Take your CFML Legacy Apps to ModernizationTake your CFML Legacy Apps to Modernization
Take your CFML Legacy Apps to ModernizationOrtus Solutions, Corp
 
An Attacker's View of Serverless and GraphQL Apps - Abhay Bhargav - AppSec Ca...
An Attacker's View of Serverless and GraphQL Apps - Abhay Bhargav - AppSec Ca...An Attacker's View of Serverless and GraphQL Apps - Abhay Bhargav - AppSec Ca...
An Attacker's View of Serverless and GraphQL Apps - Abhay Bhargav - AppSec Ca...Abhay Bhargav
 
Using Habitat to Unify Dev to CI to Production - Configmgmt Camp Feb/2018 Gent
Using Habitat to Unify Dev to CI to Production - Configmgmt Camp Feb/2018 GentUsing Habitat to Unify Dev to CI to Production - Configmgmt Camp Feb/2018 Gent
Using Habitat to Unify Dev to CI to Production - Configmgmt Camp Feb/2018 GentSalim Afiune Maya
 
Michigan IT Symposium 2017 - CI/CD Workflow Tutorial
Michigan IT Symposium 2017 - CI/CD Workflow TutorialMichigan IT Symposium 2017 - CI/CD Workflow Tutorial
Michigan IT Symposium 2017 - CI/CD Workflow TutorialJeffrey Sica
 

What's hot (20)

Drupal Continuous Integration (European Drupal Days 2015)
Drupal Continuous Integration (European Drupal Days 2015)Drupal Continuous Integration (European Drupal Days 2015)
Drupal Continuous Integration (European Drupal Days 2015)
 
DevOpsDays Singapore Habitat Ignite
DevOpsDays Singapore Habitat IgniteDevOpsDays Singapore Habitat Ignite
DevOpsDays Singapore Habitat Ignite
 
Drupal Continuous Integration with Jenkins - Deploy
Drupal Continuous Integration with Jenkins - DeployDrupal Continuous Integration with Jenkins - Deploy
Drupal Continuous Integration with Jenkins - Deploy
 
Effective Testing with Ansible and InSpec
Effective Testing with Ansible and InSpecEffective Testing with Ansible and InSpec
Effective Testing with Ansible and InSpec
 
Calabash
CalabashCalabash
Calabash
 
Drupal Continuous Integration and devops - Beyond Jenkins
Drupal Continuous Integration and devops - Beyond JenkinsDrupal Continuous Integration and devops - Beyond Jenkins
Drupal Continuous Integration and devops - Beyond Jenkins
 
Developing better PHP projects
Developing better PHP projectsDeveloping better PHP projects
Developing better PHP projects
 
Continuous delivery with open source tools
Continuous delivery with open source toolsContinuous delivery with open source tools
Continuous delivery with open source tools
 
Becoming A Php Ninja
Becoming A Php NinjaBecoming A Php Ninja
Becoming A Php Ninja
 
Bay Area Chef Meetup February
Bay Area Chef Meetup FebruaryBay Area Chef Meetup February
Bay Area Chef Meetup February
 
Continuous integration using Jenkins and Sonar
Continuous integration using Jenkins and SonarContinuous integration using Jenkins and Sonar
Continuous integration using Jenkins and Sonar
 
Continuous delivery made
Continuous delivery madeContinuous delivery made
Continuous delivery made
 
JUC Europe 2015: Continuous Integration and Distribution in the Cloud with DE...
JUC Europe 2015: Continuous Integration and Distribution in the Cloud with DE...JUC Europe 2015: Continuous Integration and Distribution in the Cloud with DE...
JUC Europe 2015: Continuous Integration and Distribution in the Cloud with DE...
 
Infrastructure and Compliance Delight with Chef Automate
Infrastructure and Compliance Delight with Chef AutomateInfrastructure and Compliance Delight with Chef Automate
Infrastructure and Compliance Delight with Chef Automate
 
Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)
 
Infrastructure as Code for Network
Infrastructure as Code for NetworkInfrastructure as Code for Network
Infrastructure as Code for Network
 
Take your CFML Legacy Apps to Modernization
Take your CFML Legacy Apps to ModernizationTake your CFML Legacy Apps to Modernization
Take your CFML Legacy Apps to Modernization
 
An Attacker's View of Serverless and GraphQL Apps - Abhay Bhargav - AppSec Ca...
An Attacker's View of Serverless and GraphQL Apps - Abhay Bhargav - AppSec Ca...An Attacker's View of Serverless and GraphQL Apps - Abhay Bhargav - AppSec Ca...
An Attacker's View of Serverless and GraphQL Apps - Abhay Bhargav - AppSec Ca...
 
Using Habitat to Unify Dev to CI to Production - Configmgmt Camp Feb/2018 Gent
Using Habitat to Unify Dev to CI to Production - Configmgmt Camp Feb/2018 GentUsing Habitat to Unify Dev to CI to Production - Configmgmt Camp Feb/2018 Gent
Using Habitat to Unify Dev to CI to Production - Configmgmt Camp Feb/2018 Gent
 
Michigan IT Symposium 2017 - CI/CD Workflow Tutorial
Michigan IT Symposium 2017 - CI/CD Workflow TutorialMichigan IT Symposium 2017 - CI/CD Workflow Tutorial
Michigan IT Symposium 2017 - CI/CD Workflow Tutorial
 

Similar to Quality code in wordpress

Continuous Integration at Mollie
Continuous Integration at MollieContinuous Integration at Mollie
Continuous Integration at Molliewillemstuursma
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 
Standardizing and Managing Your Infrastructure - MOSC 2011
Standardizing and Managing Your Infrastructure - MOSC 2011Standardizing and Managing Your Infrastructure - MOSC 2011
Standardizing and Managing Your Infrastructure - MOSC 2011Brian Ritchie
 
Production ready word press
Production ready word pressProduction ready word press
Production ready word pressEdmund Turbin
 
Production Ready WordPress #WPLDN
Production Ready WordPress #WPLDNProduction Ready WordPress #WPLDN
Production Ready WordPress #WPLDNEdmund Turbin
 
Production Ready WordPress - WC Utrecht 2017
Production Ready WordPress  - WC Utrecht 2017Production Ready WordPress  - WC Utrecht 2017
Production Ready WordPress - WC Utrecht 2017Edmund Turbin
 
Compliance Automation with InSpec - Chef NYC Meetup - April 2017
Compliance Automation with InSpec - Chef NYC Meetup - April 2017Compliance Automation with InSpec - Chef NYC Meetup - April 2017
Compliance Automation with InSpec - Chef NYC Meetup - April 2017adamleff
 
Achieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateAchieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateChef
 
Magento 2 Workflows
Magento 2 WorkflowsMagento 2 Workflows
Magento 2 WorkflowsRyan Street
 
InSpec Workflow for DevOpsDays Riga 2017
InSpec Workflow for DevOpsDays Riga 2017InSpec Workflow for DevOpsDays Riga 2017
InSpec Workflow for DevOpsDays Riga 2017Mandi Walls
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsAmazon Web Services
 
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...DevOpsDays Riga
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterpriseTaylor Lovett
 
we45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Pythonwe45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with PythonAbhay Bhargav
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseTaylor Lovett
 
Prescriptive System Security with InSpec
Prescriptive System Security with InSpecPrescriptive System Security with InSpec
Prescriptive System Security with InSpecAll Things Open
 
Prescriptive Security with InSpec - All Things Open 2019
Prescriptive Security with InSpec - All Things Open 2019Prescriptive Security with InSpec - All Things Open 2019
Prescriptive Security with InSpec - All Things Open 2019Mandi Walls
 
Using Chef InSpec for Infrastructure Security
Using Chef InSpec for Infrastructure SecurityUsing Chef InSpec for Infrastructure Security
Using Chef InSpec for Infrastructure SecurityMandi Walls
 
DevOps and AWS - Code PaLOUsa 2017
DevOps and AWS  - Code PaLOUsa 2017DevOps and AWS  - Code PaLOUsa 2017
DevOps and AWS - Code PaLOUsa 2017James Strong
 
Adding Security and Compliance to Your Workflow with InSpec
Adding Security and Compliance to Your Workflow with InSpecAdding Security and Compliance to Your Workflow with InSpec
Adding Security and Compliance to Your Workflow with InSpecMandi Walls
 

Similar to Quality code in wordpress (20)

Continuous Integration at Mollie
Continuous Integration at MollieContinuous Integration at Mollie
Continuous Integration at Mollie
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Standardizing and Managing Your Infrastructure - MOSC 2011
Standardizing and Managing Your Infrastructure - MOSC 2011Standardizing and Managing Your Infrastructure - MOSC 2011
Standardizing and Managing Your Infrastructure - MOSC 2011
 
Production ready word press
Production ready word pressProduction ready word press
Production ready word press
 
Production Ready WordPress #WPLDN
Production Ready WordPress #WPLDNProduction Ready WordPress #WPLDN
Production Ready WordPress #WPLDN
 
Production Ready WordPress - WC Utrecht 2017
Production Ready WordPress  - WC Utrecht 2017Production Ready WordPress  - WC Utrecht 2017
Production Ready WordPress - WC Utrecht 2017
 
Compliance Automation with InSpec - Chef NYC Meetup - April 2017
Compliance Automation with InSpec - Chef NYC Meetup - April 2017Compliance Automation with InSpec - Chef NYC Meetup - April 2017
Compliance Automation with InSpec - Chef NYC Meetup - April 2017
 
Achieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef AutomateAchieving DevOps Success with Chef Automate
Achieving DevOps Success with Chef Automate
 
Magento 2 Workflows
Magento 2 WorkflowsMagento 2 Workflows
Magento 2 Workflows
 
InSpec Workflow for DevOpsDays Riga 2017
InSpec Workflow for DevOpsDays Riga 2017InSpec Workflow for DevOpsDays Riga 2017
InSpec Workflow for DevOpsDays Riga 2017
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
 
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
 
we45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Pythonwe45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Python
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
 
Prescriptive System Security with InSpec
Prescriptive System Security with InSpecPrescriptive System Security with InSpec
Prescriptive System Security with InSpec
 
Prescriptive Security with InSpec - All Things Open 2019
Prescriptive Security with InSpec - All Things Open 2019Prescriptive Security with InSpec - All Things Open 2019
Prescriptive Security with InSpec - All Things Open 2019
 
Using Chef InSpec for Infrastructure Security
Using Chef InSpec for Infrastructure SecurityUsing Chef InSpec for Infrastructure Security
Using Chef InSpec for Infrastructure Security
 
DevOps and AWS - Code PaLOUsa 2017
DevOps and AWS  - Code PaLOUsa 2017DevOps and AWS  - Code PaLOUsa 2017
DevOps and AWS - Code PaLOUsa 2017
 
Adding Security and Compliance to Your Workflow with InSpec
Adding Security and Compliance to Your Workflow with InSpecAdding Security and Compliance to Your Workflow with InSpec
Adding Security and Compliance to Your Workflow with InSpec
 

More from Ran Bar-Zik

How to track users
How to track usersHow to track users
How to track usersRan Bar-Zik
 
7 deadly front end sins
7 deadly front end sins7 deadly front end sins
7 deadly front end sinsRan Bar-Zik
 
Javascript static code analysis
Javascript static code analysisJavascript static code analysis
Javascript static code analysisRan Bar-Zik
 
How to get your first job at the Israeli high tech industry
How to get your first job at the Israeli high tech industryHow to get your first job at the Israeli high tech industry
How to get your first job at the Israeli high tech industryRan Bar-Zik
 
WordPress Security 101 for developers
WordPress Security 101 for developersWordPress Security 101 for developers
WordPress Security 101 for developersRan Bar-Zik
 
Javascript Security - Three main methods of defending your MEAN stack
Javascript Security - Three main methods of defending your MEAN stackJavascript Security - Three main methods of defending your MEAN stack
Javascript Security - Three main methods of defending your MEAN stackRan Bar-Zik
 
WordPress automation and CI
WordPress automation and CIWordPress automation and CI
WordPress automation and CIRan Bar-Zik
 
Drupal Security
Drupal SecurityDrupal Security
Drupal SecurityRan Bar-Zik
 
Presentation skills - course example
Presentation skills - course examplePresentation skills - course example
Presentation skills - course exampleRan Bar-Zik
 
HTML5 for dummies
HTML5 for dummiesHTML5 for dummies
HTML5 for dummiesRan Bar-Zik
 
Basic web dveleopers terms for UX and graphic designers
Basic web dveleopers terms for UX and graphic designersBasic web dveleopers terms for UX and graphic designers
Basic web dveleopers terms for UX and graphic designersRan Bar-Zik
 
HTML55 media api
HTML55 media apiHTML55 media api
HTML55 media apiRan Bar-Zik
 
Features in Drupal 7/6
Features in Drupal 7/6Features in Drupal 7/6
Features in Drupal 7/6Ran Bar-Zik
 

More from Ran Bar-Zik (13)

How to track users
How to track usersHow to track users
How to track users
 
7 deadly front end sins
7 deadly front end sins7 deadly front end sins
7 deadly front end sins
 
Javascript static code analysis
Javascript static code analysisJavascript static code analysis
Javascript static code analysis
 
How to get your first job at the Israeli high tech industry
How to get your first job at the Israeli high tech industryHow to get your first job at the Israeli high tech industry
How to get your first job at the Israeli high tech industry
 
WordPress Security 101 for developers
WordPress Security 101 for developersWordPress Security 101 for developers
WordPress Security 101 for developers
 
Javascript Security - Three main methods of defending your MEAN stack
Javascript Security - Three main methods of defending your MEAN stackJavascript Security - Three main methods of defending your MEAN stack
Javascript Security - Three main methods of defending your MEAN stack
 
WordPress automation and CI
WordPress automation and CIWordPress automation and CI
WordPress automation and CI
 
Drupal Security
Drupal SecurityDrupal Security
Drupal Security
 
Presentation skills - course example
Presentation skills - course examplePresentation skills - course example
Presentation skills - course example
 
HTML5 for dummies
HTML5 for dummiesHTML5 for dummies
HTML5 for dummies
 
Basic web dveleopers terms for UX and graphic designers
Basic web dveleopers terms for UX and graphic designersBasic web dveleopers terms for UX and graphic designers
Basic web dveleopers terms for UX and graphic designers
 
HTML55 media api
HTML55 media apiHTML55 media api
HTML55 media api
 
Features in Drupal 7/6
Features in Drupal 7/6Features in Drupal 7/6
Features in Drupal 7/6
 

Recently uploaded

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 

Recently uploaded (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 

Quality code in wordpress

  • 1. QUALITY CODE IN WORDPRESS RAN BAR-ZIK, HEWLETT PACKARD ENTERPRISE (HPE) 2016
  • 2. WHO AM I • Web developer at HPE Live Network Content Marketplace. • Working on LAMP MEAN stacks. • Working on WordPress since V1.5 • Owner of internet-Israel.com. • Father of 4 children. • @barzik
  • 3. TARGET AUDIENCE • Devs – Do it. • People that pay devs – Demand it.
  • 4. QUALITY CODE • Fact #1 – everyone say that quality is important. • Fact #2 – most dev doesn’t do anything to improve their quality. • Fact #3 – Most clients doesn’t care about quality. • Fact #4 – Clients that does, will pay for it.
  • 5. WHY DO WE NEED QUALITY? 1. maintainable. 2. robust. 3. Secured. 4. Fast.
  • 6. WHO WILL NOT NEED IT • Landing pages. • Small scale sites. • People that love to pay for modification of cod.
  • 7. WHO WILL NEED IT • Real products. • Big sites (really big) that we need to maintain for a long time. • Secured sites.
  • 8. QUALITY CAN BE MEASURED • Show Demand it: • Your boilerplatesgenerators • Your CI process. • Your static analysis data. • Your security tests results. • Your automated tests data: • Code coverage report • E2E scenario • Your performance: • Benchmark reports.
  • 9. FOUNDATION Foundation, foundation, foundation Good foundation prevents a lot of headache
  • 10. DIFFERENCE BETWEEN DESIGN AND FUNCTIONAL CODE • Do not mix those!
  • 11. MEET THE BOILERPLATES FOR THEMES AND PLUGINS • The leading boilerplate for plugins is: https://github.com/DevinVinson/WordPress-Plugin-Boilerplate [Or just search WordPress plugin boilerplate]
  • 12. WHY IT IS BEST TO USE BOILERPLATE? • Based on experience of 59 contributors. • Updated frequently. • OOP, made with the best practices.
  • 13. USE SASS OR LESS IN YOUR TEMPLATES • Much easier to maintain (if it is a big website or something that will be maintained and developed for a long time). • All modern web products built with it. • All CSS frameworks compiled from it.
  • 15. WORDPRESS CODING STANDARDS • Created by Matt Mullenweg himself. • For PHP, CSS, JavaScript and HTML. • Can be found it WordPress Core developer’s handbook
  • 16. WHY DO WE NEED IT? • avoid common coding errors • improve the readability of code • simplify modification They ensure that files within the project appear as if they were created by a single person.
  • 17. MEET STATIC CODE ANALYSIS FOR PHP– PHPCS • PHP_CodeSniffer module. • Can be installed with pear. • Will test WordPress code combined with WordPress-Coding- Standards plugin.
  • 18. INSTALL IS EASY > pear install PHP_CodeSniffer > phpcs -i The installed coding standards are PHPCS, Squiz, PSR2, MySource, PEAR, Zend and PSR1 > cd c:wpcs > git clone -b master https://github.com/WordPress-Coding- Standards/WordPress-Coding-Standards.git wpcs > phpcs --config-set installed_paths c:pathtowpcs > phpcs -i The installed coding standards are PHPCS, Squiz, PSR2, MySource, PEAR, Zend, PSR1, WordPress, WordPress-VIP, WordPress-Core, WordPress-Docs and WordPress-Extra
  • 19. RUNNING PHPCS + WORDPRESS IS EASY FILE: /var/www/html/github/wp-notice/tests/bootstrap.php ---------------------------------------------------------------------- FOUND 6 ERRORS AFFECTING 5 LINES ---------------------------------------------------------------------- 2 | ERROR | [ ] Missing file doc comment 4 | ERROR | [x] First condition of a multi-line IF statement must | | directly follow the opening parenthesis 19 | ERROR | [ ] Missing function doc comment 19 | ERROR | [ ] Function name "_manually_load_plugin" is invalid; | | only private methods should be prefixed with an | | underscore 21 | ERROR | [x] File is being conditionally included; use "include" | | instead 22 | ERROR | [x] File is being conditionally included; use "include" | | instead ---------------------------------------------------------------------- PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY ----------------------------------------------------------------------
  • 20. MORE DATA ON INSTALLING CAN BE FOUND HERE; • https://internet-israel.com/?p=5980
  • 21. MEET JAVASCRIPT CODING STANDARDS • Jshint or eslint (I prefer eslint). • Working with npm directly from the command line. • Working with gruntgulp.
  • 22. YOU CAN DO STATIC CODE ANALYSIS ON EVERYTHING • SCSSlint will test your SCSS code against code standards. • HTML linters will lint your HTML templates. All can be run from console or with gruntgulp.
  • 23. SECURITY STATIC TEXT ANALYSIS • phpcs is testing against CSRF, XSS and SQL injection. • Use watchtower static code analysis tools to highlight code issues.
  • 24. FORGET ALL THE CONSOLE COMMANDS! USE GRUNT OR GULP Use task runner > phpcs --standard=WordPress ./**/*.php > eslint -c ~/my-eslint.json ./**/*.js > scss-lint ./**/*.css.scss
  • 25. JAVASCRIPT TASKS RUNNER WILL HELP YOU RUN EVERYTHING! • Create a build process for WordPress. • Orchestrate all static code analysis. • Print out a report. • Do it on local or on remote!
  • 26. PRO TIPS • Using intellij? There is native support of WordPress coding conventions in PHP, JS or HTML • Tie in the gruntgulp with githooks or SVN hooks.
  • 27. AUTOMATED TESTING • Help fight regression. • Help verifying that everything will work against new versions of WordPress. • Help testing it in different version of PHP, Linux updates, etc.
  • 28. UNIT TESTING • Unit testing tests the code it self, functions, class, etc., • It should be separated from 3rd party and emulating those.
  • 29. PHP UNIT TESTING • PHP unit testing is done by PHPUnit + WordPress Develop. • WordPress develop is like all WordPress + automated tests suite that you can mount plugin and template to. • Mounting is easy with this example: https://github.com/tierra/wordpress-plugin-tests It is done by ONE XML file and ONE bootstrap PHP
  • 30. JAVASCRIPT UNIT TESTING • In WordPress it is done by Qunit, but there are a lot of JavaScript testing framework and runner. • I use karma runner + Jasmine Mocha.
  • 31. MEASURING THE AUTOMATIC TESTS • Meet coverage report! • Generate it by small tweaks to the XML of the phpUnit
  • 32. ANALYZE THE PHPUNIT CODE COVERAGE REPORT
  • 33. SOME TIPS REGARDING COVERAGE REPORT • You cannot achieve 100% • Google engineers stated that above 85% is more than enough. • Branches are very important. • Demand minimum coverage!
  • 34. END TO END TESTS • Emulate users • Done against mock database sandbox 3rd party API • Done on multiple browsers
  • 35. LEADING TOOLS • Selenium (easy to custom & install & to run, limited functionality) • LeanFT (Easy to install & run, full functionality, costs money)
  • 36. TESTING CAN BE RUN ON DIFFERENT ENVIRONMENTS • You can run The testing on every WordPress dev version that you want.4 • You can orchestrate those with automatic build process.
  • 38. BUILD SYSTEMS • Travis is used for CI – it is fast to work with, very easy to set up and work with WordPress. • Jenkins is CICD tool and it is quite complicated and require devop knowledge.
  • 40. PERFORMANCE • Performance can be tested and measured by several tools. • Meet apache benchmark. • Easy to install and run (on Linux) ab -n 100 -c 5 http://mysite.dev/?p=10 C is concurrent user, n is number of pings.
  • 41. PERFORMANCE REPORT Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 2.1 0 11 Processing: 733 5078 1515.8 4786 13425 Waiting: 599 4097 1138.2 3871 11915 Total: 735 5079 1515.6 4786 13435 More information on report can be found at my site:
  • 42. SUMMARY • Quality does not mean anything without defining means to achieve it. There is HUGE difference between saying “My product is in the best quality” and “My product is based on the most modern boilerplates, using SASS, tested with static code analysis for standards and security and have more than 70% coverage”. • Some quality is better than no quality.
  • 43. CONNECT WITH ME! • Just search “Ran Bar-Zik” On Facebook, Twitter, LinkedIn or GitHub :)
  • 44. Q&A