Joomla! CodeSniffer

Discussion & Help for all web scripts and software - such as forums, wikis, content management systems, eCommerce apps and the rest.

Joomla! CodeSniffer

Postby JeanPierre » Tue Jun 19, 2012 9:56 am

Hello Max,

I would like to run PHP CodeSniffer to see which modules and plugins and templates need updating. Because SSH access is not allowed. How can I run the PCHPS script?
JeanPierre
New around here
 
Posts: 24
Joined: Fri Sep 16, 2011 12:06 pm

Re: Joomla! CodeSniffer

Postby Max » Wed Jun 20, 2012 5:39 am

JeanPierre wrote:I would like to run PHP CodeSniffer to see which modules and plugins and templates need updating. Because SSH access is not allowed. How can I run the PCHPS script?


Can you please elaborate on all this? As far as I know, codesniffer is a development tool - why do you need it in a production environment? Why do you need SSH? And what is PCHPS?
Max
Administrator
 
Posts: 1031
Joined: Sat Jul 18, 2009 3:17 pm

Re: Joomla! CodeSniffer

Postby JeanPierre » Wed Jun 20, 2012 7:57 am

Hi Max,

I have noticed when I turn on the debugging that with the new joomla 2.5 there are still php coding errors in modules, extensions and templates. As I am new to this I have been trying to figure out why new joomla 2.5 addons are still using deprecated code. So I would like to log these errors and then if possible try to solve them myself and/or pass them on to the developers of the addons.

PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.


Checking a directory with PHP_CodeSniffer


$ phpcs /path/to/code

FILE: /path/to/code/myfile.php
--------------------------------------------------------------------------------
FOUND 5 ERROR(S) AFFECTING 5 LINE(S)
--------------------------------------------------------------------------------
2 | ERROR | Missing file doc comment
20 | ERROR | PHP keywords must be lowercase; expected "false" but found "FALSE"
47 | ERROR | Line not indented correctly; expected 4 spaces but found 1
51 | ERROR | Missing function doc comment
88 | ERROR | Line not indented correctly; expected 9 spaces but found 6
--------------------------------------------------------------------------------

FILE: /path/to/code/yourfile.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
21 | ERROR | PHP keywords must be lowercase; expected "false" but found
| | "FALSE"
21 | WARNING | Equals sign not aligned with surrounding assignments
--------------------------------------------------------------------------------

Joomla CodeSniffer

http://docs.joomla.org/Joomla_CodeSniffer

This is a custom coding standard for the PHP CodeSniffer that attempts to codify and enforce the Joomla coding standards.


To test a platform file using the provided platform coding standards use

phpcs --standard=build/phpcs/Joomla path/to/file/or/folder

Further documentation on the use of phpcs can be found at: http://pear.php.net/package/PHP_CodeSniffer/docs

To test a platform file using the provided platform coding standards (i.e. Joomla CodeSniffer) use

phpcs --standard=build/phpcs/Joomla path/to/file/or/folder

I also noticed when installing PHP Codesniffer via the Pear panel I saw the following errors:

Image
JeanPierre
New around here
 
Posts: 24
Joined: Fri Sep 16, 2011 12:06 pm

Re: Joomla! CodeSniffer

Postby Max » Wed Jun 20, 2012 9:29 am

You cannot install PHP extensions from cPanel, as our PHP installations are custom built and are not managed by cPanel.

I still do not understand why you need this in production - it's a development tool and you should use it on your own home computer. Users cannot be given SSH access for security reasons.

In terms of the debugging, it's quite likely they have not switched away from using various depreciated code in light of the PHP 5.4 release, especially if they have an obligation to maintain legacy compatibility with PHP 4. This is not something for you to worry about.
Max
Administrator
 
Posts: 1031
Joined: Sat Jul 18, 2009 3:17 pm

Re: Joomla! CodeSniffer

Postby JeanPierre » Wed Jun 20, 2012 9:57 am

Thanks Max
JeanPierre
New around here
 
Posts: 24
Joined: Fri Sep 16, 2011 12:06 pm


Return to Scripts & Software

Who is online

Users browsing this forum: No registered users and 1 guest

cron