es-analysis / plato Goto Github PK
View Code? Open in Web Editor NEWJavaScript source code visualization, static analysis, and complexity tool
License: MIT License
JavaScript source code visualization, static analysis, and complexity tool
License: MIT License
globals
is now an jshint option which makes your config weird.
Can you simplify your jshint config to just an object with options? (and upgrade jshint)
Need it for https://github.com/sindresorhus/gulp-plato
In Windows when I try the example (modified for use from my project directory) I get an error:
plato -r -d report src/*.js
Output:
C:\node projects\mrteeth\node.js\beakerbridge>plato -d report -r ./*.js
fs.js:524
return binding.stat(pathModule._makeLong(path));
^
Error: ENOENT, no such file or directory 'C:\node projects\mrteeth\node.js\beake
rbridge\*.js'
at Object.fs.statSync (fs.js:524:18)
at exports.inspect.runReports (C:\Users\Jeremy\AppData\Roaming\npm\node_modu
les\plato\lib\plato.js:59:33)
at Array.forEach (native)
at exports.inspect.runReports (C:\Users\Jeremy\AppData\Roaming\npm\node_modu
les\plato\lib\plato.js:58:11)
at exports.inspect (C:\Users\Jeremy\AppData\Roaming\npm\node_modules\plato\l
ib\plato.js:113:7)
at C:\Users\Jeremy\AppData\Roaming\npm\node_modules\plato\node_modules\fs-ex
tra\node_modules\mkdirp\index.js:38:26
at Object.oncomplete (fs.js:297:15)
Instead I have to use:
plato -r -d report src/ *.js
Difference is the space between the path and the file filter.
I seem to get a good report (awesome!) but I do get a lot of errors...
Could not parse JSON from file report\files\commonComponents_tabPanelMain_demo_v
iew_DemoPanel_js\report.history.json
Could not parse JSON from file report\files\commonComponents_tabPanelMain_demo_v
iew_DemoToolbar_js\report.history.json
Could not parse JSON from file report\files\commonComponents_tabPanelMain_view_M
ainTabPanel_js\report.history.json
Could not parse JSON from file report\files\commonComponents_tabPanelMain_view_T
abPanelToolbar_js\report.history.json
Could not parse JSON from file report\files\commonComponents_tree_demo_app_model
_HardwareTreeGridModel_js\report.history.json
Could not parse JSON from file report\files\commonComponents_tree_demo_app_model
_HardwareTreeModel_js\report.history.json
Could not parse JSON from file report\files\commonComponents_tree_demo_app_store
HardwareTreeGridStore_js\report.history.json
Could not parse JSON from file report\files\commonComponents_tree_demo_app_store
HardwareTreeStore_js\report.history.json
Could not parse JSON from file report\files\commonComponents_tree_demo_app_view
TreeDemoTabPanel_js\report.history.json
Could not parse JSON from file report\files\commonComponents_tree_demo_app_view
Viewport_js\report.history.json
Could not parse JSON from file report\files\commonComponents_tree_demo_app_js\re
port.history.json
Could not parse JSON from file report\files\commonComponents_underlinedPanel_dem
o_app_js\report.history.json
Could not parse JSON from file report\files\commonComponents_underlinedPanel_Und
erlinedPanel_js\report.history.json
Could not parse JSON from file report\files\commonComponents_wizard_controller_W
izardController_js\report.history.json
Could not parse JSON from file report\files\commonComponents_wizard_demo_demo_js
\report.history.json
Could not parse JSON from file report\files\commonComponents_wizard_view_private
_WizardContentPane_js\report.history.json
Could not parse JSON from file report\files\commonComponents_wizard_view_private
_WizardHelpWindow_js\report.history.json
Could not parse JSON from file report\files\commonComponents_wizard_view_private
_WizardNavigation_js\report.history.json
Could not parse JSON from file report\files\commonComponents_wizard_view_private
WizardStepsPane_js\report.history.json
Could not parse JSON from file report\files\commonComponents_wizard_view_Wizard
js\report.history.json
Could not parse JSON from file report\files\commonComponents_wizard_view_WizardP
age_js\report.history.json
Could not parse JSON from file report\report.history.json
Done!
When you analyze code wrapped in a wrapper function, said function always gets a huge pizza slice () of the SLOC infographic in the report, even though the function is meaningless.
Example: https://github.com/sapo/Ink/blob/develop/Inkjs/Ink/UI/Toggle/1/lib.js
This file has a function starting in line 6, and wrapping the entire module. It is just a wrapper to create the module object (think module.exports) and return it, while getting all dependencies asynchronously, so I don't think it should count as the function with the most SLOC (although it CAN have if-statements and as such should appear in the cyclomatic complexity infograph.
Don't you think that an outmost function of a file, with no expressions outside, should not count towards SLOC statistics?
Remove dependency on the reports directory for history retention.
Tracking here : https://github.com/philbooth/complexityReport.js/issues/22
JSHint and ComplexityReport both support specifying additional file extensions to include in scanning which is great for a project that I'm working on that needs to save JavaScript files as .SCP files for use by the host application.
Could you add a command-line parameter to specify additional file extensions to Plato?
Is a score of 119 good?
how bad is a complexity score of 15?
Create a UI that optimizes viewing at a distance for metric displays.
v2 tracking
FYI, when I run plato on this file or this one on node 0.8.20 everything is fine. When I switch to node 0.9.10, the following message is output to the console, endlessly:
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
It doesn't matter if I change process.nextTick in my code to setImmediate or comment it out altogether (in the first example above). The second example does not do any recursion, timeouts, or nextTicks at all.
Ideally in statements, but SLOC would do for now.
I know the Cyclomatic Complexity is being used, but what are the other metrics being used and how are they calculated? For example, what is the calculation behind Average Maintainability?
It say:
plato [options] file1.js file2.js ... fileN.js
which indicate that all options are optional -d is not so it need to be:
plato -d <DIR> [other options] file1.js [file2.js ... fileN.js]
other files are also optional [ xxx ]
mean optional it's convention from unix.
The latest version I can find via npm is 0.6.2. Could you publish the 1.0.0? Thanks for your work :)
How do I exclude multiple directories?
I tried
plato -r -d report -x demo/* -x test/* src1 src2
but it only excludes test/, not demo/
I have a file that results in a maintainability index of NaN and when plato tries processing it I get the following error from plato-overview.js:111
Uncaught TypeError: Cannot call method 'toFixed' of null,
When I run jshint manually, my preferred settings are applied (i.e. "quotmark": "single"). I currently have no issues remaining with jshint.
However, when I execute plato like this:
plato -r -d -l .jshintrc report routes/
I've also tried to specify the absolute path, to no avail. The report gets generated well (it's awesome!) but a lot of the warnings indicate that it's not picking up the settings in my jshintrc file.
Any ideas? Thanks!
Title says it all -- even though .jshintrc
is basically JSON, jshint
actually accepts JavaScript-style double-slashed comments. plato
does not.
Is it possible to push the new version to npm?
PS: thanks for your great work!
In a large project it would be nice to quickly see the worst offenders in the files list. Maybe the files could be made sortable based on the results?
I am not sure if I am doing something incorrectly or if this is a known issue...
The reports are being generated correctly, but I am seeing the following warnings for each file. The paths are correct and the JSON files exist.
I am loading the plato task in another grunt plugin - not sure if that is pertinent.
Could not parse JSON from file /Users/jstrimp/castle-example/reports/analyze/files/a_js/report.history.json
Could not parse JSON from file /Users/jstrimp/castle-example/reports/analyze/files/x_js/report.history.json
Could not parse JSON from file /Users/jstrimp/castle-example/reports/analyze/files/y_js/report.history.json
Could not parse JSON from file /Users/jstrimp/castle-example/reports/analyze/report.history.json
v2 tracking.
Seems that even when there's a JSHint style global declaration /*global $ MyNameSpace*/
at the top of the file, Plato still flags namespaces as not defined.
It would be nice to have an option to pass in some files and have it just start up a web server rather than generating files. Thoughts?
$ plato -v
0.6.2
I have my file structure like below:
.
└── src
├── .jshintrc
├── bar.js
└── foo.js
The src/.jshintrc
file:
{
"undef": true,
"predef": ["define", "URL"]
}
Both src/foo.js
and src/bar.js
have the same content:
define();
These are my reproduce steps:
plato -d output -l src/.jshintrc -r ./src
in current directoryopen output/index.html
to view the resultIn result, I got:
src/bar.js lint errors: 0
src/foo.js lint errors: 1
And in report for src/foo.js
it gave the error message:
Column: 1 "'define' is not defined."
However, the expected lint errors
should all be 0
since my .jshintrc
file have define
in predef
field
Not sure how well it would work, but a website where you could just input an arbitrary git repo an get the stats.
This is what you see if you call plato -d <DIR>
/usr/lib/node_modules/plato/lib/util.js:14
var prefixlen = first.length;
^
TypeError: Cannot read property 'length' of undefined
at Object.exports.findCommonBase (/usr/lib/node_modules/plato/lib/util.js:14:24)
at Object.exports.inspect (/usr/lib/node_modules/plato/lib/plato.js:69:29)
at Object.exports.exec (/usr/lib/node_modules/plato/lib/cli.js:47:9)
at Object.<anonymous> (/usr/lib/node_modules/plato/bin/plato:19:5)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
adding regular expressions to exclude several directories is not very practical
or is there some easier way that I'm not aware of?
Specifying --exclude
multiple times doesn't work:
plato -r -d report --exclude lib --exclude extra my_js_directory
Of course using a regular expression does work:
plato -r -d report --exclude lib\|extra my_js_directory
I think using multiple --exclude
should probably work also.
v2 tracking
be able to have multiple projects / directory in the plato report
For example, i have a project with multiple directories which contains js code that i want to analyse with Plato and i want a seperation in the report.
If I'm not mistaken comment lines are being counted
more over, empty lines shouldn't be taken into account either
Some of my team is using the const keyword which is supported in V8/node.
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/const
Right now plato shows warnings for const declarations:
const DB_NAME = 'mydb';
Column: 1 "Expected an identifier and instead saw 'const'."
Column: 1 "Expected an assignment or function call and instead saw an expression."
Column: 6 "Missing semicolon."
Is it possible this could be recognized as valid syntax? Or possibly it already is with a commandline option like jshint?
Thanks for bulding such an awesome JavaScript static analysis tool!
when i Run the example command - I get this Error:
/opt/plato/lib/util.js:6
var prefixlen = first.length;
^
TypeError: Cannot read property 'length' of undefined
at Object.findCommonBase (/opt/plato/lib/util.js:6:24)
at Object.inspect (/opt/plato/lib/plato.js:55:29)
at Object.exec (/opt/plato/lib/cli.js:43:9)
at Object. (/opt/plato/bin/plato:19:5)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Array.0 (module.js:484:10)
at EventEmitter._tickCallback (node.js:190:38)
I was looking at using PMD-CPD-JavaScript with a new reporter to provide copy paste detection. How do you feel about using their jar file to handle this?
Hi,
I have found jsprime. It parses code tries to find security holes. Worth a look.
Maybe we can add it to plato along with jshint.
Its great to point plato at a full project and let it go. The complexity linking and etc are quite nice. Until of course you see your node_modules being included and having to filter them out if you follow the prj/bin/ prj/lib/ and prj/node_modules/ directory structure. Any way to add a don't report on flag please :)
Hello !
In your demo, for example with JQuery, names of the source files are like "src/ajax.js" (in the report)
When i try it on my project, filenames in the report are like :
if the path is : /my/full/path
and i have a file in the directory myFiles.js
so in the report the name is : my_full_path_myFiles.js
i launch the command : 'plato -r -d ~/Sites/plato /my/full/path'
Thanks in advance for your help
This project is awesome! Just wondering what you'd think of some kind of API mechanism, so that others can crete Plato plugins. I've seen in other issue threads that you've entertained the idea of code coverage reports, but the actual computing of the statistics should be handled outside of Plato. With a plugin API of some sort, people could create beautiful Plato reports for just about anything--code coverage, unit test failures, developer contribution statistics, etc.
Perhaps you could have a config file for registering custom plugins like this:
plugins: {
coverage: {
command: "grunt coverage",
expectedResult: "coverage-report.json"
}
}
So basically Plato would spawn 3rd party scripts/processes to "do something", and we would expect those scripts/processes to output their results in some kind of well-known JSON format, which Plato would then use to create a chart.
For instance, maybe the JSON output for a code coverage report could look like this:
{
"reportName": "Code Coverage",
"chartType": "lineChart",
"yAxis": "percent",
"xAxis": "currentDate",
"value": "72%"
}
This could be fed into the standard reporting mechanism that Plato uses to create historical reports over time. So in the above example, we could see the code coverage percentage trending up or down over time.
How can I use Plato from javascript instead of the commandline? I'm having trouble setting up Plato to be run as a script with npm and package json. https://github.com/isaacs/npm/issues/4403 It appears that I'm not allowed to specify strings with whitespace in them when setting up an item in the scripts
hash. This makes it impossible to specify a title unless I want to make something nondescript or just plain ugly. If I could just call Plato from javascript and pass it the arguments I want, then I could just set up my script
in package.json
to call node and feed it a filename.
In package.json this doesn't work because of the space in the title
"scripts": {
"generateReport": "plato --title \"Analysis of\" --recurse -d report src"
}
This would work though
"scripts": {
"generateReport": "node scriptCallingPlato.js"
}
The readme contains a changelog, but it seems horribly out of date. Any chance that could be updated all the way to the latest release?
Hi,
This is an awesome tool, would it be possible to add coffee script support?
Thanks
I tried running the following command:
plato -r -d reports -t "MEAN Framework" -x /node_modules|reports|\.json/ .
And got the following error
-bash: reports: command not found
-bash: .json/: No such file or directory
What am I doing wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.