@@ -264,13 +264,28 @@ void CppMetricsParser::typeMcCabe()
264264 });
265265}
266266
267+ odb::query<model::CohesionCppRecordView> CppMetricsParser::getCohesionRecordQuery ()
268+ {
269+ odb::query<model::CohesionCppRecordView> query = getFilterPathsQuery<model::CohesionCppRecordView>();
270+
271+ if (_ctx.options .count (" cppmetrics-ignore-lambdas" )) {
272+ query = query && odb::query<model::CohesionCppRecordView>::CppRecord::isLambda == false ;
273+ }
274+
275+ if (_ctx.options .count (" cppmetrics-ignore-nested-classes" )) {
276+ query = query && odb::query<model::CohesionCppRecordView>::CppRecord::context != model::CppRecord::Context::RECORD;
277+ }
278+
279+ return query;
280+ }
281+
267282void CppMetricsParser::lackOfCohesion ()
268283{
269284 // Calculate the cohesion metric for all types on parallel threads.
270285 parallelCalcMetric<model::CohesionCppRecordView>(
271286 " Lack of cohesion" ,
272287 _threadCount * lackOfCohesionPartitionMultiplier, // number of jobs; adjust for granularity
273- getFilterPathsQuery<model::CohesionCppRecordView> (),
288+ getCohesionRecordQuery (),
274289 [&, this ](const MetricsTasks<model::CohesionCppRecordView>& tasks)
275290 {
276291 util::OdbTransaction {_ctx.db } ([&, this ]
@@ -376,7 +391,7 @@ void CppMetricsParser::efferentTypeLevel()
376391 parallelCalcMetric<model::CohesionCppRecordView>(
377392 " Efferent coupling of types" ,
378393 _threadCount * efferentCouplingTypesPartitionMultiplier,// number of jobs; adjust for granularity
379- getFilterPathsQuery<model::CohesionCppRecordView> (),
394+ getCohesionRecordQuery (),
380395 [&, this ](const MetricsTasks<model::CohesionCppRecordView>& tasks)
381396 {
382397 util::OdbTransaction{_ctx.db }([&, this ]
@@ -456,7 +471,7 @@ void CppMetricsParser::afferentTypeLevel()
456471 parallelCalcMetric<model::CohesionCppRecordView>(
457472 " Afferent coupling of types" ,
458473 _threadCount * afferentCouplingTypesPartitionMultiplier,// number of jobs; adjust for granularity
459- getFilterPathsQuery<model::CohesionCppRecordView> (),
474+ getCohesionRecordQuery (),
460475 [&, this ](const MetricsTasks<model::CohesionCppRecordView>& tasks)
461476 {
462477 util::OdbTransaction{_ctx.db }([&, this ]
@@ -697,6 +712,12 @@ extern "C"
697712 {
698713 boost::program_options::options_description description (" C++ Metrics Plugin" );
699714
715+ description.add_options ()
716+ (" cppmetrics-ignore-lambdas" ,
717+ " Skip Efferent/Afferent Coupling, Lack of Cohesion C++ metrics calculations for lambdas." )
718+ (" cppmetrics-ignore-nested-classes" ,
719+ " Skip Efferent/Afferent Coupling, Lack of Cohesion C++ metrics calculations for nested classes." );
720+
700721 return description;
701722 }
702723
0 commit comments