@@ -103,55 +103,46 @@ bool CppMetricsParser::cleanupDatabase()
103
103
104
104
void CppMetricsParser::afferentCouplingTypeLevel ()
105
105
{
106
-
107
- // Calculate the cohesion metric for all types on parallel threads.
108
- parallelCalcMetric<model::AfferentRecordView>(
109
- " Afferent coupling" ,
110
- _threadCount * lackOfCohesionPartitionMultiplier, // number of jobs; adjust for granularity
111
- getFilterPathsQuery<model::AfferentRecordView>(),
112
- [&, this ](const MetricsTasks<model::AfferentRecordView>& tasks)
106
+ util::OdbTransaction{_ctx.db }([&,this ]
113
107
{
114
- util::OdbTransaction{_ctx.db }([&,this ]
115
- {
116
- std::set<std::uint64_t > typesFound;
117
- std::unordered_map<std::uint64_t , int > typeFoundCnt;
118
- std::unordered_map<std::uint64_t ,std::uint64_t > astNodeIdOfType;
108
+ std::set<std::uint64_t > typesFound;
109
+ std::unordered_map<std::uint64_t , int > typeFoundCnt;
110
+ std::unordered_map<std::uint64_t ,std::uint64_t > astNodeIdOfType;
119
111
120
- for (const model::AfferentRecordView& type
121
- : _ctx.db ->query <model::AfferentRecordView>())
112
+ for (const model::AfferentRecordView& type
113
+ : _ctx.db ->query <model::AfferentRecordView>())
114
+ {
115
+ if (!cc::util::isRootedUnderAnyOf (_inputPaths, type.filePath ))
122
116
{
123
- if (!cc::util::isRootedUnderAnyOf (_inputPaths, type.filePath ))
124
- {
125
- continue ;
126
- }
127
-
128
- typesFound.clear ();
129
- for (const model::CppMemberType& member : _ctx.db ->query <model::CppMemberType>(
130
- odb::query<cc::model::CppMemberType>::typeHash == type.entityHash &&
131
- odb::query<cc::model::CppMemberType>::kind == model::CppMemberType::Kind::Field))
132
- {
133
- typesFound.insert (member.memberTypeHash );
134
- }
135
-
136
- astNodeIdOfType[type.typeHash ] = type.astNodeId ;
117
+ continue ;
118
+ }
137
119
138
- for (const auto & t : typesFound)
139
- {
140
- typeFoundCnt[t]++;
141
- }
120
+ typesFound.clear ();
121
+ for (const model::CppMemberType& member : _ctx.db ->query <model::CppMemberType>(
122
+ odb::query<cc::model::CppMemberType>::typeHash == type.entityHash &&
123
+ odb::query<cc::model::CppMemberType>::kind == model::CppMemberType::Kind::Field))
124
+ {
125
+ typesFound.insert (member.memberTypeHash );
142
126
}
143
127
144
- for (const auto & pair : typeFoundCnt)
128
+ astNodeIdOfType[type.typeHash ] = type.astNodeId ;
129
+
130
+ for (const auto & t : typesFound)
145
131
{
146
- model::CppAstNodeMetrics metric;
147
- metric.astNodeId = astNodeIdOfType[pair.first ];
148
- metric.type = model::CppAstNodeMetrics::Type::AFFERENT_COUPLING;
149
- metric.value = pair.second ;
150
- _ctx.db ->persist (metric);
132
+ typeFoundCnt[t]++;
151
133
}
152
-
134
+ }
135
+
136
+ for (const auto & pair : typeFoundCnt)
137
+ {
138
+ model::CppAstNodeMetrics metric;
139
+ metric.astNodeId = astNodeIdOfType[pair.first ];
140
+ metric.type = model::CppAstNodeMetrics::Type::AFFERENT_COUPLING;
141
+ metric.value = pair.second ;
142
+ _ctx.db ->persist (metric);
143
+ }
144
+
153
145
154
- });
155
146
});
156
147
}
157
148
0 commit comments