phpcsmd
phpcsmd copied to clipboard
Add support to import a generated PMD report
All in the title, two methods for doing this: 1 - A path to the generated PMD report 2 - A command, when executed it return a PMD report on it's output
@vralfy did u see this feature ?
I dont understand this issue. Could you give a little more detail?
Is not an issue, this a future, the idea is when I have a generated PMD rapport file and I want this plugin to read this file and show me the violations on the IDE
I use this tools to analyse my code https://github.com/sensiolabs/insight, this tools generate a PMD rapports and I want to integrate this file on netbeans, there is two methods for doing this:
1- In the window of PHPCSMD can I enter the file path of the PMD rapport 2- A command that PHPCSMD execute and return the PMD rapport on it's output
Ahhh is see .. You want to use pmd instead of phpmd ... I think this should be possible
can u integrate that in this plugin ? or there is a quickly tips for doing that ?
I think i can do it ... but i have to write a parser for that ... if I have time for that Feel free to do it on your own, I think the source structure is selfexplaining
@vralfy I'm a user of this plugin, but I'm not a java programmer :D
Ok :D
@jbinfo I'm a little bit confused on how to use pmd with php sources .. could you give me an example please?
Anyway why are you not using phpmd?
I use this tools to analyse my app https://github.com/sensiolabs/insight, it's based on the symfony framework, the comany behind symfony have a tools to analyse code this app generated a PMD report.
What I want on this plugin is to read this PMD report and show the violation in the netbeans IDE.
Can you give me a command line example, to run pmd on php sources?
Look at the README.md
file on this sensiolabs tools https://github.com/sensiolabs/insight
When you install it, create an account on the sensiolabs insight and get your API TOKEN
and USER UUID
.
The command format to generate a PMD report is:
/path/to/insight-sdk/bin/insight analysis --user-uuid $YOUR_UUID --api-token $YOUR_API_TOKEN $INSIGHT_PROJECT_UUID --format=pmd
For the $INSIGHT_PROJECT_UUID
we can use this public project on sensiolabs as example to generate our PMD report: https://insight.sensiolabs.com/projects/1ae2ec87-b20b-4451-b8e8-ee35940a5b3c
The finale command is:
/path/to/insight-sdk/bin/insight analysis --user-uuid $YOUR_UUID --api-token $YOUR_API_TOKEN 1ae2ec87-b20b-4451-b8e8-ee35940a5b3c --format=pmd
You can get these values $YOUR_UUID
and $YOUR_API_TOKEN
from here: https://insight.sensiolabs.com/account
This is the PMD report for this project https://github.com/gregorybesson/PlaygroundWeather What you need is to clone this project and show these violationson the netbeans IDE.
<?xml version="1.0" encoding="UTF-8"?>
<pmd timestamp="2014-05-28T08:06:01+02:00">
<file name="composer.json">
<violation beginline="0" endline="0" rule="Version of dependencies should be fixed" ruleset="bugrisk" priority="5">Package playground/design#dev-develop is not fixed.</violation>
<violation beginline="0" endline="0" rule="Version of dependencies should be fixed" ruleset="bugrisk" priority="5">Package playground/core#dev-master is not fixed.</violation>
</file>
<file name="src/PlaygroundWeather/Mapper/Location.php">
<violation beginline="46" endline="46" rule="Database queries should use parameter binding" ruleset="security" priority="1">If provided by the user, the value of $country may allow an SQL injection attack. Avoid concatenating parameters to SQL query strings, and use parameter binding instead.</violation>
<violation beginline="42" endline="42" rule="Unused method, property, variable or parameter" ruleset="deadcode" priority="5">This sortArray argument is declared but never used. You should remove it.</violation>
</file>
<file name="src/PlaygroundWeather/Entity/Code.php">
<violation beginline="159" endline="159" rule="Boolean property should not be prefixed by "is"" ruleset="codestyle" priority="5">Boolean property accessor should not be setIsXXX nor getIsXXX but setXXX and isXXX.</violation>
<violation beginline="167" endline="167" rule="Boolean property should not be prefixed by "is"" ruleset="codestyle" priority="5">Boolean property accessor should not be setIsXXX nor getIsXXX but setXXX and isXXX.</violation>
</file>
<file name="src/PlaygroundWeather/Mapper/ImageMap.php">
<violation beginline="99" endline="99" rule="Commented code should not be commited" ruleset="deadcode" priority="5">Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.</violation>
<violation beginline="100" endline="100" rule="Commented code should not be commited" ruleset="deadcode" priority="5">Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.</violation>
<violation beginline="46" endline="46" rule="Code should not be duplicated" ruleset="architecture" priority="5">The next 43 lines appear both in src/PlaygroundWeather/Mapper/ImageMap.php:46 and src/PlaygroundWeather/Mapper/Location.php:84.</violation>
</file>
<file name="src/PlaygroundWeather/Module.php">
<violation beginline="167" endline="167" rule="Commented code should not be commited" ruleset="deadcode" priority="5">Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.</violation>
<violation beginline="168" endline="168" rule="Commented code should not be commited" ruleset="deadcode" priority="5">Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.</violation>
<violation beginline="170" endline="170" rule="Commented code should not be commited" ruleset="deadcode" priority="5">Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.</violation>
<violation beginline="171" endline="171" rule="Commented code should not be commited" ruleset="deadcode" priority="5">Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.</violation>
<violation beginline="172" endline="172" rule="Commented code should not be commited" ruleset="deadcode" priority="5">Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.</violation>
<violation beginline="173" endline="173" rule="Commented code should not be commited" ruleset="deadcode" priority="5">Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.</violation>
<violation beginline="174" endline="174" rule="Commented code should not be commited" ruleset="deadcode" priority="5">Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.</violation>
<violation beginline="176" endline="176" rule="Commented code should not be commited" ruleset="deadcode" priority="5">Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.</violation>
<violation beginline="177" endline="177" rule="Commented code should not be commited" ruleset="deadcode" priority="5">Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.</violation>
<violation beginline="76" endline="76" rule="Include statements should not be used" ruleset="architecture" priority="5">Using include() or require() bypasses lazy-loading of third-party classes. Prefer using autoloading.</violation>
</file>
<file name="src/PlaygroundWeather/Service/DataUse.php">
<violation beginline="215" endline="215" rule="Code should not be duplicated" ruleset="architecture" priority="5">The next 43 lines appear both in src/PlaygroundWeather/Service/DataUse.php:215 and src/PlaygroundWeather/Service/DataYield.php:314.</violation>
<violation beginline="10" endline="10" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class PlaygroundWeather\Entity\HourlyOccurrence is declared but never used. You should remove the use statement.</violation>
</file>
<file name="src/PlaygroundWeather/Service/ImageMap.php">
<violation beginline="175" endline="175" rule="Code should not be duplicated" ruleset="architecture" priority="5">The next 34 lines appear both in src/PlaygroundWeather/Service/ImageMap.php:175 and src/PlaygroundWeather/Service/Location.php:187.</violation>
</file>
<file name="src/PlaygroundWeather/View/Helper/ImageWidget.php">
<violation beginline="88" endline="88" rule="Code should not be duplicated" ruleset="architecture" priority="5">The next 40 lines appear both in src/PlaygroundWeather/View/Helper/ImageWidget.php:88 and src/PlaygroundWeather/View/Helper/TableWidget.php:78.</violation>
</file>
<file name="src/PlaygroundWeather/Options/ModuleOptions.php">
<violation beginline="276" endline="276" rule="Usage of a function in loops should be avoided" ruleset="performance" priority="5">This loop uses a function. To avoid the overhead of executing the function n times, you should precalculate it before the loop.</violation>
</file>
<file name="src/PlaygroundWeather/Controller/Admin/AdminController.php">
<violation beginline="19" endline="19" rule="Unused method, property, variable or parameter" ruleset="deadcode" priority="5">This options local variable is declared but never used. You should remove it.</violation>
<violation beginline="7" endline="7" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class DateTime is declared but never used. You should remove the use statement.</violation>
</file>
<file name="src/PlaygroundWeather/Service/DataYield.php">
<violation beginline="188" endline="188" rule="Unused method, property, variable or parameter" ruleset="deadcode" priority="5">This hourlyOcc local variable is declared but never used. You should remove it.</violation>
<violation beginline="162" endline="162" rule="sleep() should not be used" ruleset="performance" priority="3">sleep() may create timeouts without even protecting your application.</violation>
</file>
<file name="src/PlaygroundWeather/Controller/Frontend/WebServiceController.php">
<violation beginline="7" endline="7" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class PlaygroundWeather\Service\DataYield is declared but never used. You should remove the use statement.</violation>
</file>
<file name="src/PlaygroundWeather/Entity/ImageMap.php">
<violation beginline="16" endline="16" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class PlaygroundWeather\Entity\Location is declared but never used. You should remove the use statement.</violation>
</file>
<file name="src/PlaygroundWeather/Form/Admin/CodeFieldset.php">
<violation beginline="6" endline="6" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class Zend\Form\Form is declared but never used. You should remove the use statement.</violation>
<violation beginline="7" endline="7" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class Zend\Form\Element is declared but never used. You should remove the use statement.</violation>
</file>
<file name="src/PlaygroundWeather/Form/Admin/Code.php">
<violation beginline="4" endline="4" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class Zend\Form\Form is declared but never used. You should remove the use statement.</violation>
</file>
<file name="src/PlaygroundWeather/Form/Admin/FileImport.php">
<violation beginline="4" endline="4" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class Zend\Form\Form is declared but never used. You should remove the use statement.</violation>
</file>
<file name="src/PlaygroundWeather/Form/Admin/FilterFieldset.php">
<violation beginline="6" endline="6" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class Zend\Form\Form is declared but never used. You should remove the use statement.</violation>
<violation beginline="7" endline="7" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class Zend\Form\Element is declared but never used. You should remove the use statement.</violation>
</file>
<file name="src/PlaygroundWeather/Form/Admin/Filter.php">
<violation beginline="5" endline="5" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class Zend\Form\Form is declared but never used. You should remove the use statement.</violation>
</file>
<file name="src/PlaygroundWeather/Form/Admin/ImageMap.php">
<violation beginline="4" endline="4" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class Zend\Form\Form is declared but never used. You should remove the use statement.</violation>
<violation beginline="11" endline="11" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class PlaygroundWeather\Entity\Location is declared but never used. You should remove the use statement.</violation>
</file>
<file name="src/PlaygroundWeather/Form/Admin/Location.php">
<violation beginline="4" endline="4" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class Zend\Form\Form is declared but never used. You should remove the use statement.</violation>
</file>
<file name="src/PlaygroundWeather/Service/Cron.php">
<violation beginline="5" endline="5" rule="Unused use statement should be avoided" ruleset="deadcode" priority="5">The class ZfcBase\EventManager\EventProvider is declared but never used. You should remove the use statement.</violation>
</file>
</pmd>
ping @vralfy
I think u are in a vacation ? ping @vralfy
No, i just have to work ;)
Ok I submitted a version in branch "github_37b". Please checkout, install and tell me if its the right solution for you.. You can add a cs/pmd/cpd report file in Project Settings > phpcsmd
Note that violations will not be updated until you update the report file with your external tool (its not suitable for me to implement dozens of tools).
Anyway I recommend using phpcs/phpmd/phpcpd instead of a static report file.
Happy testing.
Good, keep going :)
Build throw this error:
Harness Directory: ${nbplatform.default.harness.dir}/build.xml
ant -f /{full-path}/phpcsmd -Dcontinue.after.failing.tests=true run
Target "run" does not exist in the project "de.foopara.phpcsmd".
BUILD FAILED (total time: 0 seconds)
Did you open the project with netbeans? My netbeans invokes ant -f /my path here/phpcsmd -Dcontinue.after.failing.tests=true netbeans Please open the project with netbeans, right click on the project, choose Install/Reload in Development IDE
:+1: good job :)
Because the static file report can be obsolete, why not to add another field to put the command that generate this report.
When I click on Tools => Scan for violations
, this plugin execute this command, the output of this command is a PMD report, analyze this report then show violation.
Actually it's the user who generate this report and I want this plugin to do this job.
any updates ?
I think thats not the intention for this plugin ... perhaps a new plugin which builds your project is the better way.