Second linting pass and adding .clang_tidy file (#3128)

This commit is contained in:
Alexander Bock
2024-03-18 22:46:17 +01:00
committed by GitHub
parent 8e49847a47
commit 534f92c485
80 changed files with 291 additions and 230 deletions

View File

@@ -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(

View File

@@ -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 "

View File

@@ -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<GLint, 4> 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);

View File

@@ -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<GLfloat, 36> 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);

View File

@@ -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

View File

@@ -227,7 +227,7 @@ void RenderableDebugPlane::createPlane() {
// ============================
const GLfloat size = _size;
const GLfloat vertexData[] = {
const std::array<GLfloat, 36> 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);

View File

@@ -264,4 +264,4 @@ std::vector<std::vector<float>> ReadFileJob::product() {
return _octants;
}
} // namespace openspace::gaiamission
} // namespace openspace::gaia

View File

@@ -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,

View File

@@ -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] == '\"') {

View File

@@ -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;

View File

@@ -88,9 +88,9 @@ void LayerRenderSettings::onChange(const std::function<void()>& 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 {

View File

@@ -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();
}

View File

@@ -70,7 +70,7 @@ struct Chunk {
WantSplit
};
Chunk(const TileIndex& tileIndex);
Chunk(const TileIndex& ti);
const TileIndex tileIndex;
const GeodeticPatch surfacePatch;

View File

@@ -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();

View File

@@ -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;

View File

@@ -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

View File

@@ -398,7 +398,7 @@ DefaultTileProvider TemporalTileProvider::createTileProvider(
case Mode::Prototype: {
static const std::vector<std::string> 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<GLsizei>(writeTexture->width());

View File

@@ -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;

View File

@@ -118,4 +118,4 @@ void GuiMissionComponent::render() {
ImGui::End();
}
} // namespace openspace gui
} // namespace openspace::gui

View File

@@ -627,4 +627,4 @@ void GuiSpaceTimeComponent::render() {
ImGui::End();
}
} // namespace openspace gui
} // namespace openspace::gui

View File

@@ -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<glm::dvec4>(key)) {
const glm::dvec4 v = dictionary.value<glm::dvec4>(key);
if (d.hasValue<glm::dvec4>(key)) {
const glm::dvec4 v = d.value<glm::dvec4>(key);
object[key] = json::array({ v[0], v[1], v[2], v[3] });
}
else if (dictionary.hasValue<glm::dvec3>(key)) {
const glm::dvec3 v = dictionary.value<glm::dvec3>(key);
else if (d.hasValue<glm::dvec3>(key)) {
const glm::dvec3 v = d.value<glm::dvec3>(key);
object[key] = json::array({ v[0], v[1], v[2] });
}
else if (dictionary.hasValue<glm::dvec2>(key)) {
const glm::dvec2 v = dictionary.value<glm::dvec2>(key);
else if (d.hasValue<glm::dvec2>(key)) {
const glm::dvec2 v = d.value<glm::dvec2>(key);
object[key] = json::array({ v[0], v[1] });
}
else if (dictionary.hasValue<double>(key)) {
object[key] = dictionary.value<double>(key);
else if (d.hasValue<double>(key)) {
object[key] = d.value<double>(key);
}
else if (dictionary.hasValue<int>(key)) {
object[key] = dictionary.value<int>(key);
else if (d.hasValue<int>(key)) {
object[key] = d.value<int>(key);
}
else if (dictionary.hasValue<std::string>(key)) {
object[key] = dictionary.value<std::string>(key);
else if (d.hasValue<std::string>(key)) {
object[key] = d.value<std::string>(key);
}
else if (dictionary.hasValue<bool>(key)) {
object[key] = dictionary.value<bool>(key);
else if (d.hasValue<bool>(key)) {
object[key] = d.value<bool>(key);
}
else if (dictionary.hasValue<Dictionary>(key)) {
else if (d.hasValue<Dictionary>(key)) {
json child;
to_json(child, dictionary.value<Dictionary>(key));
to_json(child, d.value<Dictionary>(key));
object[key] = child;
}
else {
@@ -167,4 +167,4 @@ void to_json(json& j, const dvec3& v) {
};
}
} // namepsace glm
} // namespace glm

View File

@@ -297,5 +297,4 @@ ghoul::io::SocketServer* ServerInterface::server() {
return _socketServer.get();
}
}
} // namespace openspace

View File

@@ -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

View File

@@ -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<double>();
@@ -275,4 +275,4 @@ glm::dvec3 Animation<glm::dvec3>::newValue() const {
return glm::dvec3(rotMat * glm::dvec4(_start, 1.0));;
}
} // namespace openspace
} // namespace openspace::skybrowser

Submodule modules/sound/ext/soloud added at 1157475881

View File

@@ -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<HttpFileDownload>(
url,

View File

@@ -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);

View File

@@ -446,4 +446,4 @@ void RenderableOrbitalKepler::updateBuffers() {
setBoundingSphere(maxSemiMajorAxis * 1000);
}
} // namespace opensapce
} // namespace openspace

View File

@@ -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);

View File

@@ -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);

View File

@@ -68,10 +68,10 @@ documentation::Documentation RenderablePlaneProjection::Documentation() {
return codegen::doc<Parameters>("spacecraftinstruments_renderableplaneprojection");
}
RenderablePlaneProjection::RenderablePlaneProjection(const ghoul::Dictionary& dict)
: Renderable(dict)
RenderablePlaneProjection::RenderablePlaneProjection(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
{
const Parameters p = codegen::bake<Parameters>(dict);
const Parameters p = codegen::bake<Parameters>(dictionary);
_spacecraft = p.spacecraft;
_instrument = p.instrument;
_defaultTarget = p.defaultTarget.value_or(_defaultTarget);

View File

@@ -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;

View File

@@ -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<int64_t>) {
return !c;
});

View File

@@ -909,4 +909,4 @@ void VideoPlayer::resizeTexture(glm::ivec2 size) {
}
}
} // namespace openspace::video
} // namespace openspace

View File

@@ -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<EnvelopePoint> vec) {
_points = std::move(vec);
}
Envelope::Envelope(std::vector<EnvelopePoint> 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<char>(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<int>(vec.r));
std::string g = decimalToHexadecimal(static_cast<int>(vec.g));
std::string b = decimalToHexadecimal(static_cast<int>(vec.b));
const std::string r = decimalToHexadecimal(static_cast<int>(vec.r));
const std::string g = decimalToHexadecimal(static_cast<int>(vec.g));
const std::string b = decimalToHexadecimal(static_cast<int>(vec.b));
return ("#" + r + g + b);
}

View File

@@ -56,7 +56,7 @@ public:
const std::vector<EnvelopePoint>& 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;

View File

@@ -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) {

View File

@@ -123,6 +123,8 @@ WebBrowserModule::WebBrowserModule()
addProperty(_browserUpdateInterval);
}
WebBrowserModule::~WebBrowserModule() {}
void WebBrowserModule::internalDeinitialize() {
ZoneScoped;

View File

@@ -49,7 +49,7 @@ public:
static constexpr const char* Name = "WebBrowser";
WebBrowserModule();
~WebBrowserModule() override = default;
~WebBrowserModule() override;
void addBrowser(BrowserInstance*);
void removeBrowser(BrowserInstance*);