@@ -132,7 +132,7 @@ void CppMetricsParser::functionMcCabe()
132132 parallelCalcMetric<model::CppFunctionMcCabe>(
133133 " Function-level McCabe" ,
134134 _threadCount * functionMcCabePartitionMultiplier,// number of jobs; adjust for granularity
135- getFilterPathsQuery <model::CppFunctionMcCabe>(),
135+ getFunctionQuery <model::CppFunctionMcCabe>(),
136136 [&, this ](const MetricsTasks<model::CppFunctionMcCabe>& tasks)
137137 {
138138 util::OdbTransaction {_ctx.db } ([&, this ]
@@ -155,7 +155,7 @@ void CppMetricsParser::functionBumpyRoad()
155155 parallelCalcMetric<model::CppFunctionBumpyRoad>(
156156 " Bumpy road complexity" ,
157157 _threadCount * functionBumpyRoadPartitionMultiplier,// number of jobs; adjust for granularity
158- getFilterPathsQuery <model::CppFunctionBumpyRoad>(),
158+ getFunctionQuery <model::CppFunctionBumpyRoad>(),
159159 [&, this ](const MetricsTasks<model::CppFunctionBumpyRoad>& tasks)
160160 {
161161 util::OdbTransaction {_ctx.db } ([&, this ]
@@ -184,27 +184,19 @@ void CppMetricsParser::typeMcCabe()
184184 using AstNodeMet = model::CppAstNodeMetrics;
185185
186186 // Calculate type level McCabe metric for all types on parallel threads.
187- parallelCalcMetric<AstNode >(
187+ parallelCalcMetric<model::CohesionCppRecordView >(
188188 " Type-level McCabe" ,
189189 _threadCount * typeMcCabePartitionMultiplier,// number of jobs; adjust for granularity
190- odb::query<AstNode>::symbolType == AstNode::SymbolType::Type &&
191- odb::query<AstNode>::astType == AstNode::AstType::Definition,
192- [&, this ](const MetricsTasks<AstNode>& tasks)
190+ getCohesionRecordQuery (),
191+ [&, this ](const MetricsTasks<model::CohesionCppRecordView>& tasks)
193192 {
194193 util::OdbTransaction {_ctx.db } ([&, this ]
195194 {
196- for (const AstNode & type : tasks)
195+ for (const model::CohesionCppRecordView & type : tasks)
197196 {
198- // Skip if class is included from external library
199- type.location .file .load ();
200- const auto typeFile = _ctx.db ->query_one <model::File>(
201- odb::query<model::File>::id == type.location .file ->id );
202- if (!typeFile || !cc::util::isRootedUnderAnyOf (_inputPaths, typeFile->path ))
203- continue ;
204-
205197 // Skip if its a template instantiation
206198 const auto typeEntity = _ctx.db ->query_one <Entity>(
207- odb::query<Entity>::astNodeId == type.id );
199+ odb::query<Entity>::astNodeId == type.astNodeId );
208200 if (typeEntity && typeEntity->tags .find (model::Tag::TemplateInstantiation)
209201 != typeEntity->tags .cend ())
210202 continue ;
@@ -256,7 +248,7 @@ void CppMetricsParser::typeMcCabe()
256248 }
257249
258250 model::CppAstNodeMetrics typeMcMetric;
259- typeMcMetric.astNodeId = type.id ;
251+ typeMcMetric.astNodeId = type.astNodeId ;
260252 typeMcMetric.type = model::CppAstNodeMetrics::Type::MCCABE_TYPE;
261253 typeMcMetric.value = value;
262254 _ctx.db ->persist (typeMcMetric);
0 commit comments