November 20, 2008, 06:35:00 pm *
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Metrics for spring-based project  (Read 1019 times)
stlecho
Newbie
*
Posts: 4


« on: January 28, 2008, 01:10:09 pm »

Hi,

I am currently working on Spring-based projects with quite a lot of XML-based configuration files. These configuration files can be considered as being part of the source code. Is there a way to include these XML-based configuration files in the Lines Of Code metrics produced by Semmle ?

Regards, Stefan Lecho.
Logged
Mathieu Verbaere
Administrator
Newbie
*****
Posts: 26


« Reply #1 on: January 30, 2008, 09:02:15 am »

Hi Stefan,

Thank you for your interest. There is indeed a way to get the number of lines of an XML file, and we will add it in the default library in the next version. Until then, you need to include this .QL class in your query or personal library:

Code:
class MetricXMLFile extends XMLFile {
  Location getLocation() { files(this,_,_,_,result) }
  int getNumberOfLines() {
    result = this.getLocation().getNumberOfLines()
  }
}

and use it in the following way to get the total number of lines for all Java and XML files in your working set:

Code:
select
  sum(MetricPackage p | p.fromSource() | p.getNumberOfLinesOfCode())
  + sum(MetricXMLFile f | | f.getNumberOfLines()) as numberOfLines

Hope it helps.
Logged
stlecho
Newbie
*
Posts: 4


« Reply #2 on: January 30, 2008, 10:57:09 am »

Hi Mathieu,

It works, thanks for your input  Smiley.

Regards, Stefan Lecho.
Logged
Pages: [1]
  Print  
 
Jump to: