Skip to content

Commit

Permalink
Fix/suppress various misc-const-correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
timangus committed Oct 27, 2023
1 parent bb1710c commit cc317b1
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
12 changes: 6 additions & 6 deletions source/app/commands/editattributecommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ bool EditAttributeCommand::execute()
if(userDataVector == nullptr)
return false;

UserDataVector::Type type = UserDataVector::equivalentTypeFor(_newType);
const UserDataVector::Type type = UserDataVector::equivalentTypeFor(_newType);

if(!userDataVector->canConvertTo(type))
return false;

_originalType = attribute->valueType();

bool success = userData.setAttributeType(*_graphModel, _attributeName, type);
const bool success = userData.setAttributeType(*_graphModel, _attributeName, type);
Q_ASSERT(success);
}

if(_newDescription != attribute->description())
{
_originalDescription = attribute->description();

bool success = userData.setAttributeDescription(*_graphModel, _attributeName, _newDescription);
const bool success = userData.setAttributeDescription(*_graphModel, _attributeName, _newDescription);
Q_ASSERT(success);
}

Expand Down Expand Up @@ -150,13 +150,13 @@ void EditAttributeCommand::undo()

if(_originalType != ValueType::Unknown)
{
UserDataVector::Type type = UserDataVector::equivalentTypeFor(_originalType);
bool success = userData.setAttributeType(*_graphModel, _attributeName, type);
const UserDataVector::Type type = UserDataVector::equivalentTypeFor(_originalType);
const bool success = userData.setAttributeType(*_graphModel, _attributeName, type);
Q_ASSERT(success);
_originalType = ValueType::Unknown;
}

bool success = userData.setAttributeDescription(*_graphModel, _attributeName, _originalDescription);
const bool success = userData.setAttributeDescription(*_graphModel, _attributeName, _originalDescription);
Q_ASSERT(success);
_originalDescription = {};
};
Expand Down
10 changes: 5 additions & 5 deletions source/app/rendering/graphoverviewscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ void GraphOverviewScene::zoomTo(const std::vector<ComponentId>& componentIds, bo
auto componentsZoomFactor = zoomFactorFor(static_cast<float>(_width), static_cast<float>(_height),
static_cast<float>(zoomedBoundingBox.width()), static_cast<float>(zoomedBoundingBox.height()));

bool zoomFactorChanged = setZoomFactor(componentsZoomFactor);
bool offsetChanged = setOffsetForBoundingBox(zoomedBoundingBox);
bool force = _graphRenderer->transition().active();
const bool zoomFactorChanged = setZoomFactor(componentsZoomFactor);
const bool offsetChanged = setOffsetForBoundingBox(zoomedBoundingBox);
const bool force = _graphRenderer->transition().active();

if(!zoomFactorChanged && !offsetChanged && !force)
return;
Expand Down Expand Up @@ -366,7 +366,7 @@ void GraphOverviewScene::updateZoomedComponentLayoutData()

void GraphOverviewScene::setViewportSize(int width, int height)
{
bool viewWasReset = viewIsReset();
const bool viewWasReset = viewIsReset();

_width = width;
_height = height;
Expand Down Expand Up @@ -540,7 +540,7 @@ void GraphOverviewScene::startZoomTransition(float duration)
_graphRenderer->transition().cancel();

ComponentLayoutData targetZoomedComponentLayoutData(_graphModel->graph());
ComponentArray<float> targetComponentAlpha(_graphModel->graph(), 1.0f);
const ComponentArray<float> targetComponentAlpha(_graphModel->graph(), 1.0f);

_previousZoomedComponentLayoutData = _zoomedComponentLayoutData;
_previousComponentAlpha = _componentAlpha;
Expand Down
8 changes: 4 additions & 4 deletions source/app/rendering/openglfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ QSurfaceFormat OpenGLFunctions::minimumFormat()

void OpenGLFunctions::requestMinimumFormat()
{
auto defaultFormat = QSurfaceFormat::defaultFormat();
std::pair<int, int> defaultVersion = {defaultFormat.majorVersion(), defaultFormat.minorVersion()};
auto requestFormat = minimumFormat();
std::pair<int, int> requestVersion = {requestFormat.majorVersion(), requestFormat.minorVersion()};
const auto defaultFormat = QSurfaceFormat::defaultFormat();
const std::pair<int, int> defaultVersion = {defaultFormat.majorVersion(), defaultFormat.minorVersion()};
const auto requestFormat = minimumFormat();
const std::pair<int, int> requestVersion = {requestFormat.majorVersion(), requestFormat.minorVersion()};

if(defaultVersion < requestVersion)
QSurfaceFormat::setDefaultFormat(requestFormat);
Expand Down
6 changes: 3 additions & 3 deletions source/plugins/correlation/correlationplotitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,15 @@ void CorrelationPlotItem::paint(QPainter* painter)
// it had been rendered from the top left
const int yOffset = static_cast<int>(height() - (_pixmap.height() / devicePixelRatio));

QRect target
const QRect target
{
0,
yOffset,
static_cast<int>(width()),
static_cast<int>(height()) - yOffset
};

QRect source
const QRect source
{
0, 0,
static_cast<int>(width() * devicePixelRatio),
Expand Down Expand Up @@ -969,7 +969,7 @@ void CorrelationPlotItem::onClick(const QMouseEvent* event)
auto* axis = axisRect->axis(QCPAxis::atBottom);
auto column = static_cast<size_t>(std::round(axis->pixelToCoord(event->pos().x())));

bool toggle = event->modifiers().testFlag(Qt::ControlModifier);
const bool toggle = event->modifiers().testFlag(Qt::ControlModifier);

if(!toggle)
_selectedColumns.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ void CorrelationPlotItem::onClickColumnAnnotation(const QCPAxisRect* axisRect, c
}

auto pos = event->pos() - axisRect->topLeft();
bool clickOnName = pos.x() < 0;
const bool clickOnName = pos.x() < 0;
auto p = columnAnnotationPositionForPixel(axisRect, pos.toPointF());

if(p.y() < 0)
Expand Down Expand Up @@ -534,7 +534,7 @@ void CorrelationPlotItem::onClickColumnAnnotation(const QCPAxisRect* axisRect, c
const auto* rect = qcpColumnAnnotations->rectAt(
static_cast<size_t>(p.x()), *columnAnnotations.at(static_cast<size_t>(p.y())));

bool toggle = event->modifiers().testFlag(Qt::ControlModifier);
const bool toggle = event->modifiers().testFlag(Qt::ControlModifier);

if(!toggle)
_selectedColumns.clear();
Expand All @@ -552,7 +552,7 @@ void CorrelationPlotItem::onClickColumnAnnotation(const QCPAxisRect* axisRect, c
indices.push_back(_sortMap.at(i));
}

bool selected = std::all_of(indices.begin(), indices.end(),
const bool selected = std::all_of(indices.begin(), indices.end(),
[this](size_t index) { return _selectedColumns.contains(index); });

for(auto index : indices)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ CorrelationPlotSaveImageCommand::CorrelationPlotSaveImageCommand(
QUrl target;

const QFileInfo fileInfo(_baseFilename);
QString extensionlessBaseFilename =
const QString extensionlessBaseFilename =
QString::compare(fileInfo.suffix(), _extension, Qt::CaseInsensitive) == 0 ?
fileInfo.completeBaseName() : fileInfo.fileName();

Expand Down
8 changes: 4 additions & 4 deletions source/plugins/correlation/correlationplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,8 @@ void CorrelationPluginInstance::rebuildColumnAnnotations()
_columnAnnotations = columnAnnotations;
auto after = columnAnnotationNames();

QStringList addedNames = u::toQStringList(u::setDifference(after, before));
QStringList removedNames = u::toQStringList(u::setDifference(before, after));
const QStringList addedNames = u::toQStringList(u::setDifference(after, before));
const QStringList removedNames = u::toQStringList(u::setDifference(before, after));

emit columnAnnotationNamesChanged(addedNames, removedNames);

Expand Down Expand Up @@ -941,9 +941,9 @@ std::vector<int> CorrelationPluginInstance::rowsOfInterestByColumns(const std::v
for(auto column : columns)
columnsSum += dataRow.valueAt(static_cast<size_t>(column));

double otherColumnsSum = dataRow.sum() - columnsSum;
const double otherColumnsSum = dataRow.sum() - columnsSum;

RowScore rowScore
const RowScore rowScore
{
row,
(columnsSum * positiveWeight) - (otherColumnsSum * negativeWeight)
Expand Down
2 changes: 1 addition & 1 deletion source/shared/loading/userelementdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class UserElementData : public IUserElementData<E>, public UserData
json jsonObject = UserData::save(progressable, indexes);
jsonObject["ids"] = jsonIds;

json jsonAttributes = json::object();
json jsonAttributes = json::object(); // NOLINT misc-const-correctness
for(const auto& [attributeName, override] : _exposedAttributeOverrides)
{
auto& jsonAttribute = jsonAttributes[attributeName.toStdString()];
Expand Down

0 comments on commit cc317b1

Please sign in to comment.