Feature/c3d updates - #285
Conversation
Cpp-Linter Report
|
There was a problem hiding this comment.
Cpp-linter Review
Used clang-tidy v19.1.7
Click here for the full clang-tidy patch
diff --git a/misc/c3d/src/datastructures/c3ddata.cpp b/misc/c3d/src/datastructures/c3ddata.cpp
index 8ac2f81..c9c1b21 100644
--- a/misc/c3d/src/datastructures/c3ddata.cpp
+++ b/misc/c3d/src/datastructures/c3ddata.cpp
@@ -76,3 +76,3 @@ C3D::C3D(const std::filesystem::path& path, Options options) : ezc3d::c3d{} {
- ezc3d::DataNS::Points3dNS::Info pointsInfo{*this};
- ezc3d::DataNS::AnalogsNS::Info analogsInfo{*this};
- ezc3d::DataNS::RotationNS::Info rotationsInfo{*this};
+ const ezc3d::DataNS::Points3dNS::Info pointsInfo{*this};
+ const ezc3d::DataNS::AnalogsNS::Info analogsInfo{*this};
+ const ezc3d::DataNS::RotationNS::Info rotationsInfo{*this};
@@ -116,2 +116,2 @@ C3D::C3D(const std::filesystem::path& path, Options options) : ezc3d::c3d{} {
- std::streampos fileSize = stream.seekg(0, std::ios::end).tellg();
- int targetPos(static_cast<int>(rotationsInfo.dataStart() - 1) * 512);
+ const std::streampos fileSize = stream.seekg(0, std::ios::end).tellg();
+ const int targetPos(static_cast<int>(rotationsInfo.dataStart() - 1) * 512);
diff --git a/misc/c3d/src/datastructures/c3ddatatraits.cpp b/misc/c3d/src/datastructures/c3ddatatraits.cpp
index 6e537ea..0342fb8 100644
--- a/misc/c3d/src/datastructures/c3ddatatraits.cpp
+++ b/misc/c3d/src/datastructures/c3ddatatraits.cpp
@@ -44 +44 @@ Document DataTraits<C3D>::info(const C3D& data) {
- for (auto& name : data.pointNames()) {
+ for (const auto& name : data.pointNames()) {
diff --git a/misc/c3d/src/processors/c3dtomesh.cpp b/misc/c3d/src/processors/c3dtomesh.cpp
index a63e93c..ece3f23 100644
--- a/misc/c3d/src/processors/c3dtomesh.cpp
+++ b/misc/c3d/src/processors/c3dtomesh.cpp
@@ -114 +114 @@ void C3DToMesh::process() {
- const auto* sp = static_cast<const StringProperty*>(prop);
+ const auto* sp = dynamic_cast<const StringProperty*>(prop);
Have any feedback or feature suggestions? Share it here.
|
|
||
| namespace inviwo { | ||
|
|
||
| class IVW_MODULE_C3D_API C3D : public ezc3d::c3d { |
There was a problem hiding this comment.
clang-tidy diagnostic
misc/c3d/include/inviwo/c3d/datastructures/c3ddata.h:40:26: warning: [cppcoreguidelines-special-member-functions]
class 'C3D' defines a copy constructor, a copy assignment operator, a move constructor and a move assignment operator but does not define a destructor
40 | class IVW_MODULE_C3D_API C3D : public ezc3d::c3d {
| ^| ezc3d::DataNS::Points3dNS::Info pointsInfo{*this}; | ||
| ezc3d::DataNS::AnalogsNS::Info analogsInfo{*this}; | ||
| ezc3d::DataNS::RotationNS::Info rotationsInfo{*this}; |
There was a problem hiding this comment.
clang-tidy diagnostics
- variable 'pointsInfo' of type 'ezc3d::DataNS::Points3dNS::Info' can be declared 'const' [misc-const-correctness]
- variable 'analogsInfo' of type 'ezc3d::DataNS::AnalogsNS::Info' can be declared 'const' [misc-const-correctness]
- variable 'rotationsInfo' of type 'ezc3d::DataNS::RotationNS::Info' can be declared 'const' [misc-const-correctness]
| ezc3d::DataNS::Points3dNS::Info pointsInfo{*this}; | |
| ezc3d::DataNS::AnalogsNS::Info analogsInfo{*this}; | |
| ezc3d::DataNS::RotationNS::Info rotationsInfo{*this}; | |
| const ezc3d::DataNS::Points3dNS::Info pointsInfo{*this}; | |
| const ezc3d::DataNS::AnalogsNS::Info analogsInfo{*this}; | |
| const ezc3d::DataNS::RotationNS::Info rotationsInfo{*this}; |
| std::streampos fileSize = stream.seekg(0, std::ios::end).tellg(); | ||
| int targetPos(static_cast<int>(rotationsInfo.dataStart() - 1) * 512); |
There was a problem hiding this comment.
clang-tidy diagnostics
- variable 'fileSize' of type 'std::streampos' (aka 'fpos<__mbstate_t>') can be declared 'const' [misc-const-correctness]
- variable 'targetPos' of type 'int' can be declared 'const' [misc-const-correctness]
| std::streampos fileSize = stream.seekg(0, std::ios::end).tellg(); | |
| int targetPos(static_cast<int>(rotationsInfo.dataStart() - 1) * 512); | |
| const std::streampos fileSize = stream.seekg(0, std::ios::end).tellg(); | |
| const int targetPos(static_cast<int>(rotationsInfo.dataStart() - 1) * 512); |
| if (options.readAnalogs) { | ||
| f.add(ezc3d::DataNS::AnalogsNS::Analogs(*this, stream, analogsInfo)); | ||
| } else { | ||
| stream.seekg(sizeof(float) * _header->nbAnalogByFrame() * _header->nbAnalogs(), |
There was a problem hiding this comment.
clang-tidy diagnostic
misc/c3d/src/datastructures/c3ddata.cpp:99:30: warning: [bugprone-narrowing-conversions]
narrowing conversion from 'unsigned long' to signed type 'off_type' (aka 'long long') is implementation-defined
99 | stream.seekg(sizeof(float) * _header->nbAnalogByFrame() * _header->nbAnalogs(),
| ^|
|
||
| utildoc::TableBuilder tb2(doc.handle(), P::end()); | ||
| tb2(H(fmt::format("Points ({})", data.header().nb3dPoints()))); | ||
| for (auto& name : data.pointNames()) { |
There was a problem hiding this comment.
clang-tidy diagnostics
- 'auto &name' can be declared as 'const auto &name' [readability-qualified-auto]
| for (auto& name : data.pointNames()) { | |
| for (const auto& name : data.pointNames()) { |
| return false; | ||
| } | ||
| std::any C3DReader::getOption(std::string_view key) { | ||
| if (key == "ReadAnalogs") { |
There was a problem hiding this comment.
clang-tidy diagnostic
misc/c3d/src/io/c3dreader.cpp:63:31: warning: [bugprone-branch-clone]
repeated branch body in conditional chain
63 | if (key == "ReadAnalogs") {
| ^
/home/runner/work/modules/modules/inviwo/misc/c3d/src/io/c3dreader.cpp:65:6: note: end of the original
65 | } else if (key == "ReadRotations") {
| ^
/home/runner/work/modules/modules/inviwo/misc/c3d/src/io/c3dreader.cpp:65:40: note: clone 1 starts here
65 | } else if (key == "ReadRotations") {
| ^| pointIndices.assign_range(std::views::iota(0uz, nbPoints)); | ||
| } else { | ||
| for (const auto* prop : pointSelection_) { | ||
| const auto* sp = static_cast<const StringProperty*>(prop); |
There was a problem hiding this comment.
clang-tidy diagnostics
- do not use static_cast to downcast from a base to a derived class; use dynamic_cast instead [cppcoreguidelines-pro-type-static-cast-downcast]
| const auto* sp = static_cast<const StringProperty*>(prop); | |
| const auto* sp = dynamic_cast<const StringProperty*>(prop); |
d2b1ca8 to
efff73d
Compare
There was a problem hiding this comment.
Cpp-linter Review
Used clang-tidy v19.1.7
Click here for the full clang-tidy patch
diff --git a/misc/c3d/src/datastructures/c3ddata.cpp b/misc/c3d/src/datastructures/c3ddata.cpp
index 8ac2f81..c9c1b21 100644
--- a/misc/c3d/src/datastructures/c3ddata.cpp
+++ b/misc/c3d/src/datastructures/c3ddata.cpp
@@ -76,3 +76,3 @@ C3D::C3D(const std::filesystem::path& path, Options options) : ezc3d::c3d{} {
- ezc3d::DataNS::Points3dNS::Info pointsInfo{*this};
- ezc3d::DataNS::AnalogsNS::Info analogsInfo{*this};
- ezc3d::DataNS::RotationNS::Info rotationsInfo{*this};
+ const ezc3d::DataNS::Points3dNS::Info pointsInfo{*this};
+ const ezc3d::DataNS::AnalogsNS::Info analogsInfo{*this};
+ const ezc3d::DataNS::RotationNS::Info rotationsInfo{*this};
@@ -116,2 +116,2 @@ C3D::C3D(const std::filesystem::path& path, Options options) : ezc3d::c3d{} {
- std::streampos fileSize = stream.seekg(0, std::ios::end).tellg();
- int targetPos(static_cast<int>(rotationsInfo.dataStart() - 1) * 512);
+ const std::streampos fileSize = stream.seekg(0, std::ios::end).tellg();
+ const int targetPos(static_cast<int>(rotationsInfo.dataStart() - 1) * 512);
diff --git a/misc/c3d/src/datastructures/c3ddatatraits.cpp b/misc/c3d/src/datastructures/c3ddatatraits.cpp
index 6e537ea..0342fb8 100644
--- a/misc/c3d/src/datastructures/c3ddatatraits.cpp
+++ b/misc/c3d/src/datastructures/c3ddatatraits.cpp
@@ -44 +44 @@ Document DataTraits<C3D>::info(const C3D& data) {
- for (auto& name : data.pointNames()) {
+ for (const auto& name : data.pointNames()) {
diff --git a/misc/c3d/src/processors/c3dtomesh.cpp b/misc/c3d/src/processors/c3dtomesh.cpp
index a63e93c..ece3f23 100644
--- a/misc/c3d/src/processors/c3dtomesh.cpp
+++ b/misc/c3d/src/processors/c3dtomesh.cpp
@@ -114 +114 @@ void C3DToMesh::process() {
- const auto* sp = static_cast<const StringProperty*>(prop);
+ const auto* sp = dynamic_cast<const StringProperty*>(prop);
Have any feedback or feature suggestions? Share it here.
|
|
||
| namespace inviwo { | ||
|
|
||
| class IVW_MODULE_C3D_API C3D : public ezc3d::c3d { |
There was a problem hiding this comment.
clang-tidy diagnostic
misc/c3d/include/inviwo/c3d/datastructures/c3ddata.h:40:26: warning: [cppcoreguidelines-special-member-functions]
class 'C3D' defines a copy constructor, a copy assignment operator, a move constructor and a move assignment operator but does not define a destructor
40 | class IVW_MODULE_C3D_API C3D : public ezc3d::c3d {
| ^| ezc3d::DataNS::Points3dNS::Info pointsInfo{*this}; | ||
| ezc3d::DataNS::AnalogsNS::Info analogsInfo{*this}; | ||
| ezc3d::DataNS::RotationNS::Info rotationsInfo{*this}; |
There was a problem hiding this comment.
clang-tidy diagnostics
- variable 'pointsInfo' of type 'ezc3d::DataNS::Points3dNS::Info' can be declared 'const' [misc-const-correctness]
- variable 'analogsInfo' of type 'ezc3d::DataNS::AnalogsNS::Info' can be declared 'const' [misc-const-correctness]
- variable 'rotationsInfo' of type 'ezc3d::DataNS::RotationNS::Info' can be declared 'const' [misc-const-correctness]
| ezc3d::DataNS::Points3dNS::Info pointsInfo{*this}; | |
| ezc3d::DataNS::AnalogsNS::Info analogsInfo{*this}; | |
| ezc3d::DataNS::RotationNS::Info rotationsInfo{*this}; | |
| const ezc3d::DataNS::Points3dNS::Info pointsInfo{*this}; | |
| const ezc3d::DataNS::AnalogsNS::Info analogsInfo{*this}; | |
| const ezc3d::DataNS::RotationNS::Info rotationsInfo{*this}; |
| std::streampos fileSize = stream.seekg(0, std::ios::end).tellg(); | ||
| int targetPos(static_cast<int>(rotationsInfo.dataStart() - 1) * 512); |
There was a problem hiding this comment.
clang-tidy diagnostics
- variable 'fileSize' of type 'std::streampos' (aka 'fpos<__mbstate_t>') can be declared 'const' [misc-const-correctness]
- variable 'targetPos' of type 'int' can be declared 'const' [misc-const-correctness]
| std::streampos fileSize = stream.seekg(0, std::ios::end).tellg(); | |
| int targetPos(static_cast<int>(rotationsInfo.dataStart() - 1) * 512); | |
| const std::streampos fileSize = stream.seekg(0, std::ios::end).tellg(); | |
| const int targetPos(static_cast<int>(rotationsInfo.dataStart() - 1) * 512); |
| if (options.readAnalogs) { | ||
| f.add(ezc3d::DataNS::AnalogsNS::Analogs(*this, stream, analogsInfo)); | ||
| } else { | ||
| stream.seekg(sizeof(float) * _header->nbAnalogByFrame() * _header->nbAnalogs(), |
There was a problem hiding this comment.
clang-tidy diagnostic
misc/c3d/src/datastructures/c3ddata.cpp:99:30: warning: [bugprone-narrowing-conversions]
narrowing conversion from 'unsigned long' to signed type 'off_type' (aka 'long long') is implementation-defined
99 | stream.seekg(sizeof(float) * _header->nbAnalogByFrame() * _header->nbAnalogs(),
| ^|
|
||
| utildoc::TableBuilder tb2(doc.handle(), P::end()); | ||
| tb2(H(fmt::format("Points ({})", data.header().nb3dPoints()))); | ||
| for (auto& name : data.pointNames()) { |
There was a problem hiding this comment.
clang-tidy diagnostics
- 'auto &name' can be declared as 'const auto &name' [readability-qualified-auto]
| for (auto& name : data.pointNames()) { | |
| for (const auto& name : data.pointNames()) { |
| return false; | ||
| } | ||
| std::any C3DReader::getOption(std::string_view key) { | ||
| if (key == "ReadAnalogs") { |
There was a problem hiding this comment.
clang-tidy diagnostic
misc/c3d/src/io/c3dreader.cpp:63:31: warning: [bugprone-branch-clone]
repeated branch body in conditional chain
63 | if (key == "ReadAnalogs") {
| ^
/home/runner/work/modules/modules/inviwo/misc/c3d/src/io/c3dreader.cpp:65:6: note: end of the original
65 | } else if (key == "ReadRotations") {
| ^
/home/runner/work/modules/modules/inviwo/misc/c3d/src/io/c3dreader.cpp:65:40: note: clone 1 starts here
65 | } else if (key == "ReadRotations") {
| ^| pointIndices.assign_range(std::views::iota(0uz, nbPoints)); | ||
| } else { | ||
| for (const auto* prop : pointSelection_) { | ||
| const auto* sp = static_cast<const StringProperty*>(prop); |
There was a problem hiding this comment.
clang-tidy diagnostics
- do not use static_cast to downcast from a base to a derived class; use dynamic_cast instead [cppcoreguidelines-pro-type-static-cast-downcast]
| const auto* sp = static_cast<const StringProperty*>(prop); | |
| const auto* sp = dynamic_cast<const StringProperty*>(prop); |
No description provided.