phpcsmd - plugin detail

This plugin reports code measurements generated by phpcs, phpmd, phpcpd and pdepend as Tasks and Annotations

NetBeans Plugin - phpcsmd
Plugin owner: vralfy
Website: https://github.com/vralfy/phpcsmd
Added: 2012-04-11
License: GPL
Category: Programming Languages
Downloaded: 6,177 times
Rating:
 4.29, by 15 users

Plugin Log Show log

Versions available

Download plugin   Download size: 0.10 MB   Last Update: 2014-02-27

This plugin is also available on the NetBeans Plugin Portal Update Center. Use 'Tools > Plugins' action from the NetBeans IDE main menu for convenient installation of this plugin


What's new in this version



Verifications for NetBeans versions

8.0 verification PASSED See verification details
Download plugin   Download size: 0.10 MB   Last Update: 2013-12-10

This plugin is also available on the NetBeans Plugin Portal Update Center. Use 'Tools > Plugins' action from the NetBeans IDE main menu for convenient installation of this plugin


What's new in this version



Verifications for NetBeans versions

7.4 verification PASSED See verification details
Download plugin   Download size: 0.10 MB   Last Update: 2013-12-10

This plugin is also available on the NetBeans Plugin Portal Update Center. Use 'Tools > Plugins' action from the NetBeans IDE main menu for convenient installation of this plugin


What's new in this version

* Toggle annotations * see in phpcs/phpmd/phpcpd violations grouped in one single tab in folder scan mode * phpcsmd scans files on startup and open event * violations are grouped in action items * violations also appear in errorstripe * scan progress is visible in the right lower corner of Netbeans * you can use include regex instead of include regex * abort folder scan is possible now * UI improvements * many many bug fixes @see https://github.com/vralfy/phpcsmd/issues?milestone=1&page=1&state=closed

Verifications for NetBeans versions

7.3 verification PASSED See verification details
Download plugin   Download size: 0.10 MB   Last Update: 2013-12-10

This plugin is also available on the NetBeans Plugin Portal Update Center. Use 'Tools > Plugins' action from the NetBeans IDE main menu for convenient installation of this plugin


What's new in this version

* toggle annotations * see in phpcs/phpmd/phpcpd violations grouped in one single tab in folder scan mode * phpcsmd scans files on startup and open event * violations are grouped in action items * violations also appear in errorstripe * scan progress is visible in the right lower corner of Netbeans * you can use include regex instead of include regex * abort folder scan is possible now * UI improvements * many many bug fixes @see https://github.com/vralfy/phpcsmd/issues?milestone=1&page=1&state=closed

Verifications for NetBeans versions

7.2 verification PASSED See verification details
Download plugin   Download size: 0.10 MB   Last Update: 2013-12-10

This plugin is also available on the NetBeans Plugin Portal Update Center. Use 'Tools > Plugins' action from the NetBeans IDE main menu for convenient installation of this plugin


What's new in this version

* toggle annotations * see in phpcs/phpmd/phpcpd violations grouped in one single tab in folder scan mode * phpcsmd scans files on startup and open event * violations are grouped in action items * violations also appear in errorstripe * scan progress is visible in the right lower corner of Netbeans * you can use include regex instead of include regex * abort folder scan is possible now * UI improvements * many many bug fixes @see https://github.com/vralfy/phpcsmd/issues?milestone=1&page=1&state=closed

Verifications for NetBeans versions

7.1 verification PASSED See verification details
Download plugin   Download size: 0.10 MB   Last Update: 2013-12-10

What's new in this version

* toggle annotations * see in phpcs/phpmd/phpcpd violations grouped in one single tab in folder scan mode * phpcsmd scans files on startup and open event * violations are grouped in action items * violations also appear in errorstripe * scan progress is visible in the right lower corner of Netbeans * you can use include regex instead of include regex * abort folder scan is possible now * UI improvements * many many bug fixes @see https://github.com/vralfy/phpcsmd/issues?milestone=1&page=1&state=closed

Verifications for NetBeans versions

Plugin is not subject to any verification



Introduction

This plugin displays the output of phpcs, phpmd, phpcpd or pdepend in your Netbeans IDE as Reports, Tasks or Annotations in your PHP source code.

All you need is a functional version of phpcs, phpmd, phpcpd or pdepend (depending on what you want to use).

Usage:
  • Open Tools->Options->PHP->PHPCSMD to configure the plugin
  • Open Tasks by pressing Ctrl + 6
  • You can scan with a right click on the file, source code or folder and choose "Check for violations" or "Scan with Pdepend"
  • Right click on the PHP-Project and choose Properties -> PHPCSMD to set project specific settings

That's all!

Tips:

  • enable "try threading analysis" to prevent Netbeans from freezing during scan
  • enable "update on save" to rescan the file each time you save
  • enter "\.(svn|git)" (or any other regex) to prevent this file from beeing scanned
  • if the "Task" tab is open (Ctrl + 6) PHPCSMD will scan the file after Netbeans opened it
  • first configure the path to phpcs, click "show standards" and choose your favorite standardyou can also enter a path to standard in the "--standard" option if your favorite standard is not installed in pear
  • enable PHPCS->Extras and PHPCS->Extras->Unreachable Code to see dead code
  • enable "Use tabs to organize PdependReport" and "Create JDepend statistics" to get a better view on the metrics
  • Deactivate "Create JDepend statics" if you don't care about package abstraction/instability to increase the pdepend performance
  • activate PHPCPD folder scan to detect duplicated source code between your source files NOTE: files with violations will be rescanned on save (if activated) until all phpcpd violations habe been eliminated unless the phpcpd file scan is deactivated

[ You have to be logged in to be able to comment. ]

User Comments

  

Issues

@nicorac I copied your post here: https://github.com/vralfy/phpcsmd/issues/38

@miths did you select a phpcs/phpmd profile? Did you install all these programs?
Posted by vralfy on Aug 07, 2014
  

Plugin not working.

Hi,

I have downloaded this tool for my Netbeans 8.0. Created a basic project using netbeans itself. After that installed this plugin. Unchecked the 'phpcpd' as I don't require it. Then clicked on the project and then clicked Tools->Scan for violations, but then no errors, no warnings nothing. Just a tab is opened with name - 'ScanReport:PhpProject2' in that nothing is displaying. Its just a blank tab, at the botton there is button - 'Rescan files'. I clicked on that but then also not a single error.

Can you please help me on this.

Thanks.
Posted by miths on Jul 18, 2014
  

Better menu captions

Being a Drupal developer, this extension is really valuable for me to adhere to Drupal coding standards.
I found some misbehaviors and I'd like to suggest some fixes.

Menu action Tools->Scan for violations did nothing (and exits without an error) if clicked with one (or more) file selected.
It took some time for me to understand it (I thought it also worked with a single file selected).
After looking at the plugin source code I understood how it works (and documentation is not so clear), so I suggest to (in order of preference):
*) make it visible for both files and folder selection and run a "single file" check when a file is selected (like the project context menu item) and a "folder scan" otherwise
OR
*) add an error message to warn the user that this action should be only run on a folder
OR
*) change its caption to "Scan folder for violations"

I found another misbehavior on the project files context menu.
Item "Check for violations" is enabled both for single and multiple selection BUT its action only runs if a single file is selected (and exits silently if more than one file is selected), so I suggest to:
*) let it work like the first suggestion above: make it visible for both files and folder selection and run a "single file" check when a file is selected (like the project context menu item) and a "folder scan" otherwise
OR
*) let it work with more than one file selected
OR
*) disable it when a folder or more than one file is selected

I looked at source code, but I'm not an experienced NetBeans Plugin developer so I only changed item caption to avoid me falling again into this error.

Best regards
Claudio
Posted by nicorac on Apr 04, 2014
  

Re: Toggle visibility

You can toggle the visibility only in phpcsmd options or project settings .. if that is not enough, you can create a detailed issue on github and i will try implement your request.

Oh, you have already done that. Lets talk on github :D
Posted by vralfy on Jun 19, 2013
  

Toggle visibility

Is there an easy way to toggle visibility of highlighting violations in the source code?
Posted by marcovtwout on Jun 18, 2013
  

Re: Getting an exception during validation on Windows 7, JDK 1.7, WAMP, Netbeans 7.3!

Sorry for the delayed answer. Please download and try the new version of phpcsmd. Your problem should be fixed now.

If not, please create an issue on github (https://github.com/vralfy/phpcsmd)
Posted by vralfy on May 05, 2013
  

Getting an exception during validation on Windows 7, JDK 1.7, WAMP, Netbeans 7.3!

Hi,

I have setup the plugin and the dependencies successfully, but when I try to check for violations, nothing happens. I checked the debug.log and found that there was an exception. I've provided the complete stacktrace below, but the problem seems to be the "/" character in the filename. Please help!

phpcs command
c?\software\wamp\bin\php\php5.4.3\phpcs.bat?--standard=Zend
??-w?--report=xml?C?/Workspace/PHP/test.php
Output
Warning??file_put_contents(C?\Program?Files\NetBeans?7.3/phpcs-xml.tmp)??failed?to?open?stream??Permission?denied?in?C?\Software\wamp\bin\php\php5.4.3\pear\PHP\CodeSniffer\Reporting.php?on?line?149 Call?Stack? ????0.0005?????233696???1.??main?()?C?\Software\wamp\bin\php\php5.4.3\phpcs?0 ????0.0094????1267408???2.?PHP_CodeSniffer_CLI->process()?C?\Software\wamp\bin\php\php5.4.3\phpcs?37 ????0.0130????1320408???3.?PHP_CodeSniffer->process()?C?\Software\wamp\bin\php\php5.4.3\pear\PHP\CodeSniffer\CLI.php?614 ????0.0323????1901824???4.?PHP_CodeSniffer->processFile()?C?\Software\wamp\bin\php\php5.4.3\pear\PHP\CodeSniffer.php?466 ????0.0375????2045944???5.?PHP_CodeSniffer_Reporting->cacheFileReport()?C?\Software\wamp\bin\php\php5.4.3\pear\PHP\CodeSniffer.php?1312 ????0.0398????2080920???6.?file_put_contents()?C?\Software\wamp\bin\php\php5.4.3\pear\PHP\CodeSniffer\Reporting.php?149 <?xml?version="1.0"?encoding="UTF-8"?>


Exception: Content is not allowed in prolog.
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
de.foopara.phpcsmd.exec.phpcs.PhpcsXMLParser.parse(PhpcsXMLParser.java:43)
de.foopara.phpcsmd.exec.phpcs.Phpcs.run(Phpcs.java:90)
de.foopara.phpcsmd.generics.GenericExecute.execute(GenericExecute.java:24)
de.foopara.phpcsmd.threads.QAThread.qarun(QAThread.java:103)
de.foopara.phpcsmd.generics.GenericExecute.executeQATools(GenericExecute.java:50)
de.foopara.phpcsmd.PHPCSMD.performAction(PHPCSMD.java:44)
org.openide.util.actions.NodeAction.performAction(NodeAction.java:295)
org.openide.util.actions.CallableSystemAction$1.run(CallableSystemAction.java:129)
org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:95)
org.openide.util.actions.ActionInvoker$ActionRunnable.actionPerformed(ActionInvoker.java:162)
org.netbeans.core.ModuleActions.invokeAction(ModuleActions.java:109)
org.netbeans.modules.openide.actions.ActionsBridgeImpl.invokeAction(ActionsBridgeImpl.java:60)
org.openide.util.actions.ActionInvoker$ActionRunnable.doRun(ActionInvoker.java:153)
org.openide.util.actions.ActionInvoker$2.run(ActionInvoker.java:110)
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432)
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2044)
pmd command
c?\software\wamp\bin\php\php5.4.3\phpmd.bat?C?/Workspace/PHP/test.php?xml?controversial?naming?codesize?unusedcode?design
Output
<?xml?version="1.0"?encoding="UTF-8"??>


Thanks in advance!

Regards,
Yogaesh
Posted by yogaesh on Apr 10, 2013
  

Re: Win 7 problems

@boba.keyost could i get some more informations?
What are your settings?
Have you checked all related checkboxes?
Have you enabled project specific phpcsmd options?
Have you activated the debug log?
Posted by vralfy on Mar 15, 2013
  

Win 7 problems

Hi, I'm using NB 7.3 with PHPCSMD 0.6.0.4 on Win7.

There is same problem with empty debug log and empty output.
Posted by boba.keyost on Mar 05, 2013
  

Re: Improvements 2

Thank You, amazing job ;)
Posted by fonsecas72 on Feb 25, 2013
  

Re: "update on save" only after manually "Check for violations"

This can happen the first time you are running phpcsmd.
Try restarting Netbeans and open your Action Items an let them open. Add "PHP Violations" to your ActionItems filter and change the scope to "Show action items for currently edited file only"
Posted by vralfy on Feb 22, 2013
  

"update on save" only after manually "Check for violations"

Hello vralfy,
thanks to you for your plugin.
I activate "update on save" for the phpcs. But it is necessary to "Check for violations" one times manually after starting netbeans. Before it will not work on save. After I "Check for violations" one times, it works!
Is this an normal wished behaviour?

Debian 7.0
Netbeans 7.2.1
phpcsmd 0.6.0.4 (only phpcs activated)
Posted by stso on Feb 22, 2013
  

Improvements 2

Your third suggestion is a project im currently working on. But I did not manage to add Icons to the file. If you have any idea how to do that, you are welcome.

I will try to release the source to github so everybody can help to improve the source

UPDATE: I moved from my private svn to github (see Website above)
Posted by vralfy on Feb 22, 2013
  

Improvement Suggestion 2

Thanks for your answer.
What I meant about css and js, was related to point 4. I didn't knew I had to have the actions filter open. I use to work with eclipse and things work a little different there. Everything is working now. :)

And I have some more issues/suggestions for you:
~> The "@SuppressWarnings(PHPMD)" annotations seems to not be working.
~> Can the plugin use my ruleset.xml configuration for phpmd?
~> warnings found could appear in the working tree too? Just like git plugin, we could have some flag telling that that file or that folder contains files/lines with warnings (maybe as an option?).

Maybe I could help you improving this plugin. Can you tell me how that's possible? (if it is)

Thank you again.
Posted by fonsecas72 on Feb 18, 2013
  

Re: Improvement Suggestion

Sorry for the delayed answer.

1. I will prove your feature request as soon as possible.
2. I will prove this feature request too :D
3. phpcs, phpmd, phpcpd and pdepend are supposed to work with php files. You have to write your own Sniffs and Coding Standards in phpcs to check js and/or css
4. Open your "Action Items" (Ctrl + 6) and leave it open. Enable "PHP Violations" in your "Action Items Filter". Go to PHPCSMD Options and check the first two checkboxes. Restart Netbeans. PHPCSMD should scan the file when your are opening it.

Best regards
Posted by vralfy on Feb 15, 2013
  

Improvement Suggestion

~>What about adding a "loading" bar when phpcsmd is working - if phpcs is checking for violations in a big file, we get no feedback on their status.
~>The errors and warnings found aren't appearing in right side annotations vertical bar (sorry, don't know that bar name :p)
~> this works with css and js files right?
~> There should be an option to scan on open.
I think that many people would appreciate this a lot.(sorry my poor english)
Thanks for your plugin :)
Posted by fonsecas72 on Feb 12, 2013
  

Re: Unreachable Code

Hi nedelcumax.

1. Activate Extras
2. Choose Squiz from the top tab row
3. Choose PHP from the left tab column
4. Scroll down and activate "show unreachable code" and don't activate the "ignores"

To test your setting:
1. create a new function in php with a return statement
2. insert some code (e.g. echo "foo") right after the return statement
3. save file
4. if have not activated "update on save", perform a right click on the source and "check for violations"

PHPCSMD should mark the code after the return statement as unreachable code.
Posted by vralfy on Dec 20, 2012
  

Unreachable Code

Does anyone know how I can reach this option: PHPCS->Extras->Unreachable Code . I'm using Netbeans 7.2 and the latest version of this plugin.

I cannot seem to find it :/
Posted by nedelcumax on Dec 18, 2012
  

RE: Problems with 0.6.0.2 on NB 7.2

I can confirm that with v0.6.0.3 the "java.lang.NoSuchMethodError: org.openide.filesystems.FileObject.getLookup()Lorg/openide/util/Lookup;" error is no longer reproduced in NB 7.2.

Thank you for the support!
Posted by cristian_radulescu on Nov 14, 2012
  

Re: Same as precedent

I reviewed the code and the result was version 0.6.0.3. I tested it together with a friend of mine who had the same problems like you.
Actually it works for him now.

Please update version 0.6.0.3 and leave me a comment if it works.

Thanks

vralfy

P.S. I was not able to connect to your jabber server
Posted by vralfy on Nov 13, 2012
  

Same as precedent

Same error with same system except using NetBeans 7.2.1.

Feel free to add me on gtalk/jabber if you need more info : magnetik at jabber dot magnetik dot org
Posted by magnetik on Nov 13, 2012
  

Problems with 0.6.0.2 on NB 7.2

The following error occurs when opening a new file (or focus an opened one in the editor):
java.lang.NoSuchMethodError: org.openide.filesystems.FileObject.getLookup()Lorg/openide/util/Lookup;
at de.foopara.phpcsmd.ViolationReporter.scan(ViolationReporter.java:72)
at de.foopara.phpcsmd.ViolationReporter.setScope(ViolationReporter.java:64)
at org.netbeans.modules.tasklist.impl.TaskManagerImpl.doRefresh(TaskManagerImpl.java:353)
at org.netbeans.modules.tasklist.impl.TaskManagerImpl.access$200(TaskManagerImpl.java:78)
at org.netbeans.modules.tasklist.impl.TaskManagerImpl$3.run(TaskManagerImpl.java:339)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1452)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2032)

In NB 7.3 beta 2 works fine, so I'll stick with the beta for now, seems stable enough.
The operating system is Windows 7.
Posted by cristian_radulescu on Nov 13, 2012
  

Re: Re: Problems

You are still using versin 0.6.0.1, right? If so, update phpcsmd and try again. There are some fixes in 0.6.0.2 which may resolve your problems.

If phpcsmd does not work either, leave a message here please.
Posted by vralfy on Nov 12, 2012
  

Re:Problems

Hi,

I have been using the toolbar > Tools > Scan for violantion

Phpcsmd log file here : http://pastebin.com/6rPivqdw

[edit] When I clear it and redo the action, it seems that there is nothing in the log...

Thanks for the support :)
Posted by magnetik on Nov 12, 2012
  

Problems

@magnetik: What does the debug log say?
Please activate Debug Log in Options -> PHPCSMD
scan for violoations
open PHPCSMD options and click on show
What action did you use?
- Tools in the Menu bar
- right click on source code
- right click on file
- right click on folder

@idefaye: The exception is fixed and i will upload it in a few minutes.

Bye
Posted by vralfy on Nov 07, 2012
  

Re: Windows 7 issues

Thanks vralfy for your anwser.
I've executed commandline outside of PHP directory and got this error : ".\php.exe is not recognized as an internal or external command, operable program or batch file"
To make it work I had to change phpcs.bat file so .\php.exe points to my PHP installation dir. Now in commandline it works from everywhere.

Unfortunatly I've updated to the latest version of phpcsmd: 0.6.0.1 and now get another error. I could not test previous version to see if it worked.
Here is the new error log :
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at de.foopara.phpcsmd.exec.phpcs.Phpcs.run(Phpcs.java:63)
at de.foopara.phpcsmd.generics.GenericExecute.execute(GenericExecute.java:25)
at de.foopara.phpcsmd.threads.QAThread.qarun(QAThread.java:103)
[catch] at de.foopara.phpcsmd.threads.QAThread.run(QAThread.java:84)

For now I am using another plugin called phpMDNB plugin (found here http://sourceforge.net/projects/phpmdnb/). I did not have to modify the default phpcs.bat file build by Pear to make it work in NetBeans. If this can help Windows users looking for a solution.

Still phpcsmd looks better, so I'd rather use it if I can make it work. And if it could work right out of the box without the need to modify phpcs default installation, then it would be great.

Igor
Posted by idefaye on Nov 06, 2012
  

Can't make it work

Hi,

I'm on Windows 7 using Netbeans 7.2.1 on Java 6.

PhpCS is installed correctly. I think I've set up everything correctly, but when I do Action > scan for violation, nothing happens.

Any way to see what the problem is ?
Posted by magnetik on Nov 06, 2012
  

Re

No problem.
Thx for the new version :)
Posted by ent38 on Nov 04, 2012
  

Uuups

I was developing on the netbeans nightly-build so it added version 1.49 of Project API to the dependencies. New release should be fixed.

Sorry for that!
Posted by vralfy on Nov 04, 2012
  

Can't install latest version

Hi,
I can't install the latest version on NB 7.2.1. I get the following message :

Some plugins require plugin Project API to be installed.
The plugin Project API is requested in version >= 1.49 but only 1.46.1 was found. The following plugin is affected:       phpcsmd
Posted by ent38 on Nov 03, 2012
  

Re: Update and dowload problem

Hi,

thanks for the information. I uploaded a new version of this plugin and this issue should be fixed.

The new version comes with the ability to set project specific settings (if needed). Just right click on your PHP-Project chose Properties -> PHPCSMD.

There is still the issue on projects containing whitespaces in project path. Some how I can't get it fixed.

Have fun
Posted by vralfy on Nov 03, 2012
  

Update and dowload problem

Hi,

I'm no more able to update phpcsmd from within netbeans and the download link above bring me to the following error message :

Error

Plugin file missing on the file system.
Please inform webmaster

Could you please look at this issue ?

thanks a lot

Eric
Posted by eviweb on Nov 01, 2012
  

Re: Windows 7 issues

For some reason the phpcs command does not generate any Output (as i can see, its empty). Thats why the Exception is thrown.

Have you run phpcs inside of d:\ServeurWeb\php-5.3.5-nts folder? If so, try running it outside in any other folder using the command line from the debug log. Some chars are replaced in debug-log so you can't just copy and paste.
Posted by vralfy on Oct 25, 2012
  

Windows 7 issues

Hi,
This look very promissing. Somehow I cannot have it work on win7.

Here is what the logs says :
phpcs command
D?\ServeurWeb\php-5.3.5-nts\phpcs.bat?--standard=Zend?--tab-width=4?-n?--report=xml?D?/SUBVERSION/P1/Bin/www/ope_RAPPORT/include/constante.php
Output

Exception
Premature end of file.
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:249)
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
de.foopara.phpcsmd.exec.phpcs.PhpcsXMLParser.parse(PhpcsXMLParser.java:36)
de.foopara.phpcsmd.exec.phpcs.Phpcs.run(Phpcs.java:74)
de.foopara.phpcsmd.generics.GenericExecute.execute(GenericExecute.java:22)
de.foopara.phpcsmd.threads.QAThread.qarun(QAThread.java:93)
de.foopara.phpcsmd.threads.QAThread.run(QAThread.java:74)

I run on Windows7 64Bits, NetBeans IDE 7.2 (Build 201207171143), Java 1.6.0_24, PHPCS 1.40
phpcs works properly under command prompt using the same settings, but I get this java error when using this plugin in NetBeans.

I've tried using Java 1.7 for netbeans, but still have the same error message.

Any help would be most welcome.

Igor
Posted by idefaye on Oct 22, 2012
  

+1 for project specific option

Hi,

before all, I wish to thank you for this great tool !!!
It is very very very useful.

As mr3dblond asked for, I vote for a project specific option in the setting page.
It would be a real improvement, and I would be happy too ;)

Eric
Posted by eviweb on Oct 18, 2012
  

Project specific phpcsmd settings

I know it was a codesniffer configuration, but wanted to use it as a workaround of the missing feature ;)
If this feature would be in phpcsmd, I would be happy :)
Posted by mr3dblond on Oct 11, 2012
  

Thanx

@eduardoelias
- escaping whitespaces in filenames will be in the next release

@mr3dblond
- this is phpcsmd not codesniffer
Actualy there is no way to set project specific phpcsmd settings.
I'll take your post as feature request :D
Posted by vralfy on Oct 11, 2012
  

Project with different coding standards

How can I use sniffs project related? E.g. project a with Zend and project b with Symfony2.

I found a blog article with a solution, but this did not work for me. I created an file named codesniffer.properties in nbproject directory with this content:

phpcs.standard=/usr/lib/php/pear/PHP/CodeSniffer/Standards/Zend/ruleset.xm


I tried this, too:

phpcs.standard=Zend


In all projects the coding standard of the phpcsmd setting page is used. Has anyone a solution for it?
Posted by mr3dblond on Oct 09, 2012
  

GREAT! I had never worked with such a professional team like yours!

Well, thanks to your log screen, i could see that, because my folder name, wich has an space in it, the command to phpcs, wich is not scaped, returns an error.

1) Thank you for your already done efforts and for the amazing plugin you have!
2) I'll change my folder's name, to one without spaces.
3) I'll suggest you guys, to scape the folder command to allow spaces.

If i can help in anyway, just say.
Posted by eduardoelias on Oct 08, 2012
  

Re: Some updates

I was able to reproduce your error message, by adding phpcpd as phpcs command. So it produces non xml output and this causes the error.

As you can see, i have updated a new version of phpcsmd. Please follow these steps.

1. Update phpcsmd to version 0.5.5.0
2. open phpcsmd options, enable debug log and save
3. perform a filescan
4. go back to phpcsmd options and click show (on the right side of "activate debug log")
5. look for a exception, the corresponding command and output (which show up some lines earlier) and post them here, if you have not already found a solution.

In the debug log i have marked some whitespaces and other characters with a special symbol (as you will see)

Don't forget to deactivate debug log, or netbeans will use a lot of RAM.
Posted by vralfy on Oct 05, 2012
  

Some updates:

Hello, i've been trying to fix that problem with no success. I've generated a XML via console and, successfull, it brings warnings and errors and no BOM chars.

Is there a way to look into XML that will be parsed in phpcsmd? maybe a temporary one? Is the code of your plugin open?? I would like to look into it and try to find what is messing up here.

Thanks for your patience and responses! :D
Posted by eduardoelias on Oct 05, 2012
  

Thanks for the fast reply!!

So, i did what you said and, now, it seems that the amount of erros duplicated. I had, running phpcs -d, the error:
"PHP Notice: Undefined offset: 2 in /usr/share/php/PHP/CodeSniffer/CLI.php on line 258" and added
a @ to it.

When i run phpcs from command line, it runs ok showing the errors that we predicted. Running from NetBeans, it still givin' the 'Content is not allowed in prologue'.

I reeaally need some debug info! :D
Thanks in advise.

Posted by eduardoelias on Oct 03, 2012
  

Re: Not working, something i've done ...

This is the first time i see this error message, but here are some ideas.

It seems there is some content before the opening xml-tag in the phpcs output. Sometimes these are php debug informations such as "Don't use # for comments in ini files".

Just try the following:
1. Create a php script which prints "Hello World"
2. run "php script.php" and see if it realy just prints "Hello World"
3. If not, try to allocate the php error messages
4. Add "error_reporting=E_ERROR" to the phpcs -d option
5. Activate only one of the external programs like phpcs, phpmd etc to check which of them causes the error
6. If nothing helps come back and we will try to find an other solution


It also could be an encoding conflict between your source code and the xml result (but i think it is not)

Thanks for feedback
Posted by vralfy on Oct 03, 2012
  

Not working, something i've done ...

I've tried to install phpcsmd on my Ubuntu 12.04 64 and, when i try to scan my file, it throws a 'Content is not allowed in the prologue' error, at IDE log.

I would like to know if i can setup a more verbose log. I am trying to find wich XML is causing the error.

I had checked every XML, trying to find any BOM char at t he beginning, withou success.

thanks for your help, and sorry the bad english! :D
Posted by eduardoelias on Oct 03, 2012
  

Re: Feedbacl

To your second point:

Did you activated single file scan? Phpcsmd will scan the file on save if:
  1. File scan is activated

  2. Folder scan is activated, was performed AND the file has violations at this time.



In other words. If the file had no violations and you deactivated singe file scan the file will not be scanned.

I'll try to reproduce the "Windows problem" as soon as possible.
Posted by vralfy on May 13, 2012
  

Feedback

Hi,

Thanks for the update.

1. The updates to "current project" and "all opened projects" scope are a welcome change and work as expected.
2. Folder level CPD works "acceptably" when scope is restricted to "current project" (Current file causes highlight to clear instantly). I think this is a reasonable compromise.
2. File level CPD does not work now (to test, just copy paste the same block in a file and check for violations).. I'm guessing it is an easy fix
3. I still have to check the behavior on win7/64.. Will report back later this evening
(I already have all the versions and tried them on my home pc this morning.. And version 0.5.1.1 was the only one in which cpd works - win7/64)

Thanks again!


EDIT 5/11/12: CPD still does NOT work on win 7/64 bit. Only ver 0.5.1.1 (first version) works. On all the other versions, rescanning does not detect cpd errors.
Posted by mnshankar on May 10, 2012
  

Good hint

Hi,

there was an experimental timeout i added in 0.5.2.2. Removing this timeout could solve your problem (win7 and winXp).

I deactivated scanning while "Current Project" or "All opened Projects" is activated for performance reasons. Thats why your violations do not disappear and tasks do not come up or were not updated. I implemented a little feature here so you can see allready detected violations in this scopes.
But remember: Files will not be rescanned if one of these scopes is selected or the task bar is closed.

There is only a changeListener which will scan your file on save. (No openListener, no closeLister or something like that). If there is someone who can tell me how to implement such listeners, please don't be shy :)

Ok now lets try 0.5.2.6 ;)

I am waiting for your report :)

EDIT: If the problem still exists, i will upload all versions between 0.5.2.1 and 0.5.2.5 on my webpage. Perhaps you can findout which version causes your error.
Posted by vralfy on May 10, 2012
  

Task Scope Settings

Hi vralfy.. Yes.I am using ver 5.2.5.

On further investigation, I found that In the tasks pane, if I select the scope as "Current Project" or "All opened projects", it works as expected.
Selecting scope as "Current file" (first option on the task pane margin) causes errors to clear immediately. Can you please try all task scopes and verify?

Also, When "current project" scope is selected, the list of phpcsmd errors is NOT displayed in the task pane (only annotations and highlights on the source code are displayed). The "current file" scope correctly displays the list of errors.

EDIT: The CPD checks (file and folder) do not work on win7(64 bit)+netbeans 7.1 installed on my home pc. I reverted to the 5.2.1 (initial version) and file check works fine!
Posted by mnshankar on May 09, 2012
  

Are you using 0.5.2.5?

Even with a opened Tasktab it works for me now (using version 0.5.2.5). So it must be something else.
Posted by vralfy on May 09, 2012
  

Contd...

hmm..I think you probably don't have the "tasks" tab on.. please leave it open (ctrl+6) and retry. It is what causes the annotations to clear immediately.

With the tasks tab closed, it works slightly better.. but it is not consistent.
Posted by mnshankar on May 08, 2012
  

Immediately Clear

I think i solved your problem .. i tested several times on a other mashine but i was not able to reproduce this bug. But after i updated my phpcpd the same error occurs.

If this problem still appears, try activating the phpcpd file mode in addition to folder scan. This should solve your problem too.

Thanks again for your help, to make this plugin work ;)
Posted by vralfy on May 08, 2012
  

Clears immediately

Hi,

Now, the annotations disappear just on viewing the file (without even deleting the copied code). For example, if CPD violation is detected in file1.php and file2.php, If I simply open file1.php (or file2.php), the annotations get cleared out after a delay of about 3-4 seconds.

(My best guess is that the refresh process is running phpcpd on the file and not the selected folder, and since duplicates are not found in the same file, it is clearing them)

I really appreciate your patience!
Posted by mnshankar on May 07, 2012
  

Removing CPD-Folder-Scan-Violations Bug ;)

I was able to reproduce this Bug and i was able to fix it.

It can take a while to remove the Annotations (in dependency to your PC capacities). The other file (which you have not edited) will be rescanned if you open or switch to it, and the Annotations will hopefully disapear there too.

Thanks again for your report, and let me know if you have found more bugs.
Posted by vralfy on May 07, 2012
  

More information.

Thanks for your prompt response. Here is the information you requested:

Os : Windows XP
Netbeans : 7.1
No versioning system
(Local history is on though.)

Here's how you can reproduce this error:

1. Install the plugin in netbeans (I just tried with the latest verstion 0.5.2.3).. Check the "PHPCPD(folder scan)" option and uncheck the "PHPCPD(single file)". Change the min-lines and min-tokens in the php settings tab to 5/5 so that you can simulate a cpd error easily

2. In the main project folder, create two files.. add the same php code in both.

3. Right click on the project folder, and select "Scan for violations".. both the files will be identified and displayed on the scan report

4. Delete the duplicated code from one of the files and save.

5. Now, no matter what you do (save both files, rescan the files again) , the CPD violation continues to be displayed in both the files (along with annotations and highlights). Only restarting netbeans seems to fix it.
Posted by mnshankar on May 04, 2012
  

Could i get some more informations?

To resolve this problem i need some informations.
Which OS do you use?
What's your current Netbeans version?
Do you use any versioning system like svn or git?

Do the annotations still appear in the edited file, the corresponding file or in both files?

You should also check if one of the files belong to a versioning directory. If so try adding versioning directories to the 'ignore regex' and '--exclude' option (e.g. ignore regex='\.svn' and --exclude='.svn').

Edit: I released a new version. This could possibly solve your problem
Posted by vralfy on May 04, 2012
  

Thanks for the update!

Thanks for the update! For the most part, it works as expected. There seems to be one small bug though. When a copy-paste is detected across different files (folder scan), after removing the offending code and refreshing, the annotations and highlighting dont go away. It requires a full restart of Netbeans to get reset.
Posted by mnshankar on May 03, 2012
  

Re:

Yes i know the malfunction of phpcpd detector. At this moment the plugin only scans a single file. I promise to solve this in the future.

Thnx for the comment :D
Posted by vralfy on Apr 18, 2012
  

Very helpful plugin. Thank you!

Thanks for providing this plugin. I use it regularly and prefer it to the other cs/md plugins.
One error that I noticed is that the copy/paste detector does not work as expected on multiple files.. that is, when I right-click on a folder and scan for violations, cpd does not detect violations.
Posted by mnshankar on Apr 18, 2012
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo