Skip to content

Full ES6+ support via typhonjs-escomplex - #192

Merged
jsoverson merged 5 commits into
es-analysis:masterfrom
typhonjs-node-escomplex:master
Aug 9, 2016
Merged

Full ES6+ support via typhonjs-escomplex#192
jsoverson merged 5 commits into
es-analysis:masterfrom
typhonjs-node-escomplex:master

Conversation

@typhonrt

Copy link
Copy Markdown
Contributor

Greets folks... @jsoverson This PR updates plato to use typhonjs-escomplex which is a completely rewritten version of escomplex supporting ES6+ / ES7 / edge complexity reporting. Plato has been updated with mixed ES5 / ES6 tests, automatic detection for ES Modules / ES6 for JSHint options, normalized all of the accessing code and HTML templates removing previous shims for escomplex data.

@jsoverson

Copy link
Copy Markdown
Member

That's awesome @typhonrt, i'll run it against some test projects. Will this invalidate previous history data?

@typhonrt

typhonrt commented Jul 29, 2016

Copy link
Copy Markdown
Contributor Author

Sounds good. Let me know how things work out with expanded testing. I have only run the minimal tests that I extended with the 2 ES6 classes. I don't think the history will be invalidated. You can see file 12: FileHistory.js in the changed files and it's the same except for removing the escomplex shims that previously existed.

I'll have version 0.0.7 out by tomorrow and that will be a good version to set as the exact dependency until 0.1.0 is released. There are no expected changes for the data that plato depends on presently. I have to say though there will be a lot of extra data to add to plato in the near future.

@typhonrt

Copy link
Copy Markdown
Contributor Author

Just a little heads up.. I locked the typhonjs-escomplex version to 0.0.6 as 0.0.7 does have a final change to data structures involved. Previously the npm versioning was >=0.0.6; changed to 0.0.6. A very small change for module reports (and class reports / unseen by plato currently) is aggregate to methodAggregate which better describes the data at hand; there is matching methodAveragedata which contains all averaged data in module / class reports, etc. No biggie. Once I get 0.0.7 released and such I'll update this PR w/ the necessary change.

@jsoverson

Copy link
Copy Markdown
Member

Just about to merge and saw the commit, are you comfortable with the state now?

@typhonrt

typhonrt commented Aug 3, 2016

Copy link
Copy Markdown
Contributor Author

Yes, but you might wait until tomorrow. In running Plato against a large project, esdoc everything was fine, but I noticed that typhonjs-escomplex wasn't picking up computed method names correctly for string literal values. An example from esdoc. IE all the string literal computed methods were assigned <anonymous>. I'm just about to push out 0.0.8 in the coming hours which provides a solution.

So, it's great to see that getting this working with Plato helped discover a case that somehow escaped the thousands of tests in typhonjs-escomplex!

I'll post a further update here once I get 0.0.8 out. Nothing will change with the Plato integration except setting the typhonjs-escomplex version to 0.0.8; just better support for computed method / function names.

@typhonrt

typhonrt commented Aug 3, 2016

Copy link
Copy Markdown
Contributor Author

@jsoverson... We're good to go! I significantly hardened computed method names and metrics gathering of the same. Not only are string literals (example) picked up, but any complex computed name is intelligently handled. IE:

class Foo
{
   ['foobar']() {...}
   [foo+bar+baz]() {...}
   [foo.bar+baz]() {...}
   [foo.bar+baz.toLowerCase()]() {...}
   [Symbol.iterator]() {...}
}

Resolve to method names foobar, <computed~foo + bar + baz>, <computed~foo.bar + baz>, <computed~foo.bar + baz.toLowerCase()>, <computed~Symbol.iterator>, etc. Previously before the hardening all of the above would have been named <anonymous>.

The individual Halstead operators + operands are all picked up for the above computed method names as well.

Ship it!

It'd be neat to get grunt-plato updated too.. ;)


It should be noted that arrow functions at the module scope are anonymous. The CSS / template of Plato currently requires unique names for the context linking / highlight box displayed when mousing over methods. IE

const s_SOME_METHOD = () => {...};
const s_OTHER_METHOD = () => {...}; 

are both named <anonymous> so the template / CSS of Plato should be updated to add a counter or unique ID to method names that are the same, so the linking works.

@jsoverson
jsoverson merged commit 7d7868d into es-analysis:master Aug 9, 2016
@typhonrt

typhonrt commented Aug 9, 2016

Copy link
Copy Markdown
Contributor Author

🎱 @jsoverson I'm working on finishing refinements to typhonjs-escomplex and doing a thorough overview of all the data collected. I'll post another PR with the version bump to typhonjs-escomplex when that is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants