mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-23 13:29:12 -06:00
Add checks for inline files in style checker
This commit is contained in:
Submodule ext/ghoul updated: 9a28e8b4a9...7279b3eb92
@@ -57,86 +57,62 @@ std::string TemplateVerifier<T>::documentation() const {
|
||||
|
||||
template <typename T>
|
||||
std::string Vector2Verifier<T>::type() const {
|
||||
using namespace std::string_literals;
|
||||
|
||||
return "Vector2<"s + typeid(T).name() + ">";
|
||||
return std::string("Vector2<") + typeid(T).name() + ">";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Vector3Verifier<T>::type() const {
|
||||
using namespace std::string_literals;
|
||||
|
||||
return "Vector3<"s + typeid(T).name() + ">";
|
||||
return std::string("Vector3<") + typeid(T).name() + ">";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Vector4Verifier<T>::type() const {
|
||||
using namespace std::string_literals;
|
||||
|
||||
return "Vector4<"s + typeid(T).name() + ">";
|
||||
return std::string("Vector4<") + typeid(T).name() + ">";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Matrix2x2Verifier<T>::type() const {
|
||||
using namespace std::string_literals;
|
||||
|
||||
return "Matrix2x2<"s + typeid(T).name() + ">";
|
||||
return std::string("Matrix2x2<") + typeid(T).name() + ">";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Matrix2x3Verifier<T>::type() const {
|
||||
using namespace std::string_literals;
|
||||
|
||||
return "Matrix2x3<"s + typeid(T).name() + ">";
|
||||
return std::string("Matrix2x3<") + typeid(T).name() + ">";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Matrix2x4Verifier<T>::type() const {
|
||||
using namespace std::string_literals;
|
||||
|
||||
return "Matrix2x4<"s + typeid(T).name() + ">";
|
||||
return std::string("Matrix2x4<") + typeid(T).name() + ">";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Matrix3x2Verifier<T>::type() const {
|
||||
using namespace std::string_literals;
|
||||
|
||||
return "Matrix3x2<"s + typeid(T).name() + ">";
|
||||
return std::string("Matrix3x2<") + typeid(T).name() + ">";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Matrix3x3Verifier<T>::type() const {
|
||||
using namespace std::string_literals;
|
||||
|
||||
return "Matrix3x3<"s + typeid(T).name() + ">";
|
||||
return std::string("Matrix3x3<") + typeid(T).name() + ">";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Matrix3x4Verifier<T>::type() const {
|
||||
using namespace std::string_literals;
|
||||
|
||||
return "Matrix3x4<"s + typeid(T).name() + ">";
|
||||
return std::string("Matrix3x4<") + typeid(T).name() + ">";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Matrix4x2Verifier<T>::type() const {
|
||||
using namespace std::string_literals;
|
||||
|
||||
return "Matrix4x2<"s + typeid(T).name() + ">";
|
||||
return std::string("Matrix4x2<") + typeid(T).name() + ">";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Matrix4x3Verifier<T>::type() const {
|
||||
using namespace std::string_literals;
|
||||
|
||||
return "Matrix4x3<"s + typeid(T).name() + ">";
|
||||
return std::string("Matrix4x3<") + typeid(T).name() + ">";
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Matrix4x4Verifier<T>::type() const {
|
||||
using namespace std::string_literals;
|
||||
|
||||
return "Matrix4x4<"s + typeid(T).name() + ">";
|
||||
return std::string("Matrix4x4<") + typeid(T).name() + ">";
|
||||
}
|
||||
|
||||
template <typename T, typename Operator>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
|
||||
@@ -314,6 +314,31 @@ def check_header_file(file, component):
|
||||
if using_namespaces:
|
||||
print(file, '\t', 'Using namespace found in header file')
|
||||
|
||||
def check_inline_file(file, component):
|
||||
with open(file, 'r+') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
copyright = check_copyright(lines)
|
||||
if copyright:
|
||||
print(file, '\t', 'Copyright check failed', '\t', copyright)
|
||||
return
|
||||
|
||||
header = check_glm_header(lines, file)
|
||||
if header:
|
||||
print(file, '\t', 'Illegal glm header include', header)
|
||||
return
|
||||
|
||||
core_dependency = check_core_dependency(lines, component)
|
||||
if core_dependency:
|
||||
print(file, '\t', 'Wrong dependency (core depends on module)', core_dependency)
|
||||
|
||||
if (not '_doc.inl' in file):
|
||||
# The _doc.inl files are allowed to use using namespace as they are inclued
|
||||
# from the cpp files and thus don't leak it
|
||||
using_namespaces = check_using_namespace(lines)
|
||||
if using_namespaces:
|
||||
print(file, '\t', 'Using namespace found in inline file')
|
||||
|
||||
|
||||
def check_source_file(file, component):
|
||||
with open(file, 'r+') as f:
|
||||
@@ -352,12 +377,27 @@ basePath = './'
|
||||
if len(sys.argv) > 1:
|
||||
basePath = sys.argv[1] + '/'
|
||||
|
||||
# Check header files
|
||||
print("Checking header files")
|
||||
print("=====================")
|
||||
check_files(basePath + 'include/**/*.h', '', 'openspace_core', check_header_file)
|
||||
check_files(basePath + 'apps/**/*.h', basePath + 'apps/**/ext/**/*.h', 'openspace_app', check_header_file)
|
||||
check_files(basePath + 'modules/**/*.h', basePath + 'modules/**/ext/**/*.h', 'openspace_module', check_header_file)
|
||||
check_files(basePath + 'ext/ghoul/include/**/*.h', '', 'ghoul', check_header_file)
|
||||
print("")
|
||||
|
||||
print("Checking inline files")
|
||||
print("=====================")
|
||||
check_files(basePath + 'include/**/*.inl', '', 'openspace_core', check_inline_file)
|
||||
check_files(basePath + 'src/**/*.inl', '', 'openspace_core', check_inline_file)
|
||||
check_files(basePath + 'apps/**/*.inl', basePath + 'apps/**/ext/**/*.h', 'openspace_app', check_inline_file)
|
||||
check_files(basePath + 'modules/**/*.inl', basePath + 'modules/**/ext/**/*.h', 'openspace_module', check_inline_file)
|
||||
check_files(basePath + 'ext/ghoul/include/**/*.inl', '', 'ghoul', check_inline_file)
|
||||
print("")
|
||||
|
||||
print("Checking source files")
|
||||
print("=====================")
|
||||
check_files(basePath + 'src/**/*.cpp', '', 'openspace_core', check_source_file)
|
||||
check_files(basePath + 'apps/**/*.cpp', basePath + 'apps/**/ext/**/*.cpp', 'openspace_app', check_source_file)
|
||||
check_files(basePath + 'modules/**/*.cpp', basePath + 'modules/**/ext/**/*.cpp', 'openspace_module', check_source_file)
|
||||
check_files(basePath + 'ext/ghoul/include/**/*.cpp', '', 'ghoul', check_source_file)
|
||||
check_files(basePath + 'ext/ghoul/src/**/*.cpp', '', 'ghoul', check_source_file)
|
||||
|
||||
Reference in New Issue
Block a user