简体   繁体   English

Visual Studio代码分析行代码对HTML,CSS和Javascript有何作用?

[英]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. 我知道代码行(LoC)是一个可疑的,如果不是错误的代码度量标准,并且有很多帖子可以达到这种效果。

However ... I still have to provide a LoC count for a web site in a report. 但是......我仍然需要在报告中为网站提供LoC计数。

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? 我正在使用Visual Studio 2010代码分析代码度量标准功能来获取LoC,当我想知道它是如何处理或如何计算HTML,CSS和Javascript?

The VS Help text provides this description of the metric - VS帮助文本提供了该指标的描述 -

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. 计数基于IL代码,因此不是源代码文件中的确切行数。 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? 所以我的多部分问题是...... HTML,CSS,Javascript是否被编译为IL,如果确实如此,那么我应该假设它包含在VS LoC指标中吗? 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? 如果它没有被编译到IL,那么在我的报告的LoC指标中计算或包含HTML,CSS和Javascript的最佳方法是什么? Or should they even be included in LoC at all? 或者他们甚至应该被包括在LoC中?

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 JavaScript的
files
try 尝试

find . -name '*.js' | xargs wc -l

Does HTML, CSS, Javascript get compiled to IL? HTML,CSS,Javascript是否被编译为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. 它们被编译的唯一时间是你在后面的代码中组合它们并直接将它们添加到Response缓冲区。

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? 如果它没有被编译到IL,那么在我的报告的LoC指标中计算或包含HTML,CSS和Javascript的最佳方法是什么? Or should they even be included in LoC at all? 或者他们甚至应该被包括在LoC中?

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). 我会说计算这些文件可能没什么用处 - 尽管掌握JavaScript文件大小可能很重要,因为它会对页面加载时间产生一些影响(较大的文件下载时间会更长 - 但除非你有20K行的JavaScript,应该不是一个巨大的差异)。

There are a few tools out there that count lines of code for all file types. 有一些工具可以计算所有文件类型的代码行数。 Microsoft's LOC counter is here . 微软的LOC计数器就在这里 Also, tools like NDepend (which has a free trial) can count lines of code, too. 此外, NDepend (有免费试用版)等工具也可以计算代码行数。

Is HTML/CSS/JS compiled to IL? HTML / CSS / JS是否编译为IL? It's possible (and also a good idea) to compile HTML templates to IL but I doubt it's done in your case. 将HTML模板编译为IL是可能的(也是一个好主意),但我怀疑它是否已经完成。 Your files are probably just static and served on request. 您的文件可能只是静态的,可根据要求提供。

Alternative? 另类? CodeAnalyze as in How do you count your Lines of Code? CodeAnalyze 如何计算你的代码行?

Include HTML/CSS/JS in LoC? 在LoC中包含HTML / CSS / JS? If you need this statistic to show how much you have done you might include all of them. 如果您需要此统计信息来显示您已完成的工作量,则可能包含所有这些统计信息。 If it's to get a rough idea of complexity I would only include Javascript files that you have written (exclude jQuery etc). 如果要粗略地了解复杂性,我只会包含您编写的Javascript文件(不包括jQuery等)。

It says right there that it's "based on the IL code". 它说那是“基于IL代码”。 By definition then it cannot include non-IL languages such as HTML, CSS, and Javascript. 根据定义,它不能包括非IL语言,如HTML,CSS和Javascript。

Not sure how you can come up with this count, but I would be concerned about whomever is requiring you to provide such a count -- it is a useless metric, particularly for those langauges. 不知道你怎么能算出这个数字,但是我会担心谁会要求你提供这样的计数 - 这是一个无用的指标,特别是那些语言。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM