November 20, 2008, 04:42:35 pm *
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: fetch first 10 rows only  (Read 1422 times)
Unpublished
Newbie
*
Posts: 6


« on: September 24, 2007, 03:19:08 pm »

Hi all,

first of all - thank's semmle for the usefull and nice tool!

I am just starting with automated code analyzing and are working currently in using simple metrics.
I want to expand the metrics queries with some "Top 10" lists e.g. "Top 10 large methods". Is there a way to limit the query result to a special number of lines (something like "fetch first 10 rows only in SQL).

Thank's for help and information

Best regards
Klaus


PS: As mentioned earlier in this forum the getNumberOfLines() method of MetricCallable also counts blank lines and comments. I think this is really not what someone expects when dealing with software quality. I hope something which will return the "noncomment and nonblank" line of sourcecode should be implemented soon.



« Last Edit: September 24, 2007, 03:31:37 pm by Unpublished » Logged
Mathieu Verbaere
Administrator
Newbie
*****
Posts: 26


« Reply #1 on: September 25, 2007, 11:31:10 am »

Hi Klaus,
 
You can limit the number of results for all queries in Preferences > SemmleCode.
Or you can achieve something similar with the following query:

Code:
class SourceMetricMethod extends MetricCallable {
  SourceMetricMethod() {
    this.fromSource() and
    this instanceof Method and
    this.getName() != "<clinit>"
  }
}

from SourceMetricMethod m, int n
where n = m.getNumberOfLines() and
          count(SourceMetricMethod m | m.getNumberOfLines() > n) < 10
select m, n order by n desc


In that case however, you may get slightly more than 10 results if there are large methods with the same number of lines.

As for ruling out blank lines and comments, we will add that soon.

Hope it helps.
Logged
Unpublished
Newbie
*
Posts: 6


« Reply #2 on: September 26, 2007, 11:41:49 am »

Hi Mathieu,

cool, this work's for me - thank's a lot.
Nevertheless it may would be usefull to have some kind of "fetch first...." thing to define individual number of results for different queries.

Regards
Klaus
Logged
elnar
Administrator
Newbie
*****
Posts: 17


« Reply #3 on: September 27, 2007, 07:47:17 am »

Thanks Klaus,

feature request is taken. We will try to have this feature in one of the next releases.

Elnar
Logged
Pages: [1]
  Print  
 
Jump to: