-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add deprecated code to Code Style check #208
Comments
Okay, just did some experimenting with this deprecated function. I have created a new sniff (./Joomla/Sniffs/Deprecated/DeprecatedFunctionsSniff.php):
In that class you can set 'forbidden' functions like this:
When running PHPCS I get the following report:
thoughts, input, remarks, etc. please :) |
I don't hope that this is one of those threads that I am the one talking to myself :) #IthinkIjustdidit I have done a change for everybody to test. It currently sniff only a couple of deprecated functions: just for testing the concept. In the patch there is also a cvs list of all deprecated functions I found in the Joomla 3.8 library directory (the tool to create the list is also in the deprecated directory). This should give some background on the discussion what function to include or not etc. Looking forward to feedback :) https://github.com/Ruud68/coding-standards/commit/e52b93557e34a508e8f9344335f55c0921f203c5 |
hey @Ruud68 ! I like the idea. The main problem is that a coding standard should be decoupled from anything because it can be used for any package. It makes no sense to check for deprecated CMS stuff in a framework package. Rule can be probably disabled but wouldn't it be better to have an external tool that you can integrate anywhere? I think that's the approach WP people are suggesting. I haven't worked/contributed to coding-standards but I'm guessing you are not linking method with classes? I can have a decodeData() method deprecated for 1 class but not for other? As I said I'm not a coding-standards expert so forgive me any mistake ;) |
Hi @phproberto thanks for your reply :))) What I have come up with is (as far as I have deducted from the WP code style sniffs) the same way that WP CS does it. So what I have come up with works: it checks for methods, by comparing the method name in the array with the methods found in the checked file. I can build the same for deprecated classes: it follows the same logic as methods. Before extending with deprecated classes I first would like to get some consensus on the deprecated methods. The challenges / questions now are:
Would love to get some direction / feedback as I have limited experience in tools that check for deprecated code. |
Just added DeprecatedClassesSniff.php > https://github.com/Ruud68/coding-standards/blob/master/Joomla/Sniffs/Deprecated/DeprecatedClassesSniff.php
|
here it starts (or ends :)) #221 |
Hi,
For me one of the most import Coding Standards is to NOT use deprecated code in my Joomla extensions. Some IDE's have build in support where they read the classes / methods docblocks for the @deprecated tag. A lot of IDE's and Code editors do not have this possibility (Eclipse has this possibility but it is broken after the switch to name spaces in Joomla 3.8).
Currently I made the switch to the open source 'text editor' Geany: I love it btw :)
Geany has support for PHPCS: when running PHPCS (and PHP Code Fixer) it highlights the warnings and errors in the code.
When we add the 'detection' of deprecated code to the Joomla Coding Standards, then Geany (and a lot of other editors) get directly the possibility to also check for (and highlight) deprecated code.
I have done some research and found that the WP team is also using their PHPCS for this purpose: here is the discussion > WordPress/WordPress-Coding-Standards#576
Does this also make sense for the Joomla Coding standards? Are the implemented WP sniffs for deprecated classes etc. something we can work with?
The text was updated successfully, but these errors were encountered: