forked from qt-creator/qt-creator
GitPlugin: Simplify return statements
Change-Id: If09c93acade749326b95bb1c6068b2d43a4d8551 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -264,22 +264,22 @@ BranchModel::~BranchModel()
|
||||
QModelIndex BranchModel::index(int row, int column, const QModelIndex &parentIdx) const
|
||||
{
|
||||
if (column > 1)
|
||||
return QModelIndex();
|
||||
return {};
|
||||
BranchNode *parentNode = indexToNode(parentIdx);
|
||||
|
||||
if (row >= parentNode->count())
|
||||
return QModelIndex();
|
||||
return {};
|
||||
return nodeToIndex(parentNode->children.at(row), column);
|
||||
}
|
||||
|
||||
QModelIndex BranchModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
return {};
|
||||
|
||||
BranchNode *node = indexToNode(index);
|
||||
if (node->parent == d->rootNode)
|
||||
return QModelIndex();
|
||||
return {};
|
||||
return nodeToIndex(node->parent, ColumnBranch);
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ QVariant BranchModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
BranchNode *node = indexToNode(index);
|
||||
if (!node)
|
||||
return QVariant();
|
||||
return {};
|
||||
|
||||
switch (role) {
|
||||
case Qt::DisplayRole: {
|
||||
@@ -330,7 +330,7 @@ QVariant BranchModel::data(const QModelIndex &index, int role) const
|
||||
return index.column() == 0 ? node->fullRef() : QVariant();
|
||||
case Qt::ToolTipRole:
|
||||
if (!node->isLeaf())
|
||||
return QVariant();
|
||||
return {};
|
||||
if (node->toolTip.isEmpty())
|
||||
node->toolTip = toolTip(node->sha);
|
||||
return node->toolTip;
|
||||
@@ -346,7 +346,7 @@ QVariant BranchModel::data(const QModelIndex &index, int role) const
|
||||
return font;
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,17 +524,17 @@ FilePath BranchModel::workingDirectory() const
|
||||
QModelIndex BranchModel::currentBranch() const
|
||||
{
|
||||
if (!d->currentBranch)
|
||||
return QModelIndex();
|
||||
return {};
|
||||
return nodeToIndex(d->currentBranch, ColumnBranch);
|
||||
}
|
||||
|
||||
QString BranchModel::fullName(const QModelIndex &idx, bool includePrefix) const
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return QString();
|
||||
return {};
|
||||
BranchNode *node = indexToNode(idx);
|
||||
if (!node || !node->isLeaf())
|
||||
return QString();
|
||||
return {};
|
||||
if (node == d->headNode)
|
||||
return QString("HEAD");
|
||||
return node->fullRef(includePrefix);
|
||||
@@ -550,7 +550,7 @@ QStringList BranchModel::localBranchNames() const
|
||||
QString BranchModel::sha(const QModelIndex &idx) const
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return QString();
|
||||
return {};
|
||||
BranchNode *node = indexToNode(idx);
|
||||
return node->sha;
|
||||
}
|
||||
@@ -558,13 +558,11 @@ QString BranchModel::sha(const QModelIndex &idx) const
|
||||
QDateTime BranchModel::dateTime(const QModelIndex &idx) const
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return QDateTime();
|
||||
return {};
|
||||
BranchNode *node = indexToNode(idx);
|
||||
return node->dateTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool BranchModel::isHead(const QModelIndex &idx) const
|
||||
{
|
||||
if (!idx.isValid())
|
||||
@@ -679,7 +677,7 @@ static int positionForName(BranchNode *node, const QString &name)
|
||||
QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModelIndex &startPoint)
|
||||
{
|
||||
if (!d->rootNode || !d->rootNode->count())
|
||||
return QModelIndex();
|
||||
return {};
|
||||
|
||||
const QString trackedBranch = fullName(startPoint);
|
||||
const QString fullTrackedBranch = fullName(startPoint, true);
|
||||
@@ -705,7 +703,7 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
|
||||
|
||||
if (!gitClient().synchronousBranchCmd(d->workingDirectory, args, &output, &errorMessage)) {
|
||||
VcsOutputWindow::appendError(errorMessage);
|
||||
return QModelIndex();
|
||||
return {};
|
||||
}
|
||||
|
||||
BranchNode *local = d->rootNode->children.at(LocalBranches);
|
||||
@@ -761,7 +759,7 @@ std::optional<QString> BranchModel::remoteName(const QModelIndex &idx) const
|
||||
if (!node)
|
||||
return std::nullopt;
|
||||
if (node == remotesNode)
|
||||
return QString();
|
||||
return {};
|
||||
if (node->parent == remotesNode)
|
||||
return node->name;
|
||||
return std::nullopt;
|
||||
@@ -888,7 +886,7 @@ BranchNode *BranchModel::indexToNode(const QModelIndex &index) const
|
||||
QModelIndex BranchModel::nodeToIndex(BranchNode *node, int column) const
|
||||
{
|
||||
if (node == d->rootNode)
|
||||
return QModelIndex();
|
||||
return {};
|
||||
return createIndex(node->parent->rowOf(node), column, static_cast<void *>(node));
|
||||
}
|
||||
|
||||
|
||||
@@ -333,7 +333,7 @@ QModelIndex BranchView::selectedIndex()
|
||||
{
|
||||
QModelIndexList selected = m_branchView->selectionModel()->selectedIndexes();
|
||||
if (selected.isEmpty())
|
||||
return QModelIndex();
|
||||
return {};
|
||||
return m_filterModel->mapToSource(selected.at(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ static QString findEntry(const QString &line, const QString &type)
|
||||
const QRegularExpressionMatch match = entryMatch(line, type);
|
||||
if (match.hasMatch())
|
||||
return match.captured(1);
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
static bool replaceEntry(QString &line, const QString &type, const QString &value)
|
||||
|
||||
@@ -81,7 +81,7 @@ static inline QString defaultUrl(const QSharedPointer<GerritParameters> &p,
|
||||
QString GerritPatchSet::approvalsToHtml() const
|
||||
{
|
||||
if (approvals.isEmpty())
|
||||
return QString();
|
||||
return {};
|
||||
|
||||
QString result;
|
||||
QTextStream str(&result);
|
||||
@@ -411,7 +411,7 @@ QString GerritModel::toHtml(const QModelIndex& index) const
|
||||
static const QString neededByHeader = Git::Tr::tr("Needed by");
|
||||
|
||||
if (!index.isValid())
|
||||
return QString();
|
||||
return {};
|
||||
const GerritChangePtr c = change(index);
|
||||
const QString serverPrefix = c->url.left(c->url.lastIndexOf('/') + 1);
|
||||
QString result;
|
||||
|
||||
@@ -56,7 +56,7 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
|
||||
|
||||
if (!gitClient().synchronousBranchCmd(
|
||||
m_workingDir, {"-r", "--contains", earliestCommit + '^'}, &output, &error)) {
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
const QString head = "/HEAD";
|
||||
const QStringList refs = output.split('\n');
|
||||
|
||||
@@ -1677,7 +1677,7 @@ QString GitClient::synchronousTopic(const FilePath &workingDirectory) const
|
||||
// Detached HEAD, try a tag or remote branch
|
||||
QStringList references;
|
||||
if (!synchronousHeadRefs(workingDirectory, &references))
|
||||
return QString();
|
||||
return {};
|
||||
|
||||
const QString tagStart("refs/tags/");
|
||||
const QString remoteStart("refs/remotes/");
|
||||
@@ -2262,7 +2262,7 @@ QString GitClient::commandInProgressDescription(const FilePath &workingDirectory
|
||||
case Merge:
|
||||
return Tr::tr("MERGING");
|
||||
}
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
GitClient::CommandInProgress GitClient::checkCommandInProgress(const FilePath &workingDirectory) const
|
||||
|
||||
@@ -110,11 +110,11 @@ QString GitEditorWidget::changeUnderCursor(const QTextCursor &c) const
|
||||
// Any number is regarded as change number.
|
||||
cursor.select(QTextCursor::WordUnderCursor);
|
||||
if (!cursor.hasSelection())
|
||||
return QString();
|
||||
return {};
|
||||
const QString change = cursor.selectedText();
|
||||
if (m_changeNumberPattern.match(change).hasMatch())
|
||||
return change;
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
BaseAnnotationHighlighter *GitEditorWidget::createAnnotationHighlighter(const QSet<QString> &changes) const
|
||||
@@ -317,7 +317,7 @@ QString GitEditorWidget::revisionSubject(const QTextBlock &inBlock) const
|
||||
return block.text().trimmed();
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
bool GitEditorWidget::supportChangeLinks() const
|
||||
@@ -363,21 +363,21 @@ QWidget *GitEditorWidget::addFilterWidget()
|
||||
QString GitEditorWidget::grepValue() const
|
||||
{
|
||||
if (!m_logFilterWidget)
|
||||
return QString();
|
||||
return {};
|
||||
return m_logFilterWidget->grepLineEdit->text();
|
||||
}
|
||||
|
||||
QString GitEditorWidget::pickaxeValue() const
|
||||
{
|
||||
if (!m_logFilterWidget)
|
||||
return QString();
|
||||
return {};
|
||||
return m_logFilterWidget->pickaxeLineEdit->text();
|
||||
}
|
||||
|
||||
QString GitEditorWidget::authorValue() const
|
||||
{
|
||||
if (!m_logFilterWidget)
|
||||
return QString();
|
||||
return {};
|
||||
return m_logFilterWidget->authorLineEdit->text();
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ QString LogChangeWidget::commit() const
|
||||
{
|
||||
if (const QStandardItem *sha1Item = currentItem(Sha1Column))
|
||||
return sha1Item->text();
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
int LogChangeWidget::commitIndex() const
|
||||
@@ -113,7 +113,7 @@ QString LogChangeWidget::earliestCommit() const
|
||||
if (const QStandardItem *item = m_model->item(rows - 1, Sha1Column))
|
||||
return item->text();
|
||||
}
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
void LogChangeWidget::setItemDelegate(QAbstractItemDelegate *delegate)
|
||||
@@ -269,7 +269,7 @@ int LogChangeDialog::commitIndex() const
|
||||
QString LogChangeDialog::resetFlag() const
|
||||
{
|
||||
if (!m_resetTypeComboBox)
|
||||
return QString();
|
||||
return {};
|
||||
return m_resetTypeComboBox->itemData(m_resetTypeComboBox->currentIndex()).toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ QString MergeTool::mergeTypeName()
|
||||
case DeletedMerge: return Tr::tr("Deleted");
|
||||
case SymbolicLinkMerge: return Tr::tr("Symbolic link");
|
||||
}
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
QString MergeTool::stateName(MergeTool::FileState state, const QString &extraInfo)
|
||||
@@ -107,7 +107,7 @@ QString MergeTool::stateName(MergeTool::FileState state, const QString &extraInf
|
||||
case SymbolicLinkState: return Tr::tr("Symbolic link -> %1").arg(extraInfo);
|
||||
default: break;
|
||||
}
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
void MergeTool::chooseAction()
|
||||
|
||||
@@ -112,14 +112,13 @@ QVariant RemoteModel::data(const QModelIndex &index, int role) const
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
QVariant RemoteModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || orientation != Qt::Horizontal)
|
||||
return QVariant();
|
||||
|
||||
return {};
|
||||
return (section == 0) ? Tr::tr("Name") : Tr::tr("URL");
|
||||
}
|
||||
|
||||
|
||||
@@ -234,14 +234,14 @@ static inline QString nextStash(const QString &stash)
|
||||
{
|
||||
const int openingBracePos = stash.indexOf('{');
|
||||
if (openingBracePos == -1)
|
||||
return QString();
|
||||
return {};
|
||||
const int closingBracePos = stash.indexOf('}', openingBracePos + 2);
|
||||
if (closingBracePos == -1)
|
||||
return QString();
|
||||
return {};
|
||||
bool ok;
|
||||
const int n = stash.mid(openingBracePos + 1, closingBracePos - openingBracePos - 1).toInt(&ok);
|
||||
if (!ok)
|
||||
return QString();
|
||||
return {};
|
||||
QString rc = stash.left(openingBracePos + 1);
|
||||
rc += QString::number(n + 1);
|
||||
rc += '}';
|
||||
|
||||
@@ -51,7 +51,7 @@ QString Query::toString() const
|
||||
QString query = API_PREFIX;
|
||||
switch (m_type) {
|
||||
case Query::NoQuery:
|
||||
return QString();
|
||||
return {};
|
||||
case Query::Project:
|
||||
QTC_ASSERT(!m_parameter.isEmpty(), return {});
|
||||
query += QLatin1String(QUERY_PROJECT).arg(QLatin1String(
|
||||
|
||||
Reference in New Issue
Block a user