From 3274882ec2de312ebf0c23230ad23a8a1219f724 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 1 Mar 2017 21:17:12 -0500 Subject: [PATCH] Add checks for inline files in style checker --- ext/ghoul | 2 +- include/openspace/documentation/verifier.inl | 48 +++++--------------- include/openspace/util/factorymanager.inl | 2 +- support/coding/check_style_guide.py | 42 ++++++++++++++++- 4 files changed, 55 insertions(+), 39 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 9a28e8b4a9..7279b3eb92 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 9a28e8b4a9135af6104a4c62950f47c364fc3411 +Subproject commit 7279b3eb924d1d90bf4dfa46e2f44a9a6f3a90a5 diff --git a/include/openspace/documentation/verifier.inl b/include/openspace/documentation/verifier.inl index 06228a7622..7256f9473a 100644 --- a/include/openspace/documentation/verifier.inl +++ b/include/openspace/documentation/verifier.inl @@ -57,86 +57,62 @@ std::string TemplateVerifier::documentation() const { template std::string Vector2Verifier::type() const { - using namespace std::string_literals; - - return "Vector2<"s + typeid(T).name() + ">"; + return std::string("Vector2<") + typeid(T).name() + ">"; } template std::string Vector3Verifier::type() const { - using namespace std::string_literals; - - return "Vector3<"s + typeid(T).name() + ">"; + return std::string("Vector3<") + typeid(T).name() + ">"; } template std::string Vector4Verifier::type() const { - using namespace std::string_literals; - - return "Vector4<"s + typeid(T).name() + ">"; + return std::string("Vector4<") + typeid(T).name() + ">"; } template std::string Matrix2x2Verifier::type() const { - using namespace std::string_literals; - - return "Matrix2x2<"s + typeid(T).name() + ">"; + return std::string("Matrix2x2<") + typeid(T).name() + ">"; } template std::string Matrix2x3Verifier::type() const { - using namespace std::string_literals; - - return "Matrix2x3<"s + typeid(T).name() + ">"; + return std::string("Matrix2x3<") + typeid(T).name() + ">"; } template std::string Matrix2x4Verifier::type() const { - using namespace std::string_literals; - - return "Matrix2x4<"s + typeid(T).name() + ">"; + return std::string("Matrix2x4<") + typeid(T).name() + ">"; } template std::string Matrix3x2Verifier::type() const { - using namespace std::string_literals; - - return "Matrix3x2<"s + typeid(T).name() + ">"; + return std::string("Matrix3x2<") + typeid(T).name() + ">"; } template std::string Matrix3x3Verifier::type() const { - using namespace std::string_literals; - - return "Matrix3x3<"s + typeid(T).name() + ">"; + return std::string("Matrix3x3<") + typeid(T).name() + ">"; } template std::string Matrix3x4Verifier::type() const { - using namespace std::string_literals; - - return "Matrix3x4<"s + typeid(T).name() + ">"; + return std::string("Matrix3x4<") + typeid(T).name() + ">"; } template std::string Matrix4x2Verifier::type() const { - using namespace std::string_literals; - - return "Matrix4x2<"s + typeid(T).name() + ">"; + return std::string("Matrix4x2<") + typeid(T).name() + ">"; } template std::string Matrix4x3Verifier::type() const { - using namespace std::string_literals; - - return "Matrix4x3<"s + typeid(T).name() + ">"; + return std::string("Matrix4x3<") + typeid(T).name() + ">"; } template std::string Matrix4x4Verifier::type() const { - using namespace std::string_literals; - - return "Matrix4x4<"s + typeid(T).name() + ">"; + return std::string("Matrix4x4<") + typeid(T).name() + ">"; } template diff --git a/include/openspace/util/factorymanager.inl b/include/openspace/util/factorymanager.inl index dde01bcef5..56034150b8 100644 --- a/include/openspace/util/factorymanager.inl +++ b/include/openspace/util/factorymanager.inl @@ -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 * diff --git a/support/coding/check_style_guide.py b/support/coding/check_style_guide.py index ead3bb69dc..a64ba1b200 100644 --- a/support/coding/check_style_guide.py +++ b/support/coding/check_style_guide.py @@ -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)