Code Analyzer v1.0.1

Release Notes

  • Fixed static methods false positive detection
  • Removed max execution time limit
  •  
    Fatal error: Undefined class constant 'SKIP_DOTS' in ........../www/root/mod/code_review/classes/code_review.php on line 42

  • What php version do you have?

  • It's definitely PHP versioin problem (iterator implementatioin changed since 5.2). I'll try to fix it. In the meantime note that any 5.3.x version should work fine.

  • Ohhh I'd better not to try this :D ... Pawel...do you know you'll cause a lot of sleeping disorder and headaches???

    See below...should I just close my site? :D

    Max version: 1.8
    Skipped inactive plugins: yes
    Found 1019 problems in 351 files
  • @Michele I just noticed your reply.

    Note that problems are not immediate errors. If your site works, that's great, but you need to address these problems if you wish to upgrade to Elgg 1.9 at some point.

  • @Pawel Sroka Thanks for replying. This is a great tool...and now you're scaring me for real :S :D

    Yes, I hope to upgrade to 1.9 as soon as core and plugins I use will be available...but what you say makes me worry and understand that this won't be smooth...

    Hope my testsite will help me in understanding if upgrade will be possible.

    Cheers and thank you again!

  • Most of these problems should be just functions replaced by different version. Most of changes should be doable using regular expressions and actually I'm thinking about automating this task.

  • Well...I guess we all users here would bow at you for such automatization :)

  • @Michele: why not tell the developers of the reported plugins about the deprecation issues? The Code analyzer will give you the info about the files that use deprecated functions. You could make a list of the plugins that might need to be upgraded and then comment on the corresponding plugin pages referring to the Code analyzer plugin.

    If a function is used that has been deprecated in Elgg 1.8, the plugin should continue to work on Elgg 1.9 with these functions. Only on Elgg 1.10 it will no longer work. Though I have to say "should continue to work" and not "will definitely work". I've only tested out a few of my plugins on Elgg 1.9 so far. Unfortunately, it's not necessarily due to deprecated functions that a plugin will not work without updates on Elgg 1.9. Some more complex modifications might be necessary (e,g, Tidypics) or Elgg 1.9 might silently break backward compatibility. The break of backward compatibility might be unintended though, so it surely is helpful to already start testing existing plugins on Elgg 1.9 and report possible issues with broken backward compatibilty in Elgg core on github.

  • @iionly you're right but I am always afraid to bother developers by reporting issues which sometimes are actually only my misunderstandings :S

    In this community I would like to be useful in some way and reporting issues is surely one of (the few of) them but still I am...worried to be a pain in...there...for some devs whose plugins I use.

    And, you know...you are one of them...I feel so grateful for your help man, you and few others here are an incredible mix of professionalism and kindness, so rare to find.

    Cheers

     

  • @Pawel Sroka, after your explanation I took a look again and yes, I can confirm that in my case 99% (1% could have escaped my eyes) of the problems are 'Function call: xxxxxx (deprecated since 1.8)'

    Cheers!

  • Very useful plugin. I didn't know there was something like this here... thanks a lot

  • @srokap I guess writing a plugin to automate will not be so easy/quick.

    Would you give us some hints on how to manually modify the 'Function call: xxxxxx (deprecated since 1.8)' error?

    I there's room to automate I guess we could do some of this manually by:

    - opening certain files

    - replacing function x with function y

    - ...

    What do you think?

    Cheers!

  • Simplest case is to write RegExps that make renames in case of basic renames, or rename + parameters rewrite in case of more complex ones. Most tricky is to write it in a way that won't modify code in not intended places. Ie. renaming core_function to elgg_core_function could hit already correct syntax and make elgg_elgg_core_function. You get the idea.

    Trick is to write RegExps that will catch only intended places. In this example doing preg_replace from [^_a-zA-Z0-9])core_function([^_a-zA-Z0-9] to $1elgg_core_function$2 is quite safe.

    I'm attempting to introduce this automatic rewrites, so if you have some old plugins on community that could get upgraded, paste me links to them here. I'll try to use them as reference point when coding fixes.

  • Hi Pawel!

    Thanks for replying, I was on a very long trip in Asia...now back home...

    Actually I have the majority of the 'functions deprecated' warnings on what they seem core and bundled plugins' files...eg. profile, groups and blog (many), the wire, file, bookmarks, is it possible? (I'm on 1.8.11 waiting for 1.9 upgrade) If you think useful I can send it to you a copy/paste of the report via PM.

    Maybe many fixes were made after 1.8.11?

    As for third party plugins here you have a short list of the most important for me with few/many warnings:

    http://community.elgg.org/plugins/385077/1.8.0%20rc1/tidypics-photo-gallery-plugin (many here)

    http://community.elgg.org/plugins/385114/7.6.1/profile-manager

    https://github.com/kevinjardine/polls

    http://community.elgg.org/plugins/401957/1.8.1/donation

    http://community.elgg.org/plugins/774755/1.8.5/spam-login-filter

    http://community.elgg.org/plugins/384975/4.2.0b/izap-videos-420b-youtube-upload-onserver-upload-embed-urls-10-jan-2013

     

    Cheers!

  • I'm moving slowly towards new version. I already have code to fix basic renames in safer way than regular expressions, but more complex ones require more work to be made safely. I'm also introducing unit tests as it started to be easier to miss a bug.

    I've also removed reporting of deprecated functions called from the deprecated ones themselves (reported from the core).

    I wonder about user interface that would be useful? Nearest version will probably have checkbox "fix what you can", but it might make sense to let user choose what to replace and what not to. Thoughts?

  • @Pawel: please make the fixing of deprecated issues an option. Your plugin is great to find any usages of deprecated function in plugin when working on upgrading plugins (I'm using it already on Elgg 1.9 to verify my work) but at least I prefer to update the code on my own. A "Report only" run could still display the "How the code would need to be changed" info within the list of found deprecated functions (maybe as an popup?).

    Sidenote: getting the plugin to work on Elgg 1.9 is not too difficult. The main modification necessary results from the  elgg_get_plugin_ids_in_dir() no longer available. I simply added this function as code_review_get_plugin_ids_in_dir() within the plugin itself. This should also be BC to Elgg 1.8.

  • Option to analyze code without making modifications will always be there.

    I'm just wondering about the shape of this optional modification. Making one "fix as you go" flag is easier than finding problems, asking user what to fix and fixing while checking if noone was messing with the files in the meantime.

    elgg_get_plugin_ids_in_dir problem is fixed in current master. I'm testing it on 1.9 installs, so I'd be rather worried about me missing problems in Elgg 1.8 ;-)

    Popups are nice idea. I've added similar solution with summary of all deprecated functions with data extrected from the comments + info about possible fix if implemented. They're very basic though.

    Feel free to check Github version https://github.com/Srokap/code_review. I keep it stable and safe.

  • Hi,

    I think iionly is right especially because users not really sure on what to do or not to do, could easily report the issue to each plugin's developer as iionly also suggested.

    But, of course, if some fixes are 100% safe and automatically applicable (which thing should be inserted in the comment about the fix)  then users (with an optional choice) would be happy to apply them :)

    Cheers!

    PS Pawel, this is a great tool indeed, developers can check before posting plugins...very very smart of you and kind

    PPS iionly ... the work you're doing to upgrade all your plugins to 1.9 is so great...I want to start thanking you since now...even if I will upgrade to 1.9 maybe next year :)

  • As long as the option to analyze the code without making any modifications stays there I think the changes that you think are safe to be done could be applied all at once automatically to keep the analyzer plugin simple. Afterwards you would most likely check out the differences for example with a diff tool anyway (if you are a developer of some kind). If a user without any experience in coding uses this plugin it might not help much to offer a step-by-step run with confirming every single modification. In this case it's most likely rather a trial and error approach anyway: either the plugin will work afterwards on the new Elgg version or it still won't work due to more complicated changes necessary that are beyong the scope of the analyzer plugin.

Paweł Sroka

Former Core Elgg team member, freelance developer.

Stats

  • Category: Tools
  • License: Expat (MIT) License
  • Updated: 2016-9-25
  • Downloads: 1827
  • Recommendations: 30

Other Projects

View Paweł Sroka's plugins