What would be a good way to measure the size of a JSP project?

Given an existing JSP project, I would like to get an idea of ​​the complexity / size of the "presentation" part of the project. Here is what I have done so far:

  • Pulled out a JSP list that was compiled from the production server in the last x months (which eliminates dead jsps).
  • Wrote a quick scanner to find JSP fragment files that are imported to compiled pages.
  • Pulled out the file size and timestamp from the file system.

So now I have a list of pages and fragments imported to these pages, along with their size, and the last time they were compiled and changed.

But I really need to know how complex the page is; Some of these pages have a lot of Java code. This is a big project, so going through every page and size would be tedious and probably not so accurate.

I was going to write another scanner that measured the code between <% and%>, but I wondered if there was any kind of indicator generator out there that could already do this. I would like it to output how the "big" page was and how the "big" code on the page. The point is to separate small, medium, large and huge pages, so the absolute measurement is less important than the relative.

EDIT: I wrote another scanner to count the number of JavaScript lines, Java lines (Scriptlet), HTML lines and taglib usage instances. Therefore, using the results of the scanner, I have some parameters that indicate "complexity". Not quite clean, but now everything is in order.

+3
source share
1 answer

So the problem is that you have Java code snippets interspersed with html, so no standard metrics tool will work.

Not quite off the shelf, but our Search Engine Source Code may come close. It is a tool for finding large codebases by indexing source code using precise lexical extrapolation. The relevance here is that it calculates SLOC, comment count, Halstead and Cyclomatic measurements of the files it indexes, so you get indicators if you simply ignore the search function. Metrics are generated in an XML file (with one "record" per source file), so you can do whatever further processing you want on them. See Discussion of metrics on a linked web page.

As long as we have the JSP lexer, it has not yet been tested with a search engine. We have built dozens of lexers, so it will be very easy for us (and we will be happy about it). This will give a direct answer.

If you don’t want to go this route, you can fulfill your simple idea of ​​extracting the code between <% and%>, upload it to files parallel to the original JSP files, and pass this code to the search engine through its (production) Java lexeme extractor for search engine and get your indicators this way. Lexers are very reliable in the fact of corrupted files, so the fact that the extracted Java fragments may not be entirely legal will not bother him a bit.

+1
source

All Articles