apm::metrics_internal (private)
apm::metrics_internal package_key file_type
Defined in packages/acs-tcl/tcl/apm-procs.tcl
The cached version of apm::metrics
- Parameters:
- package_key (required)
- file_type (required)
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: array set metrics {} set package_path [acs_package_root_dir $package_key] # We'll be using apm_get_package_files to get a list of files # by file type. switch -- $file_type { data_model_pg - data_model_ora { set file_types [list data_model_create data_model] } default { set file_types $file_type } } set filelist [apm_get_package_files -include_data_model_files -all_db_types -package_key $package_key -file_types $file_types] # filelist needs to be weeded for certain file types switch -- $file_type { include_page - content_page { # weed out non-.adp files set adp_files {} foreach file $filelist { if { [string match {*.adp} $file] } { lappend adp_files $file } } set filelist $adp_files } data_model_pg { # ignore drop and upgrade scripts set pg_files {} foreach file $filelist { if { [string match {*/postgresql/*} $file] && ![string match "*-drop.sql" $file] && ![string match {*/upgrade/*} $file] } { lappend pg_files $file } } set filelist $pg_files } data_model_ora { # ignore drop and upgrade scripts set ora_files {} foreach file $filelist { if { [string match {*/oracle/*} $file] && ![string match "*-drop.sql" $file] && ![string match {*/upgrade/*} $file] } { lappend ora_files $file } } set filelist $ora_files } } # read the files, so we can count lines and grep for procs set filedata [apm::read_files $package_path $filelist] # The first metrics are easy and generic set metrics(count) [llength $filelist] set lines [split $filedata \n] set metrics(lines) [llength $lines] set metrics(blank_lines) [regexp -all -line {^\s*$} $filedata] # # Count comment lines. We check here the comments available to # proc_doc and add these to the line comments below. # set metrics(comment_lines) 0 foreach file $filelist { if {[nsv_exists api_proc_doc_scripts packages/$package_key/$file]} { # # Add for every found entry in proc_doc the contents # obtained from the doc argument of ad_proc. # foreach p [nsv_get api_proc_doc_scripts packages/$package_key/$file] { set proc_doc [nsv_get api_proc_doc $p] set main_doc 0 if {[dict exists $proc_doc main]} { incr main_doc [llength [split [dict get $proc_doc main] \n]] } set return_doc 0 if {[dict exists $proc_doc return]} { incr return_doc [llength [split [dict get $proc_doc return] \n]] } incr metrics(comment_lines) $main_doc incr metrics(comment_lines) $return_doc #ns_log notice "$file: $p [nsv_exists api_proc_doc $p] main $main_doc return doc $return_doc" } } } # # Extract procs, depending on the file_type # switch -exact $file_type { tcl_procs { set metrics(procs) [regexp -all -line {^\s*ad_proc} $filedata] set metrics(comment_lines) [regexp -all -line {^\s*#} $filedata] } test_procs { set metrics(procs) [regexp -all -line {^\s*aa_register_case} $filedata] set metrics(comment_lines) [regexp -all -line {^\s*#} $filedata] } data_model_pg { set metrics(procs) [regexp -all -line -nocase {^\s*create\s+or\s+replace\s+function\s+} $filedata] set metrics(comment_lines) [regexp -all -line {^\s*--} $filedata] } data_model_ora { set metrics(procs) [expr {[regexp -all -line -nocase {^\s+function\s+} $filedata] + [regexp -all -line -nocase {^\s+procedure\s+} $filedata]}] set metrics(comment_lines) [regexp -all -line {^\s*--} $filedata] } default { # other file-types don't have procs set metrics(procs) 0 } } return [array get metrics]Generic XQL file: packages/acs-tcl/tcl/apm-procs.xql
PostgreSQL XQL file: packages/acs-tcl/tcl/apm-procs-postgresql.xql
Oracle XQL file: packages/acs-tcl/tcl/apm-procs-oracle.xql