diff --git a/.clang_tidy b/.clang_tidy new file mode 100644 index 0000000000..01370763ac --- /dev/null +++ b/.clang_tidy @@ -0,0 +1,65 @@ +Checks: >- + -*, + bugprone-*, + -bugprone-easily-swappable-parameters, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-narrowing-conversions, + -bugprone-suspicious-include, + -bugprone-switch-missing-default-case, + -bugprone-unchecked-optional-access, + clang-analyzer-*, + -clang-analyzer-security.FloatLoopCounter, + cppcoreguidelines-*, + -cppcoreguidelines-avoid-do-while, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-narrowing-conversions, + -cppcoreguidelines-no-malloc, + -cppcoreguidelines-owning-memory, + -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + -cppcoreguidelines-pro-bounds-constant-array-index, + -cppcoreguidelines-pro-bounds-pointer-arithmetic, + -cppcoreguidelines-pro-type-member-init, + -cppcoreguidelines-pro-type-reinterpret-cast, + -cppcoreguidelines-pro-type-static-cast-downcast, + -cppcoreguidelines-pro-type-union-access, + -cppcoreguidelines-pro-type-vararg, + google-*, + -google-objc-*, + -google-build-using-namespace, + -google-default-arguments, + -google-readability-casting, + -google-readability-function-size, + -google-readability-namespace-comments, + -google-runtime-int, + -google-explicit-constructor, + llvm-*, + -llvm-else-after-return, + -llvm-include-order, + -llvm-qualified-auto, + misc-*, + -misc-include-cleaner, + -misc-no-recursion, + -misc-non-private-member-variables-in-classes, + modernize-*, + -modernize-return-braced-init-list, + -modernize-use-trailing-return-type, + -modernize-use-auto, + performance-*, + -performance-no-int-to-ptr, + portability-*, + readability-*, + -readability-avoid-unconditional-preprocessor-if, + -readability-convert-member-functions-to-static, + -readability-else-after-return, + -readability-function-cognitive-complexity, + -readability-identifier-length, + -readability-implicit-bool-conversion, + -readability-magic-numbers, + -readability-named-parameter, + -readability-uppercase-literal-suffix, + -readability-use-anyofallof + +CheckOptions: + - key: performance-move-const-arg.CheckTriviallyCopyableMove + value: False diff --git a/apps/OpenSpace/ext/launcher/include/profile/actiondialog.h b/apps/OpenSpace/ext/launcher/include/profile/actiondialog.h index c81263ad8b..e7ec4b81b0 100644 --- a/apps/OpenSpace/ext/launcher/include/profile/actiondialog.h +++ b/apps/OpenSpace/ext/launcher/include/profile/actiondialog.h @@ -56,18 +56,18 @@ private: void actionRemove(); void actionSelected(); void actionSaved(); - void clearActionFields(); + void clearActionFields() const; void actionRejected(); void chooseScripts(); - void appendScriptsToTextfield(std::vector scripts); + void appendScriptsToTextfield(const std::vector& scripts) const; openspace::Profile::Keybinding* selectedKeybinding(); void keybindingAdd(); void keybindingRemove(); void keybindingSelected(); - void keybindingActionSelected(int); + void keybindingActionSelected(int) const; void keybindingSaved(); - void clearKeybindingFields(); + void clearKeybindingFields() const; void keybindingRejected(); std::vector* _actions = nullptr; diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index 5c8766efc9..065e1dbf67 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -94,7 +94,7 @@ namespace { SettingsIconSize, SettingsIconSize ); - } // geometry + } // namespace geometry std::optional loadProfileFromFile(QWidget* parent, std::string filename) { // Verify that the file actually exists @@ -787,7 +787,8 @@ void LauncherWindow::openProfileEditor(const std::string& profile, bool isUserPr if (editor.specifiedFilename() != profile) { saveProfilePath = _userProfilePath; } - std::string path = saveProfilePath + editor.specifiedFilename() + ".profile"; + const std::string path = + saveProfilePath + editor.specifiedFilename() + ".profile"; saveProfile(this, path, *p); populateProfilesList(editor.specifiedFilename()); } @@ -898,7 +899,10 @@ void LauncherWindow::handleReturnFromWindowEditor(const sgct::config::Cluster& c savePath.replace_extension(".json"); saveWindowConfig(this, savePath, cluster); // Truncate path to convert this back to path relative to _userConfigPath - std::filesystem::path p = std::filesystem::proximate(savePath, saveWindowCfgPath); + const std::filesystem::path p = std::filesystem::proximate( + savePath, + saveWindowCfgPath + ); populateWindowConfigsList(p.string()); } @@ -912,7 +916,7 @@ std::string LauncherWindow::selectedProfile() const { } std::string LauncherWindow::selectedWindowConfig() const { - int idx = _windowConfigBox->currentIndex(); + const int idx = _windowConfigBox->currentIndex(); if (idx == 0) { return _sgctConfigName; } diff --git a/apps/OpenSpace/ext/launcher/src/profile/actiondialog.cpp b/apps/OpenSpace/ext/launcher/src/profile/actiondialog.cpp index 5e311b1219..1a6f59ebcb 100644 --- a/apps/OpenSpace/ext/launcher/src/profile/actiondialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/profile/actiondialog.cpp @@ -639,7 +639,7 @@ void ActionDialog::actionSaved() { clearActionFields(); } -void ActionDialog::clearActionFields() { +void ActionDialog::clearActionFields() const { _actionWidgets.list->setCurrentRow(-1); _actionWidgets.identifier->clear(); _actionWidgets.identifier->setEnabled(false); @@ -679,8 +679,9 @@ void ActionDialog::chooseScripts() { d.exec(); } -void ActionDialog::appendScriptsToTextfield(std::vector scripts) { - for (const std::string script : scripts) { +void ActionDialog::appendScriptsToTextfield(const std::vector& scripts) const +{ + for (const std::string& script : scripts) { _actionWidgets.script->append(QString::fromStdString(script)); } } @@ -693,7 +694,7 @@ Profile::Keybinding* ActionDialog::selectedKeybinding() { void ActionDialog::keybindingAdd() { _keybindingWidgets.list->addItem(""); - _keybindingsData.push_back(Profile::Keybinding()); + _keybindingsData.emplace_back(); _keybindingWidgets.list->setCurrentRow(_keybindingWidgets.list->count() - 1); } @@ -733,7 +734,7 @@ void ActionDialog::keybindingSelected() { hasKeyModifier(keybinding->key.modifier, KeyModifier::Alt) ); - std::string key = ghoul::to_string(keybinding->key.key); + const std::string key = ghoul::to_string(keybinding->key.key); _keybindingWidgets.key->setCurrentText(QString::fromStdString(key)); _keybindingWidgets.key->setEnabled(true); _keybindingWidgets.action->setCurrentText( @@ -771,7 +772,7 @@ void ActionDialog::keybindingSelected() { } } -void ActionDialog::keybindingActionSelected(int) { +void ActionDialog::keybindingActionSelected(int) const { _keybindingWidgets.actionText->setText(_keybindingWidgets.action->currentText()); } @@ -812,7 +813,7 @@ void ActionDialog::keybindingSaved() { clearKeybindingFields(); } -void ActionDialog::clearKeybindingFields() { +void ActionDialog::clearKeybindingFields() const { _keybindingWidgets.list->setCurrentRow(-1); _keybindingWidgets.shiftModifier->setChecked(false); _keybindingWidgets.shiftModifier->setEnabled(false); diff --git a/apps/OpenSpace/ext/launcher/src/profile/cameradialog.cpp b/apps/OpenSpace/ext/launcher/src/profile/cameradialog.cpp index 1f1e0d8f07..7d941ccfe6 100644 --- a/apps/OpenSpace/ext/launcher/src/profile/cameradialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/profile/cameradialog.cpp @@ -53,10 +53,7 @@ namespace { if (!validConversion) { return false; } - if (value < min || value > max) { - return false; - } - return true; + return (value >= min) && (value <= max); } bool isNumericalLargerThan(QLineEdit* le, float limit) { @@ -66,10 +63,7 @@ namespace { if (!validConversion) { return false; } - if (value > limit) { - return true; - } - return false; + return value > limit; } } // namespace diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index 19603f0bbd..9fad60cfb2 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit 19603f0bbd18073d0c7d68bfd5c94315572193d1 +Subproject commit 9fad60cfb2aabf1768e6129365fa64f2bb07d35e diff --git a/ext/ghoul b/ext/ghoul index 43c025377f..fffdcec63a 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 43c025377fe5077c90e37f1a1a408e1865de6b14 +Subproject commit fffdcec63a4e47678f7286c8e2d787f843f8d1ba diff --git a/include/openspace/interaction/sessionrecording.h b/include/openspace/interaction/sessionrecording.h index 27dc7d615d..988f4b1a73 100644 --- a/include/openspace/interaction/sessionrecording.h +++ b/include/openspace/interaction/sessionrecording.h @@ -282,9 +282,9 @@ public: * Used to trigger a save of a script to the recording file, but only if a recording * is currently in progress. * - * \param scriptToSave String of the Lua command to be saved + * \param script String of the Lua command to be saved */ - void saveScriptKeyframeToTimeline(std::string scriptToSave); + void saveScriptKeyframeToTimeline(std::string script); /** * \return The Lua library that contains all Lua functions available to affect the @@ -633,7 +633,7 @@ protected: Timestamps generateCurrentTimestamp3(double keyframeTime) const; static void saveStringToFile(const std::string& s, unsigned char* kfBuffer, size_t& idx, std::ofstream& file); - static void saveKeyframeToFileBinary(unsigned char* bufferSource, size_t size, + static void saveKeyframeToFileBinary(unsigned char* buffer, size_t size, std::ofstream& file); bool addKeyframe(Timestamps t3stamps, @@ -689,11 +689,12 @@ protected: bool convertEntries(std::string& inFilename, std::stringstream& inStream, DataMode mode, int lineNum, std::ofstream& outFile); virtual bool convertCamera(std::stringstream& inStream, DataMode mode, int lineNum, - std::string& inputLine, std::ofstream& outFile, unsigned char* buff); + std::string& inputLine, std::ofstream& outFile, unsigned char* buffer); virtual bool convertTimeChange(std::stringstream& inStream, DataMode mode, - int lineNum, std::string& inputLine, std::ofstream& outFile, unsigned char* buff); + int lineNum, std::string& inputLine, std::ofstream& outFile, + unsigned char* buffer); virtual bool convertScript(std::stringstream& inStream, DataMode mode, int lineNum, - std::string& inputLine, std::ofstream& outFile, unsigned char* buff); + std::string& inputLine, std::ofstream& outFile, unsigned char* buffer); DataMode readModeFromHeader(const std::string& filename); void readPlaybackHeader_stream(std::stringstream& conversionInStream, std::string& version, DataMode& mode); diff --git a/include/openspace/navigation/orbitalnavigator.h b/include/openspace/navigation/orbitalnavigator.h index cde98848f3..c5f1cd05ee 100644 --- a/include/openspace/navigation/orbitalnavigator.h +++ b/include/openspace/navigation/orbitalnavigator.h @@ -274,8 +274,8 @@ private: * from the global to the current total rotation so that * `cameraRotation = globalRotation * localRotation`. */ - CameraRotationDecomposition decomposeCameraRotationSurface(const CameraPose& pose, - const SceneGraphNode& reference); + CameraRotationDecomposition decomposeCameraRotationSurface( + const CameraPose& cameraPose, const SceneGraphNode& reference); /** * Decomposes the camera's rotation in to a global and a local rotation defined by @@ -285,7 +285,7 @@ private: * The local rotation defines the differential from the global to the current total * rotation so that `cameraRotation = globalRotation * localRotation`. */ - CameraRotationDecomposition decomposeCameraRotation(const CameraPose& pose, + CameraRotationDecomposition decomposeCameraRotation(const CameraPose& cameraPose, const glm::dvec3& reference); /** @@ -293,7 +293,7 @@ private: * the world rotation for a camera. */ glm::dquat composeCameraRotation( - const CameraRotationDecomposition& composition) const; + const CameraRotationDecomposition& decomposition) const; /** * Moves and rotates the camera around the anchor node in order to maintain the screen @@ -326,8 +326,8 @@ private: glm::dquat interpolateLocalRotation(double deltaTime, const glm::dquat& localCameraRotation); - Displacement interpolateRetargetAim(double deltaTime, CameraPose pose, - const glm::dvec3& cameraToAnchor, Displacement anchorToAim); + Displacement interpolateRetargetAim(double deltaTime, const CameraPose& pose, + const glm::dvec3& prevCameraToAnchor, Displacement anchorToAim); double interpolateCameraToSurfaceDistance(double deltaTime, double currentDistance, double targetDistance); diff --git a/include/openspace/network/parallelconnection.h b/include/openspace/network/parallelconnection.h index a633f3ab89..60f67b7172 100644 --- a/include/openspace/network/parallelconnection.h +++ b/include/openspace/network/parallelconnection.h @@ -61,7 +61,7 @@ public: struct DataMessage { DataMessage() = default; - DataMessage(datamessagestructures::Type t, double timestamp, std::vector c); + DataMessage(datamessagestructures::Type t, double time, std::vector c); datamessagestructures::Type type; double timestamp; @@ -70,7 +70,7 @@ public: class ConnectionLostError : public ghoul::RuntimeError { public: - explicit ConnectionLostError(bool shouldLogError = true); + explicit ConnectionLostError(bool shouldLogError_ = true); bool shouldLogError; }; diff --git a/include/openspace/rendering/colormappingcomponent.h b/include/openspace/rendering/colormappingcomponent.h index 6443a46975..c67dfd107d 100644 --- a/include/openspace/rendering/colormappingcomponent.h +++ b/include/openspace/rendering/colormappingcomponent.h @@ -74,7 +74,7 @@ public: static documentation::Documentation Documentation(); - glm::vec4 colorFromColorMap(float value) const; + glm::vec4 colorFromColorMap(float valueToColorFrom) const; properties::BoolProperty enabled; properties::BoolProperty invert; diff --git a/include/openspace/scene/profile.h b/include/openspace/scene/profile.h index 13ca783062..f745be9aed 100644 --- a/include/openspace/scene/profile.h +++ b/include/openspace/scene/profile.h @@ -46,7 +46,7 @@ public: struct ParsingError : public ghoul::RuntimeError { enum class Severity { Info, Warning, Error }; - explicit ParsingError(Severity severity, std::string msg); + explicit ParsingError(Severity severity_, std::string msg); Severity severity; }; diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 224ed69a52..dc269e07e8 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -140,7 +140,7 @@ public: bool supportsDirectInteraction() const; - SceneGraphNode* childNode(const std::string& identifier); + SceneGraphNode* childNode(const std::string& id); const Renderable* renderable() const; Renderable* renderable(); diff --git a/modules/base/dashboard/dashboarditemframerate.cpp b/modules/base/dashboard/dashboarditemframerate.cpp index 6712ae7192..51fa1aad01 100644 --- a/modules/base/dashboard/dashboarditemframerate.cpp +++ b/modules/base/dashboard/dashboarditemframerate.cpp @@ -223,7 +223,7 @@ void DashboardItemFramerate::render(glm::vec2& penPosition) { global::windowDelegate->maxDeltaTime() * 1000.0 ); - FrametimeType frametimeType = FrametimeType(_frametimeType.value()); + const FrametimeType frametimeType = FrametimeType(_frametimeType.value()); std::fill(_buffer.begin(), _buffer.end(), char(0)); char* end = format( diff --git a/modules/base/rendering/pointcloud/renderablepointcloud.cpp b/modules/base/rendering/pointcloud/renderablepointcloud.cpp index 85d05f1e45..65c99497e7 100644 --- a/modules/base/rendering/pointcloud/renderablepointcloud.cpp +++ b/modules/base/rendering/pointcloud/renderablepointcloud.cpp @@ -101,7 +101,7 @@ namespace { openspace::properties::Property::Visibility::NoviceUser }; - static const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = { + const openspace::properties::PropertyOwner::PropertyOwnerInfo LabelsInfo = { "Labels", "Labels", "The labels for the points. If no label file is provided, the labels will be " diff --git a/modules/base/rendering/pointcloud/renderablepolygoncloud.cpp b/modules/base/rendering/pointcloud/renderablepolygoncloud.cpp index 9797bce49c..cdfd786524 100644 --- a/modules/base/rendering/pointcloud/renderablepolygoncloud.cpp +++ b/modules/base/rendering/pointcloud/renderablepolygoncloud.cpp @@ -131,16 +131,16 @@ void RenderablePolygonCloud::renderToTexture(GLuint textureToRenderTo, LDEBUG("Rendering to Texture"); // Saves initial Application's OpenGL State - GLint defaultFBO; - GLint viewport[4]; + GLint defaultFBO = 0; + std::array viewport; glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); - glGetIntegerv(GL_VIEWPORT, viewport); + glGetIntegerv(GL_VIEWPORT, viewport.data()); GLuint textureFBO; glGenFramebuffers(1, &textureFBO); glBindFramebuffer(GL_FRAMEBUFFER, textureFBO); - GLenum drawBuffers[1] = { GL_COLOR_ATTACHMENT0 }; - glDrawBuffers(1, drawBuffers); + const GLenum drawBuffers = GL_COLOR_ATTACHMENT0; + glDrawBuffers(1, &drawBuffers); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureToRenderTo, 0); diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 4224b57c9d..9baf51f932 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -322,7 +322,7 @@ void RenderablePlane::update(const UpdateData&) { void RenderablePlane::createPlane() { const GLfloat sizeX = _size.value().x; const GLfloat sizeY = _size.value().y; - const GLfloat vertexData[] = { + const std::array vertexData = { // x y z w s t -sizeX, -sizeY, 0.f, 0.f, 0.f, 0.f, sizeX, sizeY, 0.f, 0.f, 1.f, 1.f, @@ -334,7 +334,7 @@ void RenderablePlane::createPlane() { glBindVertexArray(_quad); glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); - glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData.data(), GL_STATIC_DRAW); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, nullptr); diff --git a/modules/base/rendering/renderableplanetimevaryingimage.h b/modules/base/rendering/renderableplanetimevaryingimage.h index adb667868b..8afde80dc2 100644 --- a/modules/base/rendering/renderableplanetimevaryingimage.h +++ b/modules/base/rendering/renderableplanetimevaryingimage.h @@ -57,7 +57,7 @@ private: ghoul::opengl::Texture* loadTexture() const; void extractTriggerTimesFromFileNames(); bool extractMandatoryInfoFromDictionary(); - int updateActiveTriggerTimeIndex(double currenttime) const; + int updateActiveTriggerTimeIndex(double currentTime) const; void computeSequenceEndTime(); // If there's just one state it should never disappear diff --git a/modules/debugging/rendering/renderabledebugplane.cpp b/modules/debugging/rendering/renderabledebugplane.cpp index 541d1e6fff..906d21f5bc 100644 --- a/modules/debugging/rendering/renderabledebugplane.cpp +++ b/modules/debugging/rendering/renderabledebugplane.cpp @@ -227,7 +227,7 @@ void RenderableDebugPlane::createPlane() { // ============================ const GLfloat size = _size; - const GLfloat vertexData[] = { + const std::array vertexData = { // x y z w s t -size, -size, 0.f, 0.f, 0.f, 0.f, size, size, 0.f, 0.f, 1.f, 1.f, @@ -239,7 +239,7 @@ void RenderableDebugPlane::createPlane() { glBindVertexArray(_quad); // bind array glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer - glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData.data(), GL_STATIC_DRAW); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, nullptr); glEnableVertexAttribArray(1); diff --git a/modules/gaia/tasks/readfilejob.cpp b/modules/gaia/tasks/readfilejob.cpp index 716471a252..c3f98af875 100644 --- a/modules/gaia/tasks/readfilejob.cpp +++ b/modules/gaia/tasks/readfilejob.cpp @@ -264,4 +264,4 @@ std::vector> ReadFileJob::product() { return _octants; } -} // namespace openspace::gaiamission +} // namespace openspace::gaia diff --git a/modules/globebrowsing/src/geojson/geojsoncomponent.cpp b/modules/globebrowsing/src/geojson/geojsoncomponent.cpp index b943747989..1ce8ada611 100644 --- a/modules/globebrowsing/src/geojson/geojsoncomponent.cpp +++ b/modules/globebrowsing/src/geojson/geojsoncomponent.cpp @@ -250,7 +250,7 @@ documentation::Documentation GeoJsonComponent::Documentation() { GeoJsonComponent::SubFeatureProps::SubFeatureProps( properties::PropertyOwner::PropertyOwnerInfo info) - : properties::PropertyOwner(info) + : properties::PropertyOwner(std::move(info)) , enabled(EnabledInfo, true) , centroidLatLong( CentroidCoordinateInfo, diff --git a/modules/globebrowsing/src/globelabelscomponent.cpp b/modules/globebrowsing/src/globelabelscomponent.cpp index 2993a744c2..cd6350402e 100644 --- a/modules/globebrowsing/src/globelabelscomponent.cpp +++ b/modules/globebrowsing/src/globelabelscomponent.cpp @@ -202,23 +202,12 @@ namespace { // farDistance *= invMagFar; constexpr float Radius = 1.0; - if ((glm::dot(leftNormal, position) + leftDistance) < -Radius) { - return false; - } - else if ((glm::dot(rightNormal, position) + rightDistance) < -Radius) { - return false; - } - else if ((glm::dot(bottomNormal, position) + bottomDistance) < -Radius) { - return false; - } - else if ((glm::dot(topNormal, position) + topDistance) < -Radius) { - return false; - } - else if ((glm::dot(nearNormal, position) + nearDistance) < -Radius) { - return false; - } - - return true; + const bool res = ((glm::dot(leftNormal, position) + leftDistance) < -Radius) || + ((glm::dot(rightNormal, position) + rightDistance) < -Radius) || + ((glm::dot(bottomNormal, position) + bottomDistance) < -Radius) || + ((glm::dot(topNormal, position) + topDistance) < -Radius) || + ((glm::dot(nearNormal, position) + nearDistance) < -Radius); + return !res; } struct [[codegen::Dictionary(GlobeLabelsComponent)]] Parameters { @@ -452,7 +441,7 @@ bool GlobeLabelsComponent::readLabelsFile(const std::filesystem::path& file) { strncpy(lEntry.feature, token.c_str(), 255); int tokenChar = 0; while (tokenChar < 256) { - if (lEntry.feature[tokenChar] < 0 && lEntry.feature[tokenChar]) { + if (lEntry.feature[tokenChar] < 0 || lEntry.feature[tokenChar] == '\0') { lEntry.feature[tokenChar] = '*'; } else if (lEntry.feature[tokenChar] == '\"') { diff --git a/modules/globebrowsing/src/layermanager.h b/modules/globebrowsing/src/layermanager.h index 024734af6a..f55341c610 100644 --- a/modules/globebrowsing/src/layermanager.h +++ b/modules/globebrowsing/src/layermanager.h @@ -55,8 +55,8 @@ public: void initialize(const ghoul::Dictionary& layerGroupsDict); void deinitialize(); - Layer* addLayer(layers::Group::ID groupId, const ghoul::Dictionary& layerDict); - void deleteLayer(layers::Group::ID groupId, const std::string& layerName); + Layer* addLayer(layers::Group::ID id, const ghoul::Dictionary& layerDict); + void deleteLayer(layers::Group::ID id, const std::string& layerName); LayerGroup& layerGroup(layers::Group::ID groupId); const LayerGroup& layerGroup(layers::Group::ID groupId) const; diff --git a/modules/globebrowsing/src/layerrendersettings.cpp b/modules/globebrowsing/src/layerrendersettings.cpp index e50a39d070..144289775a 100644 --- a/modules/globebrowsing/src/layerrendersettings.cpp +++ b/modules/globebrowsing/src/layerrendersettings.cpp @@ -88,9 +88,9 @@ void LayerRenderSettings::onChange(const std::function& callback) { offset.onChange(callback); } -float LayerRenderSettings::performLayerSettings(float v) const { +float LayerRenderSettings::performLayerSettings(float value) const { return - ((glm::sign(v) * glm::pow(glm::abs(v), gamma) * multiplier) + offset); + ((glm::sign(value) * glm::pow(glm::abs(value), gamma) * multiplier) + offset); } glm::vec4 LayerRenderSettings::performLayerSettings(const glm::vec4& currentValue) const { diff --git a/modules/globebrowsing/src/rawtiledatareader.cpp b/modules/globebrowsing/src/rawtiledatareader.cpp index f456046efb..0374d9681c 100644 --- a/modules/globebrowsing/src/rawtiledatareader.cpp +++ b/modules/globebrowsing/src/rawtiledatareader.cpp @@ -415,8 +415,8 @@ void RawTileDataReader::initialize() { case GL_SHORT: return 1ULL << 15ULL; case GL_UNSIGNED_INT: return 1ULL << 32ULL; case GL_INT: return 1ULL << 31ULL; - case GL_HALF_FLOAT: return 1ULL; - case GL_FLOAT: return 1ULL; + case GL_HALF_FLOAT: + case GL_FLOAT: case GL_DOUBLE: return 1ULL; default: throw ghoul::MissingCaseException(); } diff --git a/modules/globebrowsing/src/renderableglobe.h b/modules/globebrowsing/src/renderableglobe.h index f4ce5e70e5..a3baeb1ff6 100644 --- a/modules/globebrowsing/src/renderableglobe.h +++ b/modules/globebrowsing/src/renderableglobe.h @@ -70,7 +70,7 @@ struct Chunk { WantSplit }; - Chunk(const TileIndex& tileIndex); + Chunk(const TileIndex& ti); const TileIndex tileIndex; const GeodeticPatch surfacePatch; diff --git a/modules/globebrowsing/src/skirtedgrid.h b/modules/globebrowsing/src/skirtedgrid.h index 85360432ca..0dd21926cc 100644 --- a/modules/globebrowsing/src/skirtedgrid.h +++ b/modules/globebrowsing/src/skirtedgrid.h @@ -39,10 +39,10 @@ namespace openspace::globebrowsing { class SkirtedGrid { public: /** - * \param xSegments is the number of grid cells in the x direction - * \param ySegments is the number of grid cells in the y direction + * \param xSeg is the number of grid cells in the x direction + * \param ySeg is the number of grid cells in the y direction */ - SkirtedGrid(unsigned int xSegments, unsigned int ySegments); + SkirtedGrid(unsigned int xSeg, unsigned int ySeg); ~SkirtedGrid() = default; void initializeGL(); diff --git a/modules/globebrowsing/src/tileindex.h b/modules/globebrowsing/src/tileindex.h index 10f89628b7..3a0098a4ad 100644 --- a/modules/globebrowsing/src/tileindex.h +++ b/modules/globebrowsing/src/tileindex.h @@ -34,7 +34,7 @@ namespace openspace::globebrowsing { struct TileIndex { using TileHashKey = uint64_t; - TileIndex(uint32_t x, uint32_t y, uint8_t level); + TileIndex(uint32_t x_, uint32_t y_, uint8_t level_); uint32_t x = 0; uint32_t y = 0; diff --git a/modules/globebrowsing/src/tileprovider/defaulttileprovider.cpp b/modules/globebrowsing/src/tileprovider/defaulttileprovider.cpp index 5450f4681c..400e058db0 100644 --- a/modules/globebrowsing/src/tileprovider/defaulttileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider/defaulttileprovider.cpp @@ -142,7 +142,7 @@ DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary) const int pixelSize = p.tilePixelSize.value_or(0); // Only preprocess height layers by default - _performPreProcessing = _layerGroupID == layers::Group::ID::HeightLayers; + _performPreProcessing = (_layerGroupID == layers::Group::ID::HeightLayers); _performPreProcessing = p.performPreProcessing.value_or(_performPreProcessing); // Get the name of the layergroup to which this layer belongs diff --git a/modules/globebrowsing/src/tileprovider/temporaltileprovider.cpp b/modules/globebrowsing/src/tileprovider/temporaltileprovider.cpp index 1792b6f056..34616b46d4 100644 --- a/modules/globebrowsing/src/tileprovider/temporaltileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider/temporaltileprovider.cpp @@ -398,7 +398,7 @@ DefaultTileProvider TemporalTileProvider::createTileProvider( case Mode::Prototype: { static const std::vector IgnoredTokens = { // From: http://www.gdal.org/frmt_wms.html - "${x}", "${y}", "${z}", "${version}" "${format}", "${layer}" + "${x}", "${y}", "${z}", "${version}", "${format}", "${layer}" }; value = _prototyped.prototype; @@ -768,8 +768,8 @@ Tile TemporalTileProvider::InterpolateTileProvider::tile(const TileIndex& tileIn glBindFramebuffer(GL_FRAMEBUFFER, fbo); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, *writeTexture, 0); glDisable(GL_BLEND); - GLenum textureBuffers[1] = { GL_COLOR_ATTACHMENT0 }; - glDrawBuffers(1, textureBuffers); + const GLenum textureBuffers = GL_COLOR_ATTACHMENT0; + glDrawBuffers(1, &textureBuffers); // Setup our own viewport settings const GLsizei w = static_cast(writeTexture->width()); diff --git a/modules/globebrowsing/src/tileprovider/texttileprovider.h b/modules/globebrowsing/src/tileprovider/texttileprovider.h index a9bf92ec43..4d8ec98b86 100644 --- a/modules/globebrowsing/src/tileprovider/texttileprovider.h +++ b/modules/globebrowsing/src/tileprovider/texttileprovider.h @@ -31,7 +31,7 @@ namespace openspace::globebrowsing { class TextTileProvider : public TileProvider { public: - TextTileProvider(TileTextureInitData initData, size_t fontSize = 48); + TextTileProvider(TileTextureInitData initData_, size_t fontSize_ = 48); ~TextTileProvider() override; void reset() override; diff --git a/modules/imgui/src/guimissioncomponent.cpp b/modules/imgui/src/guimissioncomponent.cpp index 7fd9022d08..eae88610b6 100644 --- a/modules/imgui/src/guimissioncomponent.cpp +++ b/modules/imgui/src/guimissioncomponent.cpp @@ -118,4 +118,4 @@ void GuiMissionComponent::render() { ImGui::End(); } -} // namespace openspace gui +} // namespace openspace::gui diff --git a/modules/imgui/src/guispacetimecomponent.cpp b/modules/imgui/src/guispacetimecomponent.cpp index 15844b7985..d650336be6 100644 --- a/modules/imgui/src/guispacetimecomponent.cpp +++ b/modules/imgui/src/guispacetimecomponent.cpp @@ -627,4 +627,4 @@ void GuiSpaceTimeComponent::render() { ImGui::End(); } -} // namespace openspace gui +} // namespace openspace::gui diff --git a/modules/server/src/jsonconverters.cpp b/modules/server/src/jsonconverters.cpp index 3481455972..18960ed5d4 100644 --- a/modules/server/src/jsonconverters.cpp +++ b/modules/server/src/jsonconverters.cpp @@ -70,37 +70,37 @@ void to_json(json& j, const PropertyOwner* p) { namespace ghoul { -void to_json(json& j, const Dictionary& dictionary) { +void to_json(json& j, const Dictionary& d) { json object; - for (const std::string_view k : dictionary.keys()) { + for (const std::string_view k : d.keys()) { const std::string key = std::string(k); - if (dictionary.hasValue(key)) { - const glm::dvec4 v = dictionary.value(key); + if (d.hasValue(key)) { + const glm::dvec4 v = d.value(key); object[key] = json::array({ v[0], v[1], v[2], v[3] }); } - else if (dictionary.hasValue(key)) { - const glm::dvec3 v = dictionary.value(key); + else if (d.hasValue(key)) { + const glm::dvec3 v = d.value(key); object[key] = json::array({ v[0], v[1], v[2] }); } - else if (dictionary.hasValue(key)) { - const glm::dvec2 v = dictionary.value(key); + else if (d.hasValue(key)) { + const glm::dvec2 v = d.value(key); object[key] = json::array({ v[0], v[1] }); } - else if (dictionary.hasValue(key)) { - object[key] = dictionary.value(key); + else if (d.hasValue(key)) { + object[key] = d.value(key); } - else if (dictionary.hasValue(key)) { - object[key] = dictionary.value(key); + else if (d.hasValue(key)) { + object[key] = d.value(key); } - else if (dictionary.hasValue(key)) { - object[key] = dictionary.value(key); + else if (d.hasValue(key)) { + object[key] = d.value(key); } - else if (dictionary.hasValue(key)) { - object[key] = dictionary.value(key); + else if (d.hasValue(key)) { + object[key] = d.value(key); } - else if (dictionary.hasValue(key)) { + else if (d.hasValue(key)) { json child; - to_json(child, dictionary.value(key)); + to_json(child, d.value(key)); object[key] = child; } else { @@ -167,4 +167,4 @@ void to_json(json& j, const dvec3& v) { }; } -} // namepsace glm +} // namespace glm diff --git a/modules/server/src/serverinterface.cpp b/modules/server/src/serverinterface.cpp index 4679ed9414..c9bf5a08f5 100644 --- a/modules/server/src/serverinterface.cpp +++ b/modules/server/src/serverinterface.cpp @@ -297,5 +297,4 @@ ghoul::io::SocketServer* ServerInterface::server() { return _socketServer.get(); } - -} +} // namespace openspace diff --git a/modules/skybrowser/skybrowsermodule.h b/modules/skybrowser/skybrowsermodule.h index 40006f2084..b194768f83 100644 --- a/modules/skybrowser/skybrowsermodule.h +++ b/modules/skybrowser/skybrowsermodule.h @@ -74,7 +74,7 @@ public: bool isSelectedPairUsingRae() const; // Managing the target browser pairs - void removeTargetBrowserPair(const std::string& browserId); + void removeTargetBrowserPair(const std::string& id); void addTargetBrowserPair(const std::string& targetId, const std::string& browserId); // Hover circle diff --git a/modules/skybrowser/src/utility.cpp b/modules/skybrowser/src/utility.cpp index f7f1a0cef8..b9e3923fa6 100644 --- a/modules/skybrowser/src/utility.cpp +++ b/modules/skybrowser/src/utility.cpp @@ -61,12 +61,12 @@ glm::dvec3 sphericalToCartesian(const glm::dvec2& coords) { } // Converts from cartesian coordianates to spherical in the unit of degrees -glm::dvec2 cartesianToSpherical(const glm::dvec3& coord) { +glm::dvec2 cartesianToSpherical(const glm::dvec3& coords) { // Equatorial coordinates RA = right ascension, Dec = declination - double ra = atan2(coord.y, coord.x); + double ra = atan2(coords.y, coords.x); const double dec = atan2( - coord.z, - glm::sqrt((coord.x * coord.x) + (coord.y * coord.y)) + coords.z, + glm::sqrt((coords.x * coords.x) + (coords.y * coords.y)) ); ra = ra > 0.0 ? ra : ra + glm::two_pi(); @@ -275,4 +275,4 @@ glm::dvec3 Animation::newValue() const { return glm::dvec3(rotMat * glm::dvec4(_start, 1.0));; } -} // namespace openspace +} // namespace openspace::skybrowser diff --git a/modules/sound/ext/soloud b/modules/sound/ext/soloud new file mode 160000 index 0000000000..1157475881 --- /dev/null +++ b/modules/sound/ext/soloud @@ -0,0 +1 @@ +Subproject commit 1157475881da0d7f76102578255b937c7d4e8f57 diff --git a/modules/space/horizonsfile.cpp b/modules/space/horizonsfile.cpp index 6dedaf89b6..1bf0cf13ca 100644 --- a/modules/space/horizonsfile.cpp +++ b/modules/space/horizonsfile.cpp @@ -116,7 +116,7 @@ std::string constructHorizonsUrl(HorizonsType type, const std::string& target, return url; } -json sendHorizonsRequest(const std::string& url, std::filesystem::path filePath) { +json sendHorizonsRequest(const std::string& url, const std::filesystem::path& filePath) { // Set up HTTP request and download result const auto download = std::make_unique( url, diff --git a/modules/space/horizonsfile.h b/modules/space/horizonsfile.h index 25b0cf6aae..92bc18fd01 100644 --- a/modules/space/horizonsfile.h +++ b/modules/space/horizonsfile.h @@ -128,7 +128,7 @@ std::string constructHorizonsUrl(HorizonsType type, const std::string& target, const std::string& stopTime, const std::string& stepSize, const std::string& unit); nlohmann::json sendHorizonsRequest(const std::string& url, - std::filesystem::path filePath); + const std::filesystem::path& filePath); nlohmann::json convertHorizonsDownloadToJson(const std::filesystem::path& filePath); HorizonsResultCode isValidHorizonsAnswer(const nlohmann::json& answer); HorizonsResultCode isValidHorizonsFile(const std::filesystem::path& file); diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index 217efc3f89..a5b6e29633 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -446,4 +446,4 @@ void RenderableOrbitalKepler::updateBuffers() { setBoundingSphere(maxSemiMajorAxis * 1000); } -} // namespace opensapce +} // namespace openspace diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 444f7e63bc..39eca50620 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -929,8 +929,8 @@ void RenderableStars::renderPSFToTexture() { GLuint psfFBO = 0; glGenFramebuffers(1, &psfFBO); glBindFramebuffer(GL_FRAMEBUFFER, psfFBO); - GLenum drawBuffers[1] = { GL_COLOR_ATTACHMENT0 }; - glDrawBuffers(1, drawBuffers); + GLenum drawBuffers = GL_COLOR_ATTACHMENT0; + glDrawBuffers(1, &drawBuffers); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, _psfTexture, 0); glViewport(0, 0, PsfTextureSize, PsfTextureSize); diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp index 9278edbf31..97a5371bea 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp @@ -431,7 +431,7 @@ glm::mat4 RenderableModelProjection::attitudeParameters(double time, const glm:: time ); - const SpiceManager::FieldOfViewResult res = SpiceManager::ref().fieldOfView( + SpiceManager::FieldOfViewResult res = SpiceManager::ref().fieldOfView( _projectionComponent.instrumentId() ); _boresight = std::move(res.boresightVector); diff --git a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp index 53534ce988..1bbadb7caa 100644 --- a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp @@ -68,10 +68,10 @@ documentation::Documentation RenderablePlaneProjection::Documentation() { return codegen::doc("spacecraftinstruments_renderableplaneprojection"); } -RenderablePlaneProjection::RenderablePlaneProjection(const ghoul::Dictionary& dict) - : Renderable(dict) +RenderablePlaneProjection::RenderablePlaneProjection(const ghoul::Dictionary& dictionary) + : Renderable(dictionary) { - const Parameters p = codegen::bake(dict); + const Parameters p = codegen::bake(dictionary); _spacecraft = p.spacecraft; _instrument = p.instrument; _defaultTarget = p.defaultTarget.value_or(_defaultTarget); diff --git a/modules/statemachine/statemachinemodule.h b/modules/statemachine/statemachinemodule.h index 9f6708bc25..dfb45d81df 100644 --- a/modules/statemachine/statemachinemodule.h +++ b/modules/statemachine/statemachinemodule.h @@ -58,7 +58,7 @@ public: * Save the state machine to a file given by the name and optional directory. * If no directory is given, the TEMP folder is used. */ - void saveToFile(const std::string& fileName, + void saveToFile(const std::string& filename, std::string directory = "${TEMPORARY}/") const; scripting::LuaLibrary luaLibrary() const override; diff --git a/modules/sync/syncs/httpsynchronization.cpp b/modules/sync/syncs/httpsynchronization.cpp index 7b5dd027cb..12979a5a77 100644 --- a/modules/sync/syncs/httpsynchronization.cpp +++ b/modules/sync/syncs/httpsynchronization.cpp @@ -240,8 +240,8 @@ bool HttpSynchronization::isEachFileDownloaded() { } HttpSynchronization::SynchronizationState -HttpSynchronization::trySyncFromUrl(std::string listUrl) { - HttpMemoryDownload fileListDownload(std::move(listUrl)); +HttpSynchronization::trySyncFromUrl(std::string url) { + HttpMemoryDownload fileListDownload = HttpMemoryDownload(std::move(url)); fileListDownload.onProgress([&c = _shouldCancel](int64_t, std::optional) { return !c; }); diff --git a/modules/video/src/videoplayer.cpp b/modules/video/src/videoplayer.cpp index b6a8225dd0..dd79ab5e45 100644 --- a/modules/video/src/videoplayer.cpp +++ b/modules/video/src/videoplayer.cpp @@ -909,4 +909,4 @@ void VideoPlayer::resizeTexture(glm::ivec2 size) { } } -} // namespace openspace::video +} // namespace openspace diff --git a/modules/volume/envelope.cpp b/modules/volume/envelope.cpp index 061e310bd9..31cedf7995 100644 --- a/modules/volume/envelope.cpp +++ b/modules/volume/envelope.cpp @@ -33,8 +33,8 @@ using json = nlohmann::json; namespace openspace::volume { EnvelopePoint::EnvelopePoint(glm::vec3 c, float x, float y) - : color(c) - , colorHex(hexadecimalFromVec3(std::move(c))) + : color(std::move(c)) + , colorHex(hexadecimalFromVec3(color)) , position({ x, y }) {} @@ -44,9 +44,9 @@ EnvelopePoint::EnvelopePoint(std::string c, float x, float y) , position(std::make_pair(x, y)) {} -Envelope::Envelope(std::vector vec) { - _points = std::move(vec); -} +Envelope::Envelope(std::vector vec) + : _points(std::move(vec)) +{} bool Envelope::operator!=(const Envelope& env) const { constexpr double MinDist = 0.0001; @@ -87,13 +87,14 @@ bool Envelope::isEnvelopeValid() const { nextIter != _points.end(); ++currentIter, ++nextIter) { - if (currentIter->position.first > nextIter->position.first) + if (currentIter->position.first > nextIter->position.first) { return false; + } } return true; } -glm::vec3 Envelope::normalizeColor(glm::vec3 vec) const { +glm::vec3 Envelope::normalizeColor(const glm::vec3& vec) const { return { vec.r / 255.f, vec.g / 255.f , vec.b / 255.f }; } @@ -110,7 +111,7 @@ glm::vec4 Envelope::valueAtPosition(float pos) const { } auto beforeIter = afterIter - 1; - float dist = afterIter->position.first - beforeIter->position.first; + const float dist = afterIter->position.first - beforeIter->position.first; if (dist < 0.0001) { return { normalizeColor((beforeIter->color + afterIter->color) / 2.f), @@ -158,7 +159,7 @@ std::string EnvelopePoint::decimalToHexadecimal(int dec) const { std::string hexStr; while (dec > 0) { - int hex = dec % 16; + const int hex = dec % 16; if (hex < 10) { hexStr = hexStr.insert(0, std::string(1, static_cast(hex + 48))); @@ -180,9 +181,9 @@ glm::vec3 EnvelopePoint::hexadecimalToRGBConversion(const std::string& hex) cons } std::string EnvelopePoint::hexadecimalFromVec3(const glm::vec3& vec) const { - std::string r = decimalToHexadecimal(static_cast(vec.r)); - std::string g = decimalToHexadecimal(static_cast(vec.g)); - std::string b = decimalToHexadecimal(static_cast(vec.b)); + const std::string r = decimalToHexadecimal(static_cast(vec.r)); + const std::string g = decimalToHexadecimal(static_cast(vec.g)); + const std::string b = decimalToHexadecimal(static_cast(vec.b)); return ("#" + r + g + b); } diff --git a/modules/volume/envelope.h b/modules/volume/envelope.h index ee31491667..4723630cc4 100644 --- a/modules/volume/envelope.h +++ b/modules/volume/envelope.h @@ -56,7 +56,7 @@ public: const std::vector& points() const; glm::vec4 valueAtPosition(float pos) const; - glm::vec3 normalizeColor(glm::vec3 vec) const; + glm::vec3 normalizeColor(const glm::vec3& vec) const; nlohmann::json jsonPoints() const; nlohmann::json jsonEnvelope() const; void setEnvelopeLuaTable(lua_State* state) const; diff --git a/modules/volume/transferfunction.cpp b/modules/volume/transferfunction.cpp index b62082565c..f07afd4ce8 100644 --- a/modules/volume/transferfunction.cpp +++ b/modules/volume/transferfunction.cpp @@ -33,8 +33,8 @@ using json = nlohmann::json; namespace openspace::volume { -TransferFunction::TransferFunction(const std::string& s) { - setEnvelopesFromString(s); +TransferFunction::TransferFunction(const std::string& string) { + setEnvelopesFromString(string); } bool TransferFunction::setEnvelopesFromString(const std::string& s) { diff --git a/modules/webbrowser/webbrowsermodule.cpp b/modules/webbrowser/webbrowsermodule.cpp index 35788be99d..f9a3d60677 100644 --- a/modules/webbrowser/webbrowsermodule.cpp +++ b/modules/webbrowser/webbrowsermodule.cpp @@ -123,6 +123,8 @@ WebBrowserModule::WebBrowserModule() addProperty(_browserUpdateInterval); } +WebBrowserModule::~WebBrowserModule() {} + void WebBrowserModule::internalDeinitialize() { ZoneScoped; diff --git a/modules/webbrowser/webbrowsermodule.h b/modules/webbrowser/webbrowsermodule.h index b6215a8acc..3ec9a233f4 100644 --- a/modules/webbrowser/webbrowsermodule.h +++ b/modules/webbrowser/webbrowsermodule.h @@ -49,7 +49,7 @@ public: static constexpr const char* Name = "WebBrowser"; WebBrowserModule(); - ~WebBrowserModule() override = default; + ~WebBrowserModule() override; void addBrowser(BrowserInstance*); void removeBrowser(BrowserInstance*); diff --git a/src/data/dataloader.cpp b/src/data/dataloader.cpp index b2b10bb94c..a97327ad0b 100644 --- a/src/data/dataloader.cpp +++ b/src/data/dataloader.cpp @@ -449,9 +449,9 @@ void saveCachedFile(const Labelset& labelset, const std::filesystem::path& path) } } -Labelset loadFileWithCache(std::filesystem::path filePath) { +Labelset loadFileWithCache(std::filesystem::path path) { return internalLoadFileWithCache( - std::move(filePath), + std::move(path), std::nullopt, &loadFile, &loadCachedFile, diff --git a/src/data/datamapping.cpp b/src/data/datamapping.cpp index 172e3753d9..3b8f24cd8a 100644 --- a/src/data/datamapping.cpp +++ b/src/data/datamapping.cpp @@ -107,7 +107,7 @@ namespace { std::optional> excludeColumns; }; #include "datamapping_codegen.cpp" -} +} // namespace namespace openspace::dataloader { diff --git a/src/documentation/documentationengine.cpp b/src/documentation/documentationengine.cpp index 73e3df7788..89a28af415 100644 --- a/src/documentation/documentationengine.cpp +++ b/src/documentation/documentationengine.cpp @@ -83,7 +83,7 @@ nlohmann::json generateJsonDocumentation(const Documentation& d) { for (const DocumentationEntry& p : d.entries) { nlohmann::json entry; entry["key"] = p.key; - entry["optional"] = p.optional ? true : false; + entry["optional"] = static_cast(p.optional); entry["type"] = p.verifier->type(); entry["documentation"] = p.documentation; diff --git a/src/engine/moduleengine.cpp b/src/engine/moduleengine.cpp index fd1f8450fd..4212596462 100644 --- a/src/engine/moduleengine.cpp +++ b/src/engine/moduleengine.cpp @@ -135,27 +135,27 @@ void ModuleEngine::deinitializeGL() { LDEBUG("Finished deinitializing OpenGL of modules"); } -void ModuleEngine::registerModule(std::unique_ptr mod) { +void ModuleEngine::registerModule(std::unique_ptr module) { ZoneScoped; - ghoul_assert(mod, "Module must not be nullptr"); + ghoul_assert(module, "Module must not be nullptr"); auto it = std::find_if( _modules.begin(), _modules.end(), - [&mod](std::unique_ptr& rhs) { - return rhs->identifier() == mod->identifier(); + [&module](std::unique_ptr& rhs) { + return rhs->identifier() == module->identifier(); } ); if (it != _modules.end()) { throw ghoul::RuntimeError( - fmt::format("Module name '{}' was registered before", mod->identifier()), + fmt::format("Module name '{}' was registered before", module->identifier()), "ModuleEngine" ); } - LDEBUG(fmt::format("Registered module '{}'", mod->identifier())); - _modules.push_back(std::move(mod)); + LDEBUG(fmt::format("Registered module '{}'", module->identifier())); + _modules.push_back(std::move(module)); } std::vector ModuleEngine::modules() const { diff --git a/src/events/eventengine.cpp b/src/events/eventengine.cpp index a827cbfae7..da1f06c9f9 100644 --- a/src/events/eventengine.cpp +++ b/src/events/eventengine.cpp @@ -31,7 +31,7 @@ namespace { constexpr std::string_view _loggerCat = "EventEngine"; -} +} // namespace namespace openspace { diff --git a/src/interaction/mousecamerastates.cpp b/src/interaction/mousecamerastates.cpp index d74502d8af..219183c061 100644 --- a/src/interaction/mousecamerastates.cpp +++ b/src/interaction/mousecamerastates.cpp @@ -28,9 +28,9 @@ #include namespace { - const double SENSITIVITY_ADJUSTMENT_INCREASE = 8.0; - const double SENSITIVITY_ADJUSTMENT_DECREASE = 0.5; -} + constexpr double SensitivityAdjustmentIncrease = 8.0; + constexpr double SensitivityAdjustmentDecrease = 0.5; +} // namespace namespace openspace::interaction { @@ -100,10 +100,10 @@ void MouseCameraStates::updateStateFromInput(const MouseInputState& mouseState, double sensitivity = _sensitivity; if (keyboardState.isKeyPressed(Key::Z)) { - sensitivity *= SENSITIVITY_ADJUSTMENT_INCREASE; + sensitivity *= SensitivityAdjustmentIncrease; } else if (keyboardState.isKeyPressed(Key::X)) { - sensitivity *= SENSITIVITY_ADJUSTMENT_DECREASE; + sensitivity *= SensitivityAdjustmentDecrease; } _truckMovementState.velocity.set( diff --git a/src/interaction/sessionrecording.cpp b/src/interaction/sessionrecording.cpp index bd7ad87bbb..b30297c21b 100644 --- a/src/interaction/sessionrecording.cpp +++ b/src/interaction/sessionrecording.cpp @@ -2083,24 +2083,20 @@ bool SessionRecording::processCameraKeyframe(double now) { } bool SessionRecording::processScriptKeyframe() { - if (!_playbackActive_script) { + if (!_playbackActive_script || _keyframesScript.empty()) { return false; } - else if (_keyframesScript.empty()) { - return false; - } - else { - const std::string nextScript = nextKeyframeObj( - _idxScript, - _keyframesScript, - ([this]() { signalPlaybackFinishedForComponent(RecordedType::Script); }) - ); - global::scriptEngine->queueScript( - nextScript, - scripting::ScriptEngine::ShouldBeSynchronized::Yes, - scripting::ScriptEngine::ShouldSendToRemote::Yes - ); - } + + const std::string nextScript = nextKeyframeObj( + _idxScript, + _keyframesScript, + ([this]() { signalPlaybackFinishedForComponent(RecordedType::Script); }) + ); + global::scriptEngine->queueScript( + nextScript, + scripting::ScriptEngine::ShouldBeSynchronized::Yes, + scripting::ScriptEngine::ShouldSendToRemote::Yes + ); return true; } diff --git a/src/interaction/tasks/convertrecfileversiontask.cpp b/src/interaction/tasks/convertrecfileversiontask.cpp index 48bf123ee8..1bc49b77b8 100644 --- a/src/interaction/tasks/convertrecfileversiontask.cpp +++ b/src/interaction/tasks/convertrecfileversiontask.cpp @@ -113,4 +113,4 @@ documentation::Documentation ConvertRecFileVersionTask::documentation() { }; } -} +} // namespace openspace::interaction diff --git a/src/interaction/tasks/convertrecformattask.cpp b/src/interaction/tasks/convertrecformattask.cpp index 9e6952ff53..635e13d835 100644 --- a/src/interaction/tasks/convertrecformattask.cpp +++ b/src/interaction/tasks/convertrecformattask.cpp @@ -336,4 +336,4 @@ documentation::Documentation ConvertRecFormatTask::documentation() { }; } -} +} // namespace openspace::interaction diff --git a/src/mission/mission.cpp b/src/mission/mission.cpp index 589e86ad3d..4a04fe6bc2 100644 --- a/src/mission/mission.cpp +++ b/src/mission/mission.cpp @@ -163,10 +163,9 @@ MissionPhase::MissionPhase(const ghoul::Dictionary& dictionary) { _milestones.reserve(p.milestones->size()); for (const Parameters::Milestone& milestone : *p.milestones) { std::string name = milestone.name; - Time newTime = Time(milestone.date); Milestone newDate = { .name = std::move(name), - .date = std::move(newTime) + .date = Time(milestone.date) }; if (milestone.description.has_value()) { newDate.description = milestone.description.value(); diff --git a/src/navigation/navigationhandler.cpp b/src/navigation/navigationhandler.cpp index 96329c6e79..e53b6bc487 100644 --- a/src/navigation/navigationhandler.cpp +++ b/src/navigation/navigationhandler.cpp @@ -583,7 +583,7 @@ void NavigationHandler::loadNavigationState(const std::string& filepath) { } std::ifstream f = std::ifstream(filepath); - std::string contents = std::string( + const std::string contents = std::string( std::istreambuf_iterator(f), std::istreambuf_iterator() ); diff --git a/src/navigation/orbitalnavigator.cpp b/src/navigation/orbitalnavigator.cpp index 80a8c82032..01baef8f30 100644 --- a/src/navigation/orbitalnavigator.cpp +++ b/src/navigation/orbitalnavigator.cpp @@ -331,7 +331,7 @@ namespace { openspace::properties::Property::Visibility::AdvancedUser }; - static const openspace::properties::PropertyOwner::PropertyOwnerInfo LimitZoomInfo = { + const openspace::properties::PropertyOwner::PropertyOwnerInfo LimitZoomInfo = { "LimitZoom", "Limit Zoom", "Settings to limit the camera from going to close to or too far away from the " @@ -1565,7 +1565,7 @@ glm::dquat OrbitalNavigator::interpolateLocalRotation(double deltaTime, } OrbitalNavigator::Displacement -OrbitalNavigator::interpolateRetargetAim(double deltaTime, CameraPose pose, +OrbitalNavigator::interpolateRetargetAim(double deltaTime, const CameraPose& pose, const glm::dvec3& prevCameraToAnchor, Displacement anchorToAim) { @@ -1603,7 +1603,7 @@ OrbitalNavigator::interpolateRetargetAim(double deltaTime, CameraPose pose, if (requestedAngle <= maxAngle) { const glm::dvec3 aimPos = pose.position + prevCameraToAnchor + anchorToAim.second; const CameraRotationDecomposition aimDecomp = decomposeCameraRotation( - std::move(pose), + pose, aimPos ); diff --git a/src/network/parallelconnection.cpp b/src/network/parallelconnection.cpp index 36a013b6cf..5b09e9ceea 100644 --- a/src/network/parallelconnection.cpp +++ b/src/network/parallelconnection.cpp @@ -112,13 +112,12 @@ bool ParallelConnection::sendMessage(const Message& message) { reinterpret_cast(&messageSizeOut) + sizeof(uint32_t) ); - if (!_socket->put(header.data(), header.size())) { + const bool res = _socket->put(header.data(), header.size()); + if (!res) { return false; } - if (!_socket->put(message.content.data(), message.content.size())) { - return false; - } - return true; + const bool res2 = _socket->put(message.content.data(), message.content.size()); + return res2; } void ParallelConnection::disconnect() { diff --git a/src/properties/stringproperty.cpp b/src/properties/stringproperty.cpp index 5f114bbce7..492420dd2d 100644 --- a/src/properties/stringproperty.cpp +++ b/src/properties/stringproperty.cpp @@ -31,7 +31,7 @@ namespace openspace::properties { StringProperty::StringProperty(Property::PropertyInfo info, std::string value) - : TemplateProperty(info, value) + : TemplateProperty(std::move(info), std::move(value)) {} std::string_view StringProperty::className() const { diff --git a/src/query/query.cpp b/src/query/query.cpp index c932accdb5..4bb2d64e87 100644 --- a/src/query/query.cpp +++ b/src/query/query.cpp @@ -59,4 +59,4 @@ std::vector allProperties() { return global::rootPropertyOwner->propertiesRecursive(); } -} // namespace +} // namespace openspace diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 17a28b076e..4a68fa2fba 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -982,7 +982,7 @@ std::unique_ptr RenderEngine::buildRenderProgram( name, vsPath, absPath(RenderFsPath), - std::move(dict) + dict ); if (program) { @@ -1015,7 +1015,7 @@ std::unique_ptr RenderEngine::buildRenderProgram( vsPath, absPath(RenderFsPath), csPath, - std::move(dict) + dict ); if (program) { diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index 35a58cc915..05ea76406f 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -880,19 +880,19 @@ scripting::LuaLibrary Scene::luaLibrary() { }; } -std::string makeIdentifier(std::string s) { +std::string makeIdentifier(std::string str) { // Note that we want to preserve '-' and '_', but replace any other punctuation // marks. Hence, we first convert '_' to whitespaces to avoid them being replaced // in the puncutation check - std::replace(s.begin(), s.end(), '_', ' '); + std::replace(str.begin(), str.end(), '_', ' '); std::replace_if( - s.begin(), - s.end(), + str.begin(), + str.end(), [](unsigned char c) { return std::ispunct(c) != 0; }, '-' ); - std::replace(s.begin(), s.end(), ' ', '_'); - return s; + std::replace(str.begin(), str.end(), ' ', '_'); + return str; } } // namespace openspace diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 83fc57afd9..df30467c15 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -253,7 +253,7 @@ void applyRegularExpression(lua_State* L, const std::string& regex, global::renderEngine->scene()->addPropertyInterpolation( prop, static_cast(interpolationDuration), - std::move(postScript), + postScript, easingFunction ); } diff --git a/src/util/factorymanager.cpp b/src/util/factorymanager.cpp index 8adcd7178d..fb67d3464f 100644 --- a/src/util/factorymanager.cpp +++ b/src/util/factorymanager.cpp @@ -95,7 +95,8 @@ nlohmann::json generateJsonDocumentation(const Documentation& d) { return json; } -} + +} // namespace namespace openspace { diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index a2def26b7d..6830a8a55f 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -1665,8 +1665,8 @@ References: Specialist Conference, August 21-24, 2006. Keystone, CO. )"; - std::filesystem::path path = std::filesystem::temp_directory_path(); - std::filesystem::path file = path / "geophysical.ker"; + const std::filesystem::path path = std::filesystem::temp_directory_path(); + const std::filesystem::path file = path / "geophysical.ker"; { std::ofstream f(file); f << GeoPhysicalConstantsKernelSource; diff --git a/src/util/time.cpp b/src/util/time.cpp index 452d5bf0a1..85f3259b25 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -97,8 +97,8 @@ double Time::j2000Seconds() const { return _time; } -double Time::advanceTime(double delta) { - _time += delta; +double Time::advanceTime(double deltaTime) { + _time += deltaTime; return _time; } diff --git a/src/util/timeline.cpp b/src/util/timeline.cpp index 4abd3d112f..e326cb492d 100644 --- a/src/util/timeline.cpp +++ b/src/util/timeline.cpp @@ -47,4 +47,4 @@ bool compareKeyframeTimeWithTime_playbackWithFrames(const KeyframeBase& a, doubl return a.timestamp <= b; } -} // namespace +} // namespace openspace diff --git a/src/util/timemanager.cpp b/src/util/timemanager.cpp index 473c2a9356..74ac17eb4a 100644 --- a/src/util/timemanager.cpp +++ b/src/util/timemanager.cpp @@ -347,7 +347,7 @@ void TimeManager::progressTime(double dt) { TimeKeyframeData TimeManager::interpolate(const Keyframe& past, const Keyframe& future, - double appTime) + double time) { // https://en.wikipedia.org/wiki/Spline_interpolation // interpolatedTime = (1 - t)y1 + t*y2 + t(1 - t)(a(1 - t) + bt), where @@ -363,7 +363,7 @@ TimeKeyframeData TimeManager::interpolate(const Keyframe& past const double deltaAppTime = future.timestamp - past.timestamp; const double deltaSimTime = futureSimTime - pastSimTime; - const double t = (appTime - past.timestamp) / deltaAppTime; + const double t = (time - past.timestamp) / deltaAppTime; const double a = pastDerivative * deltaAppTime - deltaSimTime; const double b = -futureDerivative * deltaAppTime + deltaSimTime; @@ -387,8 +387,8 @@ TimeKeyframeData TimeManager::interpolate(const Keyframe& past return data; } -void TimeManager::applyKeyframeData(const TimeKeyframeData& keyframeData, double dt) { - const Time& currentTime = keyframeData.time; +void TimeManager::applyKeyframeData(const TimeKeyframeData& keyframe, double dt) { + const Time& currentTime = keyframe.time; _deltaTime = _timePaused ? 0.0 : _targetDeltaTime; if (isPlayingBackSessionRecording()) { _currentTime.data().advanceTime(dt * _deltaTime); @@ -396,8 +396,8 @@ void TimeManager::applyKeyframeData(const TimeKeyframeData& keyframeData, double else { _currentTime.data().setTime(currentTime.j2000Seconds()); } - _timePaused = keyframeData.pause; - _targetDeltaTime = keyframeData.delta; + _timePaused = keyframe.pause; + _targetDeltaTime = keyframe.delta; _deltaTime = _timePaused ? 0.0 : _targetDeltaTime; } diff --git a/support/coding/codegen b/support/coding/codegen index 6fae00541a..871a465402 160000 --- a/support/coding/codegen +++ b/support/coding/codegen @@ -1 +1 @@ -Subproject commit 6fae00541aadf1fdd2634e9e633be69d16c8bc70 +Subproject commit 871a4654024fc1043cc2120a94d05fb3edc88887 diff --git a/tests/test_documentation.cpp b/tests/test_documentation.cpp index 82ec21cdc4..d76b851dcd 100644 --- a/tests/test_documentation.cpp +++ b/tests/test_documentation.cpp @@ -824,7 +824,7 @@ TEST_CASE("Documentation: MixedVerifiers", "[documentation]") { positive.setValue("Int", 0); positive.setValue("String", ""s); positive.setValue("Table", ghoul::Dictionary()); - TestResult positiveRes = testSpecification(doc, positive); + const TestResult positiveRes = testSpecification(doc, positive); CHECK(positiveRes.success); CHECK(positiveRes.offenses.empty()); @@ -897,7 +897,7 @@ TEST_CASE("Documentation: NestedTables", "[documentation]") { } positive.setValue("Outer_Table2", inner); } - TestResult positiveRes = testSpecification(doc, positive); + const TestResult positiveRes = testSpecification(doc, positive); CHECK(positiveRes.success); CHECK(positiveRes.offenses.empty()); @@ -1058,7 +1058,7 @@ TEST_CASE("Documentation: Optional", "[documentation]") { CHECK(positiveRes.success); CHECK(positiveRes.offenses.empty()); - ghoul::Dictionary negative; + const ghoul::Dictionary negative; TestResult negativeRes = testSpecification(doc, negative); CHECK_FALSE(negativeRes.success); REQUIRE(negativeRes.offenses.size() == 1); @@ -1128,7 +1128,7 @@ TEST_CASE("Documentation: Required In Optional", "[documentation]") { CHECK(positiveRes.success); CHECK(positiveRes.offenses.empty()); - ghoul::Dictionary positive3; + const ghoul::Dictionary positive3; positiveRes = testSpecification(doc, positive3); CHECK(positiveRes.success); CHECK(positiveRes.offenses.empty()); @@ -1219,7 +1219,7 @@ TEST_CASE("Documentation: Empty Entries Non Exhaustive", "[documentation]") { const Documentation doc; - ghoul::Dictionary positive {}; + const ghoul::Dictionary positive {}; TestResult positiveRes = testSpecification(doc, positive); CHECK(positiveRes.success); CHECK(positiveRes.offenses.empty()); @@ -2310,7 +2310,7 @@ TEST_CASE("Documentation: Referencing", "[documentation]") { CHECK(negativeRes.offenses[0].reason == TestResult::Offense::Reason::WrongType); - Documentation wrongDoc = { + const Documentation wrongDoc = { .entries = { { "Table", new ReferencingVerifier("WRONG"), Optional::No } } diff --git a/tests/test_horizons.cpp b/tests/test_horizons.cpp index da50c539c7..c87537e1d2 100644 --- a/tests/test_horizons.cpp +++ b/tests/test_horizons.cpp @@ -271,7 +271,7 @@ TEST_CASE("HorizonsFile: Observer and target same", "[horizonsfile]") { const HorizonsResultCode answer = HorizonsResultCode::ErrorObserverTargetSame; // This test is only for Observer type format - HorizonsType type = HorizonsType::Observer; + const HorizonsType type = HorizonsType::Observer; testHorizonsAnswer(data, type, filePath, answer); #endif // OPENSPACE_MODULE_SPACE_ENABLED } diff --git a/tests/test_profile.cpp b/tests/test_profile.cpp index 51a5d99ef8..19255ebe4e 100644 --- a/tests/test_profile.cpp +++ b/tests/test_profile.cpp @@ -36,6 +36,11 @@ #include #include +// clang-tidy is convinced that it is possible to use emplace_back instead of push_back +// for the profiole types, but I haven't been able to convince the Visual Studio +// compiler to agree +// NOLINTBEGIN(modernize-use-emplace) + namespace openspace { bool operator==(const openspace::Profile::Version& lhs, const openspace::Profile::Version& rhs) noexcept @@ -1587,3 +1592,5 @@ TEST_CASE("(Error) Camera (GoToNode): Missing value 'anchor'", "[profile]") { // Catch::Matchers::Equals("(profile) 'camera.height' must be a larger than zero") // ); //} + +// NOLINTEND(modernize-use-emplace) diff --git a/tests/test_rawvolumeio.cpp b/tests/test_rawvolumeio.cpp index 6e0b6fddb4..6aa574be19 100644 --- a/tests/test_rawvolumeio.cpp +++ b/tests/test_rawvolumeio.cpp @@ -35,15 +35,15 @@ TEST_CASE("RawVolumeIO: TinyInputOutput", "[rawvolumeio]") { using namespace openspace::volume; - glm::uvec3 dims(1); - float value = 0.5f; + const glm::uvec3 dims = glm::uvec3(1, 1, 1); + const float value = 0.5f; RawVolume vol(dims); vol.set({ 0, 0, 0 }, value); CHECK(vol.get({ 0, 0, 0 }) == value); - std::filesystem::path volumePath = absPath("${TESTDIR}/tinyvolume.rawvolume"); + const std::filesystem::path volumePath = absPath("${TESTDIR}/tinyvolume.rawvolume"); // Write the 1x1x1 volume to disk RawVolumeWriter writer(volumePath.string()); @@ -59,12 +59,14 @@ TEST_CASE("RawVolumeIO: BasicInputOutput", "[rawvolumeio]") { using namespace openspace::volume; const glm::uvec3 dims = glm::uvec3(2, 4, 8); - auto value = [dims](glm::uvec3 v) { + auto value = [dims](const glm::uvec3& v) { return static_cast(v.z * dims.z * dims.y + v.y * dims.y + v.x); }; RawVolume vol(dims); - vol.forEachVoxel([&vol, &value](glm::uvec3 x, float) { vol.set(x, value(x)); }); + vol.forEachVoxel( + [&vol, &value](const glm::uvec3& x, float) { vol.set(x, value(x)); } + ); vol.forEachVoxel([&value](const glm::uvec3& x, float v) { CHECK(v == value(x)); }); const std::filesystem::path volumePath = absPath("${TESTDIR}/basicvolume.rawvolume");