Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Visual Studio Code Analysis Lines of Code do with HTML, CSS and Javascript?

I know that Lines of Code (LoC) is a dubious if not false code metric and there are lots of posts to this effect.

However ... I still have to provide a LoC count for a web site in a report.

I was using the Visual Studio 2010 Code Analysis Code Metrics feature to get the LoC when I wondered what does it do with or how does it count HTML, CSS and Javascript?

The VS Help text provides this description of the metric -

Lines of Code – Indicates the approximate number of lines in the code. The count is based on the IL code and is therefore not the exact number of lines in the source code file. A very high count might indicate that a type or method is trying to do too much work and should be split up. It might also indicate that the type or method might be hard to maintain.

So my multi part question is ... does HTML, CSS, Javascript get compiled to IL and if it does then should I assume it is included in the VS LoC metric? If it does not get compiled to IL, what is the best way to calculate or include HTML, CSS and Javascript in the LoC metric for my report? Or should they even be included in LoC at all?

like image 391
Scott Wylie Avatar asked Jan 26 '12 00:01

Scott Wylie


People also ask

Does Visual Studio support HTML CSS and JavaScript?

Visual Studio offers powerful HTML, CSS, JavaScript, and JSON editors. Tap into the power of LESS, and Sass, use PHP, Python, or C# with ASP.NET. All the popular languages are supported and you can move between languages and project types with ease.

Is Visual Studio Code good for HTML and CSS?

Visual Studio Code provides basic support for HTML programming out of the box. There is syntax highlighting, smart completions with IntelliSense, and customizable formatting. VS Code also includes great Emmet support.

How do I run HTML and JavaScript together in Visual Studio Code?

Method 1: Use HTML script tag Create an HTML file in VS Code and inside the file, add the script tags. You can write JavaScript code inside the script tags. Save the changes and then open the HTML file in the browser. In the browser, open the inspect window by right-clicking the mouse and select Inspect option.


2 Answers

I think it does not count them, and this is clearly the most well thought out response in the history of Stack Overflow based on line count. Also to count lines in your JavaScript files try

find . -name '*.js' | xargs wc -l
like image 102
JSager Avatar answered Sep 28 '22 23:09

JSager


Does HTML, CSS, Javascript get compiled to IL?

No - those files are static. The only time they get compiled is if you compose them in code behind and add them to the Response buffer directly.

If it does not get compiled to IL, what is the best way to calculate or include HTML, CSS and Javascript in the LoC metric for my report? Or should they even be included in LoC at all?

I would say counting those files may not be of much use -- although getting a handle on JavaScript file size could be of importance as it would have some effect on page load times (larger files will take longer to download -- but unless you have 20K lines of JavaScript, it shouldn't be a huge difference).

There are a few tools out there that count lines of code for all file types. Microsoft's LOC counter is here. Also, tools like NDepend (which has a free trial) can count lines of code, too.

like image 38
David Hoerster Avatar answered Sep 28 '22 23:09

David Hoerster