terryyin / lizard

A simple code complexity analyser without caring about the C/C++ header files or Java imports, supports most of the popular languages.
Other
1.82k stars 248 forks source link

Underreport a js function #302

Open cyw3 opened 3 years ago

cyw3 commented 3 years ago

when i scan the file below with lizard 1.17.5, render() can not be reported.

class CanvasElement extends Component {
    render() {
        return (
            <React.Fragment>
                <div onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
                </div>
                {this.renderHistoryBorder()}
            </React.Fragment>
        );
    }
}

output:

================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
       4      1     12      0       4 this.renderHistoryBorder@10-13@/Users/xxx/canvas-element.js
1 file analyzed.
==============================================================
NLOC    Avg.NLOC  AvgCCN  Avg.token  function_cnt    file
--------------------------------------------------------------
     11       4.0     1.0       12.0         1     /Users/xxx/canvas-element.js

===============================================================================================================
No thresholds exceeded (cyclomatic_complexity > 15 or length > 1000 or nloc > 1000000 or parameter_count > 100)
==========================================================================================
Total nloc   Avg.NLOC  AvgCCN  Avg.token   Fun Cnt  Warning cnt   Fun Rt   nloc Rt
------------------------------------------------------------------------------------------
        11       4.0     1.0       12.0        1            0      0.00    0.00

And when remove the line of {this.renderHistoryBorder()}:


class CanvasElement extends Component {
    render() {
        return (
            <React.Fragment>
                <div onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
                </div>
            </React.Fragment>
        );
    }
}

output:

================================================
  NLOC    CCN   token  PARAM  length  location
------------------------------------------------
       8      1     26      0       8 render@3-10@/Users/xxx/canvas-element.js
1 file analyzed.
==============================================================
NLOC    Avg.NLOC  AvgCCN  Avg.token  function_cnt    file
--------------------------------------------------------------
     10       8.0     1.0       26.0         1     /Users/xxx/canvas-element.js

===============================================================================================================
No thresholds exceeded (cyclomatic_complexity > 15 or length > 1000 or nloc > 1000000 or parameter_count > 100)
==========================================================================================
Total nloc   Avg.NLOC  AvgCCN  Avg.token   Fun Cnt  Warning cnt   Fun Rt   nloc Rt
------------------------------------------------------------------------------------------
        10       8.0     1.0       26.0        1            0      0.00    0.00