Skip to content

Commit

Permalink
Bumpy road complexity metrics (#738)
Browse files Browse the repository at this point in the history
Co-authored-by: Bükki Dániel <dbukki@freemail.hu>
  • Loading branch information
mcserep and dbukki authored Apr 29, 2024
1 parent 194afa2 commit 5bfc159
Show file tree
Hide file tree
Showing 16 changed files with 1,387 additions and 375 deletions.
22 changes: 22 additions & 0 deletions plugins/cpp/model/include/model/cppfunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ struct CppFunction : CppTypedEntity
std::vector<odb::lazy_shared_ptr<CppVariable>> parameters;
#pragma db on_delete(cascade)
std::vector<odb::lazy_shared_ptr<CppVariable>> locals;

unsigned int mccabe;
unsigned int bumpiness;
unsigned int statementCount;

std::string toString() const
{
Expand Down Expand Up @@ -82,6 +85,25 @@ struct CppFunctionMcCabe
std::string filePath;
};

#pragma db view \
object(CppFunction) \
object(CppAstNode : CppFunction::astNodeId == CppAstNode::id) \
object(File : CppAstNode::location.file)
struct CppFunctionBumpyRoad
{
#pragma db column(CppEntity::astNodeId)
CppAstNodeId astNodeId;

#pragma db column(CppFunction::bumpiness)
unsigned int bumpiness;

#pragma db column(CppFunction::statementCount)
unsigned int statementCount;

#pragma db column(File::path)
std::string filePath;
};

}
}

Expand Down
3 changes: 2 additions & 1 deletion plugins/cpp/parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ add_library(cppparser SHARED
src/ppmacrocallback.cpp
src/relationcollector.cpp
src/doccommentformatter.cpp
src/diagnosticmessagehandler.cpp)
src/diagnosticmessagehandler.cpp
src/nestedscope.cpp)

target_link_libraries(cppparser
cppmodel
Expand Down
Loading

0 comments on commit 5bfc159

Please sign in to comment.