mozilla / rust-code-analysis

Library to analyze and collect metrics on source code
https://mozilla.github.io/rust-code-analysis/
262 stars 46 forks source link

empty function name for cpp #1055

Closed baolef closed 5 months ago

baolef commented 1 year ago

When I run analysis for cxx file, it is unable to identify class member function name.

For example, the member function

void CuiConfigFunctionListBox::ClearAll()
/*  Description
    Deletes all entries in the FunctionListBox, all UserData and all
    possibly existing MacroInfo.
*/
{
    sal_uInt16 nCount = aArr.size();
    for ( sal_uInt16 i=0; i<nCount; ++i )
    {
        SfxGroupInfo_Impl *pData = aArr[i].get();

        if ( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT )
        {
            OUString* pScriptURI = static_cast<OUString*>(pData->pObject);
            delete pScriptURI;
        }

        if ( pData->nKind == SfxCfgKind::GROUP_SCRIPTCONTAINER )
        {
            XInterface* xi = static_cast<XInterface *>(pData->pObject);
            if (xi != nullptr)
            {
                xi->release();
            }
        }
    }

    aArr.clear();
    m_xTreeView->clear();
}

its output is

{"name":null,"start_line":310,"end_line":339,"kind":"function","spaces":[],"metrics":{"nargs":{"total_functions":0.0,"total_closures":0.0,"average_functions":0.0,"average_closures":0.0,"total":0.0,"average":0.0,"functions_min":0.0,"functions_max":0.0,"closures_min":0.0,"closures_max":0.0},"nexits":{"sum":0.0,"average":0.0,"min":0.0,"max":0.0},"cognitive":{"sum":8.0,"average":8.0,"min":8.0,"max":8.0},"cyclomatic":{"sum":5.0,"average":5.0,"min":5.0,"max":5.0},"halstead":{"n1":18.0,"N1":65.0,"n2":23.0,"N2":43.0,"length":108.0,"estimated_program_length":179.1005750152729,"purity_ratio":1.6583386575488233,"vocabulary":41.0,"volume":578.6156164987531,"difficulty":16.82608695652174,"level":0.05943152454780362,"effort":9735.836677609454,"time":540.8798154227475,"bugs":0.1519827383557585},"loc":{"sloc":30.0,"ploc":23.0,"lloc":12.0,"cloc":4.0,"blank":3.0,"sloc_average":30.0,"ploc_average":23.0,"lloc_average":12.0,"cloc_average":4.0,"blank_average":3.0,"sloc_min":30.0,"sloc_max":30.0,"cloc_min":4.0,"cloc_max":4.0,"ploc_min":23.0,"ploc_max":23.0,"lloc_min":12.0,"lloc_max":12.0,"blank_min":3.0,"blank_max":3.0},"nom":{"functions":1.0,"closures":0.0,"functions_average":1.0,"closures_average":0.0,"total":1.0,"average":1.0,"functions_min":1.0,"functions_max":1.0,"closures_min":0.0,"closures_max":0.0},"mi":{"mi_original":81.67528282898678,"mi_sei":69.4405024202566,"mi_visual_studio":47.763323291805136},"abc":{"assignments":0.0,"branches":0.0,"conditions":0.0,"magnitude":0.0,"assignments_average":0.0,"branches_average":0.0,"conditions_average":0.0,"assignments_min":0.0,"assignments_max":0.0,"branches_min":0.0,"branches_max":0.0,"conditions_min":0.0,"conditions_max":0.0}}}

where the name is null.

It seems that it is only able to identify names of those functions without namespace:: on the left. Is this behavior expected? Is it better to extract names for class member functions?