11'use strict'
22
3- const escomplex = require ( 'escomplex' )
3+ const escomplex = require ( 'typhonjs- escomplex' )
44const path = require ( 'path' )
55const read = require ( 'read-file' )
66
77function sanitize ( fileName , filePath , result ) {
88 return {
9- cyclomatic : result . aggregate . cyclomatic ,
10- cyclomaticDensity : result . aggregate . cyclomaticDensity ,
9+ cyclomatic : result . methodAggregate . cyclomatic ,
10+ cyclomaticDensity : result . methodAggregate . cyclomaticDensity ,
1111 file : {
1212 name : fileName ,
1313 path : filePath
1414 } ,
1515 halstead : {
16- bugs : result . aggregate . halstead . bugs ,
17- difficulty : result . aggregate . halstead . difficulty ,
18- effort : result . aggregate . halstead . effort ,
19- length : result . aggregate . halstead . length ,
20- time : result . aggregate . halstead . time ,
21- vocabulary : result . aggregate . halstead . vocabulary ,
22- volume : result . aggregate . halstead . volume
16+ bugs : result . methodAggregate . halstead . bugs ,
17+ difficulty : result . methodAggregate . halstead . difficulty ,
18+ effort : result . methodAggregate . halstead . effort ,
19+ length : result . methodAggregate . halstead . length ,
20+ time : result . methodAggregate . halstead . time ,
21+ vocabulary : result . methodAggregate . halstead . vocabulary ,
22+ volume : result . methodAggregate . halstead . volume
2323 } ,
2424 maintainability : result . maintainability ,
2525 sloc : {
26- logical : result . aggregate . sloc . logical ,
27- physical : result . aggregate . sloc . physical
26+ logical : result . methodAggregate . sloc . logical ,
27+ physical : result . methodAggregate . sloc . physical
2828 }
2929 }
3030}
@@ -36,9 +36,9 @@ module.exports.analyze = (source) => {
3636
3737 if ( Array . isArray ( source ) ) {
3838 source . forEach ( ( filePath ) => {
39- // let fullPath = path.resolve(__dirname, filePath)
40- let content = read . sync ( filePath , 'utf8' )
41- result = escomplex . analyse ( content )
39+ let fullPath = path . resolve ( __dirname , filePath )
40+ let content = read . sync ( fullPath , 'utf8' )
41+ result = escomplex . analyzeModule ( content )
4242 report = sanitize ( path . basename ( filePath ) , filePath , result )
4343 reports . push ( report )
4444 } )
@@ -47,6 +47,4 @@ module.exports.analyze = (source) => {
4747 return reports
4848}
4949
50- module . exports . getExtension = ( ) => {
51- return 'js'
52- }
50+ module . exports . extension = 'js'
0 commit comments