kisstkondoros / codemetrics Goto Github PK
View Code? Open in Web Editor NEWVSCode extension which shows the complexity information for TypeScript class members
License: Other
VSCode extension which shows the complexity information for TypeScript class members
License: Other
It would be nice to have a certain way to ignore/suppress specific functions checks. I would like the code metric algorithm to skip certain functions by passing an ignore tag or something similar like eslint would be nice: http://eslint.org/docs/user-guide/configuring.html#configuring-rules
For an instance:
/* @cm ignore-next-function */
this.fucntionName = new Funciton()
{
...
}
Developing under ES3 sometimes requires larger constructs which I would manually like to ignore or skip in some way.
I noticed that class complexity is the sum of its parts, but I think if you're going to do that, then there needs to be some sort of acceptable baseline that isn't dependent on the calculation of the function complexity.
A class is made up of methods, properties, and potentially a constructor. The complexity of the methods themselves should play an insignificant role in the complexity of the overall Class; possibly 5% of the method complexity, rounded up towards the Class complexity threshold.
The baselines that need to be established are as follows
I believe no matter what, this is a very subjective complexity assessment, seeing as Classes are inherently contextual. Because of this, in the interim, it would be nice to be able to hide the current vastly inaccurate assessment of Classes.
Thanks for your time โค๏ธ
Hi,
Recently started using this extension and it is neat however a brief explanation would be useful to myself and perhaps other users.
thanks,
Peter
It's possible to add support for .vue files? Excellent plugin btw.
I see this error a lot in production and when developing extensions it makes the debugger always break there...
Cannot read property 'document' of undefined: TypeError: Cannot read property 'document' of undefined
at Timeout._onTimeout (/Users/jrieken/.vscode-insiders/extensions/kisstkondoros.vscode-codemetrics-1.7.0/out/editordecoration/EditorDecoration.js:40:59)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
yeah yeah.. I know.. but still.. it kind of bugs me ;)
I understand metrics are important but the code lenses for arrow functions inside my code appear visually noisy to me. I'd prefer to see them member functions only and have a command that show the for others on demand.
Hi, love what you did here!
A lot of my code involves arrow functions, would you consider supporting them (if I'm missing an option to enable them)?
When code metrics is enabled, and a portion of code is selected the quick fix bulb does not appear, neither pressing Cmd+.
When the extension is disabled, the quick fix bulb appears again.
It would be awesome if there was an option to tell CodeMetrics to ignore files whose path matches a glob/pattern, specifically node_modules/**/*
. Often times when I drill down to the TypeScript definition or source for an npm
package, VSCode will freeze for while as CodeMetrics does its work. In general, I don't really care about the metrics or complexity of a dependency. I would like to be able to tell CodeMetrics to ignore those files altogether. In the meanwhile, I am trying out codemetrics.basics.FileSizeLimitMB
to see if it can be adjusted to a reasonable value that will filter out large files from dependencies without impacting my ability to analyze my own source files.
I've tried a couple of things but the only one that actually works is using the command "Toggle code lenses for arrow functions". I would like to set a setting in my user config so it is toggled on by default. codemetrics.basics.MetricsForArrowFunctionsToggled
does not make any difference for me.
Is this already possible, if so how?
Hi,
is it possible to remove the text like "Complexity is 6 It's time to do something" above the function and just get a colored rectangle and the text is only shown as tooltip?
Best,
Phlpp
function example() {
return {
a: {},
b: {},
};
}
this has a cyclomatic complexity of 1 (no branching whatsoever) and is given a complexity rating of 5, which is unusual.
Hey there,
thanks for the this awesome plugin.
I use it every day. ๐ ๐ ๐
Now I am working on a bigger project.
It has lots of huge methods and classes.
It would save me lots of time if I could simply generate a report telling me which file has classes and methods containing a complexity higher than 6 , 8 or 10
,
What do you think is it possible to add this feature?
Kind regards
Greg
Hi, I've just installed the extension (v 1.2.0) in VS Code. It shows complexity at the top of a class declaration, but not for individual methods. Having seen the example screenshots, it may not be working as designed. I would expect complexity to be shown on top of functions. Additionally, it seems class complexity is calculated as sum of member complexities, which is arguably OK, but is there would need to be different complexity limits for classes and class memebers. (5 max limit is good for functions, but not so much for classes - code in the below example already breaks the limit.)
Using a Gulp tasks to compute TypeScript Code Complexity outside Visual Studio can be super helpful.
Below is a sample of how code coverage are displayed.
In addition, adding a configuration setting to produce a JSON or XML output will allow for the creation of a complete code metrics report. As of today I was unable to find any package for code complexity specifically for TypeScript. Please consider such a package.
I get this when I try > toggle code metrics
command 'codemetrics.toggleCodeMetricsDisplayed' not found
With version 1.7.0 the codemetrics results are shown on the panel triggered by Issue: #25. Is there a way to hide them there?
If not, would it be useful to make that configurable to be able to disable that?
Every time add one return
, the complexity will increase 1, it's a cool rule?
That's my first time know about return
make code complexity, can you help me understand about this!
How to exclude particular folder or file from code metric analysis.
E.g. I have a folder /dist or /build, which contains compiled js files, that I don't want to be analysed by CM, however I still see thousands of warnings in "PROBLEMS" tab for those files from codemetrics.
I don't want to exclude those folders from workspace either, I just want all code analysis tools to ignore those files.
Sorry if this is the wrong place to ask, but is there a way/plans to view the complexity in the bottom panel like with eslint?
just fyi great job but is it really necessary to pack the entire vscode app on the extension?
... is this some standard measurement? The extension looked interesting, so I installed it, but despite having a bunch of really complex code, I pretty much only see one warning from this plugin, on a really simple section:
function getIntentName() {
switch (type) {
case 'IntentRequest':
return req.data.request.intent && req.data.request.intent.name;
case 'LaunchRequest':
return 'LaunchRequest';
case 'SessionEndedRequest':
return 'SessionEndedRequest';
default:
return '';
}
}
See here: http://code.visualstudio.com/docs/extensionAPI/extension-points#_contributesconfiguration. It describes how to define extension specific configurations such that a user can easily discover and configure this extension
when i pass argument as object_literal
i get a high complexity level, is their anyway to reduce the complexity level for passing arguments as object_literal
because i am doing this for clarification and readability in the first place .
What were the metrics used as a reference?
Is there any way to run codemetrics on all files in workspace? And/or integrate it into a es/ts linters, webpack?
I have to restart VS Code several times in order to keep certain user settings with this extension installed. I narrowed it down to this extension. Any way to find what is happening?
I'm not sure if it's an issue or it's expected from your algorithm calculations.
Final sum is always added 1 point, seems it's putting function statement into account instead of just its body ("codemetrics.luaconfiguration.FunctionDeclaration": 1
).
Please see image below, I think it's self explanatory.
text example:
function a() { return 1 }
function b(p) {
return p ? 1 : 2
}
function c(p) { }
AFAIK, their cyclomatic complexity should be 1 for a
, 2 for b
, and 0 for c
.
Great work!
I have a suggestion based on another extension I use: TODO Highlight, that has a handy marker in the right scroll column when a Todo highlight has been inserted.
It seems like a great feature to me to have that is similar to the "decoration mode" currently. It's unobtrusive, but I can easily check a file to see where I may have some fat functions, etc. I could imagine it being another flag alongside decoration mode:
// A flag which indicates whether code metrics are shown as inline decoration
"codemetrics.basics.DecorationModeEnabled": true,
Personally, I would probably turn off decoration mode and prefer the scroll bar decorator color as it would be out of the way of my code. Then I could scan on the right, and home-in on the more subtle code lens text.
When I try to turn the Code Lens off, it doesn't work and show me the following error:
Running the contributed command:'codemetrics.showCodeMetricsCodeLensInfo' failed.
I have tried it on Ubuntu 17.10, both on the latest version of VSCode:
Version 1.18.1
Commit 929bacba01ef658b873545e26034d1a8067445e9
Date 2017-11-16T18:34:22.110Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64
As well as VSCode Insiders:
Version 1.19.0-insider
Commit 89b158e11cb1c3fe94a3876222478ed2d0549fc8
Date 2017-11-24T06:14:09.459Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64
Thanks for the tool! Would be happy to provide more details!
Why is this counted for 12 points?
`function textChoiceToNumber(value) {
switch (value) {
case 1:
return 'one';
case 2:
return 'two';
case 3:
return 'three';
case 4:
return 'four';
default:
return value;
}
}`
VS Code version: 1.18.1
Code Metrics Extension version: 1.11.0
When hovering the mouse over the little coloured square, it sometimes shows duplicate messages (two or even many more), as the below one:
After moved it to a new file and reloaded it, but this time it shows only one message:
I this package brings something really interesting to the table; however, I simply cannot bring myself to use it with having the tiny type next to my code. Is it possible to show codemetrics' messaging via icons next to the numbers? This is a common pattern used by linters, for example.
Hi all,
I cannot see metrics info,
toggle code metrics doesn't produce any info.
osx 10.11.6
vscode 1.10.2
extension version 1.2.2
Would it be possible to make this support JSX files as well?
If it's just a matter of adding checking for JavaScript React filetypes then i could have a go at it myself!
There is a Lua AST parser written in JavaScript (namely luaparse),.
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.