SlideShare a Scribd company logo
1 of 13
CodeIgniter Code Sniffer
Topic Code Sniffer The ins and out of making sure your code is up to a standard of your choosing.
INTRODUCTION In our days we have come to code to our own way. Many of us have preferences of tabs to spaces, how we name public and private variables. Whether to use CamelCases or Underscores.  I myself have been a more code as I code and go back to clean up later, be it with documentation, notes, and how my code is presented. Many like myself want to make sure that All of our codebase is the same format, but we don't want to manually run through them. That could be so tedious and repetitive that one can take a whole other development cycle to just review the code they have written. Luckily there is a pear package we can use to alleviate the stress, this package is called PhpCodeSniffer.
INSTALLING PHP CODE SNIFFER  To Install PhpCodeSniffer, follow these steps: Go to your command line and enter the following: pear install PHP_CodeSniffer Then enter Phpcs –ito see the installed Coding Standards
ABOUT CODE SNIFFER Code Sniffer is used by many Open Source and Private development teams.  Code Sniffer can sniff any file or directory you wish.  Once it has finished Sniffing you will find a detailed report on all the files you have tested.  Also CodeSniffer comes with the prepackaged coding standards (PEAR, Squiz, PHPCS and Zend	), I personally follow the Zend Coding Standards, but you can also customize and create your own coding standard taking bits from all over.
CODE SNIFFER RESPONSE Bellow is a typical report for a CodeSniff. FILE: /home/lorna/phpcs/recipe.class.php -------------------------------------------------------------------------------- FOUND 3 ERROR(S) AND 0 WARNING(S) AFFECTING 3 LINE(S) -------------------------------------------------------------------------------- 10 | ERROR | Variable "prep_time" is not in valid camel caps format 13 | ERROR | Spaces must be used to indent lines; tabs are not allowed 17 | ERROR | A closing tag is not permitted at the end of a PHP file --------------------------------------------------------------------------------
HOW TO USE CODE SNIFFER Code Sniffer is run via command line, so if needed please shell into your server. At times it is best to know the path to the directory/project you want to sniff. Personally I create a reports folder within the project so All my files related to that project are together.  I also want the full report to be printed / displayed. Here is the line I use to generate the Reports from within the project reports folder: phpcs /full/path/to/project --standard=Zend --report=full -n >> projectName.sniffer.txt now we target just specific files as follows: phpcs /full/path/to/project/ext/fileW.extension --standard=Zend --report=full -n >> projectName.sniffer.txt now I use >> to pipe the results into a file but you can remove the the piping to render the results within the terminal/console.
I GOT MY REPORT NOW WHAT Now that you have the report in which ever format you decided as a file or on screen, just follow it's instructions, clear out all the errors and run the command again until there is nothing to report or you are satisfied with the current errors being defined.
Something to Note Code Sniffer does not catch all the errors on first pass especially if there are errors, on many cases once some errors clear up another set of errors become apparent and noticeable. It's good use to make sure you run code sniffer a couple of times to validate that your sniffer code is properly sniffed.
THANKS Thanks go to Adil and Rokkan for providing us with the Conference space.
Next Months Topic Vote at: www.meetup.com/codeigniter/ PhpUnit and Code Igniter with PHP 5.3 Code Sniffer Creating Custom Standards Anything More important than testing and keeping that code clean.
General Info My Email: albert@albert-rosa.com AIM: albertrosa2000 Meetup: www.meetup.com/codeigniter/ Rokkan: www.rokkan.com

More Related Content

What's hot

Denial of service attack part 2
Denial of service attack part 2Denial of service attack part 2
Denial of service attack part 2Kaustubh Padwad
 
Introduction to ida python
Introduction to ida pythonIntroduction to ida python
Introduction to ida pythongeeksec80
 
What's new on Laravel 5.5
What's new on Laravel 5.5What's new on Laravel 5.5
What's new on Laravel 5.5Glend Maatita
 
Static Analysis of PHP Code – IPC Berlin 2016
Static Analysis of PHP Code – IPC Berlin 2016Static Analysis of PHP Code – IPC Berlin 2016
Static Analysis of PHP Code – IPC Berlin 2016Rouven Weßling
 
Flask With Server-Sent Event
Flask With Server-Sent EventFlask With Server-Sent Event
Flask With Server-Sent EventTencent
 
Getting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingGetting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingRavikanth Chaganti
 
Unit testing symfony plugins with php unit
Unit testing symfony plugins with php unitUnit testing symfony plugins with php unit
Unit testing symfony plugins with php unitChristian Schaefer
 
Php psr standard 2014 01-22
Php psr standard 2014 01-22Php psr standard 2014 01-22
Php psr standard 2014 01-22Võ Duy Tuấn
 
Using OTP and gen_server Effectively
Using OTP and gen_server EffectivelyUsing OTP and gen_server Effectively
Using OTP and gen_server EffectivelyKen Pratt
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdownLarry Cai
 
Installing and updating software packages [autosaved]
Installing and updating software packages [autosaved]Installing and updating software packages [autosaved]
Installing and updating software packages [autosaved]ANIMESHKUMARSINHA2
 
PhpSpec: practical introduction
PhpSpec: practical introductionPhpSpec: practical introduction
PhpSpec: practical introductionDave Hulbert
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTPMykhailo Kolesnyk
 
Implement server push in flask framework
Implement server push in flask frameworkImplement server push in flask framework
Implement server push in flask frameworkChi-Chia Huang
 
Assurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring frameworkAssurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring frameworkGosuke Miyashita
 

What's hot (20)

Perl ides
Perl idesPerl ides
Perl ides
 
Bsides tampa
Bsides tampaBsides tampa
Bsides tampa
 
Denial of service attack part 2
Denial of service attack part 2Denial of service attack part 2
Denial of service attack part 2
 
Introduction to ida python
Introduction to ida pythonIntroduction to ida python
Introduction to ida python
 
What's new on Laravel 5.5
What's new on Laravel 5.5What's new on Laravel 5.5
What's new on Laravel 5.5
 
Static Analysis of PHP Code – IPC Berlin 2016
Static Analysis of PHP Code – IPC Berlin 2016Static Analysis of PHP Code – IPC Berlin 2016
Static Analysis of PHP Code – IPC Berlin 2016
 
Flask With Server-Sent Event
Flask With Server-Sent EventFlask With Server-Sent Event
Flask With Server-Sent Event
 
Getting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingGetting Started With PowerShell Scripting
Getting Started With PowerShell Scripting
 
Unit testing symfony plugins with php unit
Unit testing symfony plugins with php unitUnit testing symfony plugins with php unit
Unit testing symfony plugins with php unit
 
appledoc_style
appledoc_styleappledoc_style
appledoc_style
 
Php psr standard 2014 01-22
Php psr standard 2014 01-22Php psr standard 2014 01-22
Php psr standard 2014 01-22
 
Using OTP and gen_server Effectively
Using OTP and gen_server EffectivelyUsing OTP and gen_server Effectively
Using OTP and gen_server Effectively
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdown
 
Installing and updating software packages [autosaved]
Installing and updating software packages [autosaved]Installing and updating software packages [autosaved]
Installing and updating software packages [autosaved]
 
PhpSpec: practical introduction
PhpSpec: practical introductionPhpSpec: practical introduction
PhpSpec: practical introduction
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTP
 
Implement server push in flask framework
Implement server push in flask frameworkImplement server push in flask framework
Implement server push in flask framework
 
Assurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring frameworkAssurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring framework
 
PHP-VCR behat case study
PHP-VCR behat case studyPHP-VCR behat case study
PHP-VCR behat case study
 
CodeShip
CodeShipCodeShip
CodeShip
 

Similar to Code Igniter Code Sniffer

Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Chef
 
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi WallsOSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi WallsNETWAYS
 
OSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 - Mandi Walls - Building security into your workflow with inspecOSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 - Mandi Walls - Building security into your workflow with inspecNETWAYS
 
Adding Security to Your Workflow with InSpec (MAY 2017)
Adding Security to Your Workflow with InSpec (MAY 2017)Adding Security to Your Workflow with InSpec (MAY 2017)
Adding Security to Your Workflow with InSpec (MAY 2017)Mandi Walls
 
Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?AFUP_Limoges
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Bastian Feder
 
Joomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation TestingJoomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation TestingShyam Sunder Verma
 
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017AgileNZ Conference
 
InSpec Workflow for DevOpsDays Riga 2017
InSpec Workflow for DevOpsDays Riga 2017InSpec Workflow for DevOpsDays Riga 2017
InSpec Workflow for DevOpsDays Riga 2017Mandi Walls
 
Mpeg guide
Mpeg  guideMpeg  guide
Mpeg guidekimsach
 
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTYWilliam Chong
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Fabrice Bernhard
 
Nike popup compliance workshop
Nike popup compliance workshopNike popup compliance workshop
Nike popup compliance workshopChef
 
20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboardsDenis Ristic
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Wim Godden
 
Apache Street Smarts Presentation (SANS 99)
Apache Street Smarts Presentation (SANS 99)Apache Street Smarts Presentation (SANS 99)
Apache Street Smarts Presentation (SANS 99)Michael Dobe, Ph.D.
 
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
 

Similar to Code Igniter Code Sniffer (20)

Php
PhpPhp
Php
 
Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2Compliance Automation with Inspec Part 2
Compliance Automation with Inspec Part 2
 
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi WallsOSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
OSDC 2017 | Building Security Into Your Workflow with InSpec by Mandi Walls
 
OSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 - Mandi Walls - Building security into your workflow with inspecOSDC 2017 - Mandi Walls - Building security into your workflow with inspec
OSDC 2017 - Mandi Walls - Building security into your workflow with inspec
 
Adding Security to Your Workflow with InSpec (MAY 2017)
Adding Security to Your Workflow with InSpec (MAY 2017)Adding Security to Your Workflow with InSpec (MAY 2017)
Adding Security to Your Workflow with InSpec (MAY 2017)
 
Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
LIGGGHTS installation-guide
LIGGGHTS installation-guideLIGGGHTS installation-guide
LIGGGHTS installation-guide
 
Joomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation TestingJoomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation Testing
 
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017
 
InSpec Workflow for DevOpsDays Riga 2017
InSpec Workflow for DevOpsDays Riga 2017InSpec Workflow for DevOpsDays Riga 2017
InSpec Workflow for DevOpsDays Riga 2017
 
Readme
ReadmeReadme
Readme
 
Mpeg guide
Mpeg  guideMpeg  guide
Mpeg guide
 
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
5 年後還是新手 - WordPress Plugin 開發大冒險 - GOTY
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Nike popup compliance workshop
Nike popup compliance workshopNike popup compliance workshop
Nike popup compliance workshop
 
20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
 
Apache Street Smarts Presentation (SANS 99)
Apache Street Smarts Presentation (SANS 99)Apache Street Smarts Presentation (SANS 99)
Apache Street Smarts Presentation (SANS 99)
 
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 ...
 

Recently uploaded

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Code Igniter Code Sniffer

  • 2. Topic Code Sniffer The ins and out of making sure your code is up to a standard of your choosing.
  • 3.
  • 4. INTRODUCTION In our days we have come to code to our own way. Many of us have preferences of tabs to spaces, how we name public and private variables. Whether to use CamelCases or Underscores. I myself have been a more code as I code and go back to clean up later, be it with documentation, notes, and how my code is presented. Many like myself want to make sure that All of our codebase is the same format, but we don't want to manually run through them. That could be so tedious and repetitive that one can take a whole other development cycle to just review the code they have written. Luckily there is a pear package we can use to alleviate the stress, this package is called PhpCodeSniffer.
  • 5. INSTALLING PHP CODE SNIFFER To Install PhpCodeSniffer, follow these steps: Go to your command line and enter the following: pear install PHP_CodeSniffer Then enter Phpcs –ito see the installed Coding Standards
  • 6. ABOUT CODE SNIFFER Code Sniffer is used by many Open Source and Private development teams. Code Sniffer can sniff any file or directory you wish. Once it has finished Sniffing you will find a detailed report on all the files you have tested. Also CodeSniffer comes with the prepackaged coding standards (PEAR, Squiz, PHPCS and Zend ), I personally follow the Zend Coding Standards, but you can also customize and create your own coding standard taking bits from all over.
  • 7. CODE SNIFFER RESPONSE Bellow is a typical report for a CodeSniff. FILE: /home/lorna/phpcs/recipe.class.php -------------------------------------------------------------------------------- FOUND 3 ERROR(S) AND 0 WARNING(S) AFFECTING 3 LINE(S) -------------------------------------------------------------------------------- 10 | ERROR | Variable "prep_time" is not in valid camel caps format 13 | ERROR | Spaces must be used to indent lines; tabs are not allowed 17 | ERROR | A closing tag is not permitted at the end of a PHP file --------------------------------------------------------------------------------
  • 8. HOW TO USE CODE SNIFFER Code Sniffer is run via command line, so if needed please shell into your server. At times it is best to know the path to the directory/project you want to sniff. Personally I create a reports folder within the project so All my files related to that project are together. I also want the full report to be printed / displayed. Here is the line I use to generate the Reports from within the project reports folder: phpcs /full/path/to/project --standard=Zend --report=full -n >> projectName.sniffer.txt now we target just specific files as follows: phpcs /full/path/to/project/ext/fileW.extension --standard=Zend --report=full -n >> projectName.sniffer.txt now I use >> to pipe the results into a file but you can remove the the piping to render the results within the terminal/console.
  • 9. I GOT MY REPORT NOW WHAT Now that you have the report in which ever format you decided as a file or on screen, just follow it's instructions, clear out all the errors and run the command again until there is nothing to report or you are satisfied with the current errors being defined.
  • 10. Something to Note Code Sniffer does not catch all the errors on first pass especially if there are errors, on many cases once some errors clear up another set of errors become apparent and noticeable. It's good use to make sure you run code sniffer a couple of times to validate that your sniffer code is properly sniffed.
  • 11. THANKS Thanks go to Adil and Rokkan for providing us with the Conference space.
  • 12. Next Months Topic Vote at: www.meetup.com/codeigniter/ PhpUnit and Code Igniter with PHP 5.3 Code Sniffer Creating Custom Standards Anything More important than testing and keeping that code clean.
  • 13. General Info My Email: albert@albert-rosa.com AIM: albertrosa2000 Meetup: www.meetup.com/codeigniter/ Rokkan: www.rokkan.com