-
Notifications
You must be signed in to change notification settings - Fork 114
Efferent coupling of types #711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mcserep
merged 12 commits into
Ericsson:master
from
intjftw:efferent-coupling-type-level
Aug 30, 2024
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7478293
Efferent coupling of types.
intjftw b7dde23
The metric is actually correct now. Might need optimization.
intjftw 2a5beae
Optimized to be only calculated for user-defined types, and disposed …
intjftw 7125cce
Merge branch 'master' into efferent-coupling-type-level
intjftw 11f6e7a
Merge branch 'master' into efferent-coupling-type-level
intjftw 63481da
Adding inheritance to the efferent coupling of types.
intjftw 3e170a3
Fixing inheritance dependency calculation and adding efferent couplin…
intjftw d559bf7
Correctly calculating efferent coupling components for types.
intjftw a8f8897
Added multithreaded calculation to efferent coupling.
intjftw c44c0d0
Added multithreaded calculation to efferent coupling, with non-root p…
intjftw 1eaa71b
Merge branch 'master' into efferent-coupling-type-level
intjftw d2128e8
Fixed a bug in the C++ metrics service.
intjftw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| #include <cppmetricsparser/cppmetricsparser.h> | ||
| #include "efferent.h" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect inclusion order. Please refer to the coding conventions. |
||
|
|
||
| #include <model/cppastnodemetrics.h> | ||
| #include <model/cppastnodemetrics-odb.hxx> | ||
|
|
@@ -251,6 +252,9 @@ bool CppMetricsParser::parse() | |
| functionParameters(); | ||
| functionMcCabe(); | ||
| lackOfCohesion(); | ||
|
|
||
| EfferentCoupling efferent(_ctx, _inputPaths); | ||
| efferent.efferentTypeLevel(); | ||
| return true; | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #include <model/cpprecord.h> | ||
| #include <model/cpprecord-odb.hxx> | ||
| #include <model/cppastnodemetrics.h> | ||
| #include <model/cppastnodemetrics-odb.hxx> | ||
| #include <model/cppcohesionmetrics.h> | ||
| #include <model/cppcohesionmetrics-odb.hxx> | ||
|
|
||
| #include <util/filesystem.h> | ||
| #include <util/odbtransaction.h> | ||
|
|
||
| #include "efferent.h" | ||
|
|
||
| namespace cc | ||
| { | ||
| namespace parser | ||
| { | ||
|
|
||
| EfferentCoupling::EfferentCoupling( | ||
| ParserContext& ctx_, | ||
| std::vector<std::string>& inputPaths_) | ||
| : _ctx(ctx_), _inputPaths(inputPaths_) | ||
| { | ||
| } | ||
|
|
||
| void EfferentCoupling::efferentTypeLevel() | ||
| { | ||
| typedef odb::query<cc::model::CppMemberType> MemTypeQuery; | ||
|
|
||
| util::OdbTransaction{_ctx.db}([&, this] | ||
| { | ||
| std::set<std::uint64_t> memberTypes; | ||
| for (const model::CohesionCppRecordView& type | ||
| : _ctx.db->query<model::CohesionCppRecordView>()) | ||
| { | ||
| // Skip types that were included from external libraries. | ||
| if (!cc::util::isRootedUnderAnyOf(_inputPaths, type.filePath)) | ||
| continue; | ||
|
|
||
| memberTypes.clear(); | ||
| for (const model::CppMemberType& mem : _ctx.db->query<model::CppMemberType>( | ||
| MemTypeQuery::typeHash == type.entityHash && | ||
| MemTypeQuery::kind == model::CppMemberType::Kind::Field)) | ||
| { | ||
| memberTypes.insert(mem.memberTypeHash); | ||
| } | ||
|
|
||
| model::CppAstNodeMetrics metric; | ||
| metric.astNodeId = type.astNodeId; | ||
| metric.type = model::CppAstNodeMetrics::Type::EFFERENT_TYPE; | ||
| metric.value = memberTypes.size(); | ||
| _ctx.db->persist(metric); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| } // parser | ||
| } // cc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #ifndef CC_PARSER_EFFERENT_H | ||
| #define CC_PARSER_EFFERENT_H | ||
|
|
||
| #include "parser/parsercontext.h" | ||
|
|
||
| namespace cc | ||
| { | ||
| namespace parser | ||
| { | ||
|
|
||
| class EfferentCoupling | ||
| { | ||
| public: | ||
| EfferentCoupling( | ||
| ParserContext& ctx_, | ||
| std::vector<std::string>& inputPaths_); | ||
|
|
||
| void efferentTypeLevel(); | ||
|
|
||
| private: | ||
| ParserContext _ctx; | ||
| std::vector<std::string> _inputPaths; | ||
| }; | ||
|
|
||
| } // parser | ||
| } // cc | ||
|
|
||
| #endif // CC_PARSER_EFFERENT_H |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
efferent.hshould also be added here, so CMake can recognize that in case the header file changes, recompilation of the target is required.