mirror of
https://github.com/Murmele/Gittyup.git
synced 2024-11-03 21:24:30 +03:00
chore(compiler warnings): replace -Wswitch-enum
with -Wswitch
and fix remaining issues.
Moved the `throw` statements introduced in an earlier commit to after the `switch` statement and removed the `default` which could mask an unhandled case. Changed some situations where every enum item was listed, but fell through to a default action by replacing the explicitly enumerated items with a `default`. This was primarily where the enum was defined in an external library.
This commit is contained in:
parent
98eb73bc15
commit
39539746e5
@ -1,6 +1,6 @@
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
add_compile_options(-Werror=switch-enum)
|
||||
add_compile_options(-Werror=switch)
|
||||
|
||||
add_subdirectory(util)
|
||||
add_subdirectory(cli)
|
||||
|
@ -73,55 +73,7 @@ public:
|
||||
CustomTheme::drawCloseButton(option, painter);
|
||||
break;
|
||||
|
||||
case PE_Frame: // fall through
|
||||
case PE_FrameDefaultButton: // fall through
|
||||
case PE_FrameDockWidget: // fall through
|
||||
case PE_FrameFocusRect: // fall through
|
||||
case PE_FrameGroupBox: // fall through
|
||||
case PE_FrameLineEdit: // fall through
|
||||
case PE_FrameMenu: // fall through
|
||||
case PE_FrameStatusBarItem: // fall through
|
||||
case PE_FrameTabWidget: // fall through
|
||||
case PE_FrameWindow: // fall through
|
||||
case PE_FrameButtonBevel: // fall through
|
||||
case PE_FrameButtonTool: // fall through
|
||||
case PE_FrameTabBarBase: // fall through
|
||||
case PE_PanelButtonCommand: // fall through
|
||||
case PE_PanelButtonBevel: // fall through
|
||||
case PE_PanelButtonTool: // fall through
|
||||
case PE_PanelMenuBar: // fall through
|
||||
case PE_PanelToolBar: // fall through
|
||||
case PE_PanelLineEdit: // fall through
|
||||
case PE_IndicatorArrowDown: // fall through
|
||||
case PE_IndicatorArrowLeft: // fall through
|
||||
case PE_IndicatorArrowRight: // fall through
|
||||
case PE_IndicatorArrowUp: // fall through
|
||||
case PE_IndicatorBranch: // fall through
|
||||
case PE_IndicatorButtonDropDown: // fall through
|
||||
case PE_IndicatorItemViewItemCheck: // fall through
|
||||
case PE_IndicatorDockWidgetResizeHandle: // fall through
|
||||
case PE_IndicatorHeaderArrow: // fall through
|
||||
case PE_IndicatorMenuCheckMark: // fall through
|
||||
case PE_IndicatorProgressChunk: // fall through
|
||||
case PE_IndicatorRadioButton: // fall through
|
||||
case PE_IndicatorSpinDown: // fall through
|
||||
case PE_IndicatorSpinMinus: // fall through
|
||||
case PE_IndicatorSpinPlus: // fall through
|
||||
case PE_IndicatorSpinUp: // fall through
|
||||
case PE_IndicatorToolBarHandle: // fall through
|
||||
case PE_IndicatorToolBarSeparator: // fall through
|
||||
case PE_PanelTipLabel: // fall through
|
||||
case PE_IndicatorTabTear: // fall through
|
||||
case PE_PanelScrollAreaCorner: // fall through
|
||||
case PE_Widget: // fall through
|
||||
case PE_IndicatorColumnViewArrow: // fall through
|
||||
case PE_IndicatorItemViewItemDrop: // fall through
|
||||
case PE_PanelItemViewItem: // fall through
|
||||
case PE_PanelItemViewRow: // fall through
|
||||
case PE_PanelStatusBar: // fall through
|
||||
case PE_PanelMenu: // fall through
|
||||
case PE_IndicatorTabTearRight: // fall through
|
||||
case PE_CustomBase: // fall through
|
||||
default:
|
||||
baseStyle()->drawPrimitive(elem, option, painter, widget);
|
||||
break;
|
||||
}
|
||||
@ -484,7 +436,7 @@ QColor CustomTheme::commitEditor(CommitEditor color) {
|
||||
case CommitEditor::LengthWarning:
|
||||
return commitEditor.value("lengthwarning").value<QColor>();
|
||||
}
|
||||
throw std::runtime_error("Not Implemented or invalid enum " +
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(color)));
|
||||
}
|
||||
|
||||
@ -515,7 +467,7 @@ QColor CustomTheme::diff(Diff color) {
|
||||
case Diff::Error:
|
||||
return diff.value("error").value<QColor>();
|
||||
}
|
||||
throw std::runtime_error("Not Implemented or invalid enum" +
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(color)));
|
||||
}
|
||||
|
||||
@ -527,10 +479,9 @@ QColor CustomTheme::heatMap(HeatMap color) {
|
||||
return QColor(heatmap.value("hot").toString());
|
||||
case HeatMap::Cold:
|
||||
return QColor(heatmap.value("cold").toString());
|
||||
default:
|
||||
throw std::runtime_error("Not Implemented or invalid enum" +
|
||||
std::to_string(static_cast<int>(color)));
|
||||
}
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(color)));
|
||||
}
|
||||
|
||||
QColor CustomTheme::remoteComment(Comment color) {
|
||||
@ -545,10 +496,9 @@ QColor CustomTheme::remoteComment(Comment color) {
|
||||
return QColor(comment.value("author").toString());
|
||||
case Comment::Timestamp:
|
||||
return QColor(comment.value("timestamp").toString());
|
||||
default:
|
||||
throw std::runtime_error("Not Implemented or invalid enum" +
|
||||
std::to_string(static_cast<int>(color)));
|
||||
}
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(color)));
|
||||
}
|
||||
|
||||
QColor CustomTheme::star() {
|
||||
|
@ -108,7 +108,7 @@ QColor Theme::badge(BadgeRole role, BadgeState state) {
|
||||
case BadgeState::Added: // fall through
|
||||
case BadgeState::Deleted: // fall through
|
||||
case BadgeState::Untracked: // fall through
|
||||
case BadgeState::Renamed:
|
||||
case BadgeState::Renamed: // fall through
|
||||
return QPalette().color(QPalette::WindowText);
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ QColor Theme::commitEditor(CommitEditor color) {
|
||||
case CommitEditor::LengthWarning:
|
||||
return Qt::yellow;
|
||||
}
|
||||
throw std::runtime_error("Not Implemented or invalid enum" +
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(color)));
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ QColor Theme::diff(Diff color) {
|
||||
case Diff::Error:
|
||||
return "#7E494B";
|
||||
}
|
||||
throw std::runtime_error("Not Implemented or invalid enum" +
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(color)));
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ QColor Theme::diff(Diff color) {
|
||||
case Diff::Error:
|
||||
return "#FF0000";
|
||||
}
|
||||
throw std::runtime_error("Not Implemented or invalid enum" +
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(color)));
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ QColor Theme::heatMap(HeatMap color) {
|
||||
return mDark ? QPalette().color(QPalette::Inactive, QPalette::Highlight)
|
||||
: QPalette().color(QPalette::Mid);
|
||||
}
|
||||
throw std::runtime_error("Not Implemented or invalid enum" +
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(color)));
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ QColor Theme::remoteComment(Comment color) {
|
||||
case Comment::Timestamp:
|
||||
return QPalette().color(QPalette::WindowText);
|
||||
}
|
||||
throw std::runtime_error("Not Implemented or invalid enum" +
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(color)));
|
||||
}
|
||||
|
||||
|
@ -171,11 +171,9 @@ QString Settings::promptDescription(Prompt::Kind kind) const {
|
||||
|
||||
case Prompt::Kind::LargeFiles:
|
||||
return tr("Prompt to stage large files");
|
||||
|
||||
default:
|
||||
throw std::runtime_error("Not Implemented or invalid enum" +
|
||||
std::to_string(static_cast<int>(kind)));
|
||||
}
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(kind)));
|
||||
}
|
||||
|
||||
void Settings::setHotkey(const QString &action, const QString &hotkey) {
|
||||
|
@ -197,11 +197,9 @@ void Diff::sort(SortRole role, Qt::SortOrder order) {
|
||||
return ascending ? (lhsStatus < rhsStatus)
|
||||
: (rhsStatus < lhsStatus);
|
||||
}
|
||||
|
||||
default:
|
||||
throw std::runtime_error("Unhandled case or invalid enum " +
|
||||
std::to_string(static_cast<int>(role)));
|
||||
}
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(role)));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -435,6 +435,7 @@ void Patch::apply(QList<QList<QByteArray>> &image, int hidx, int start_line,
|
||||
break;
|
||||
|
||||
default:
|
||||
// no-op
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -629,6 +629,7 @@ Commit Repository::commit(const Signature &author, const Signature &committer,
|
||||
break;
|
||||
|
||||
default:
|
||||
// no-op
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -203,11 +203,9 @@ QString Account::helpText(Kind kind) {
|
||||
case Bitbucket:
|
||||
case Beanstalk:
|
||||
return QString();
|
||||
|
||||
default:
|
||||
throw std::runtime_error("Unhandled case or invalid enum " +
|
||||
std::to_string(static_cast<int>(kind)));
|
||||
}
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(kind)));
|
||||
}
|
||||
|
||||
QString Account::defaultUrl(Kind kind) {
|
||||
@ -222,10 +220,9 @@ QString Account::defaultUrl(Kind kind) {
|
||||
return Beanstalk::defaultUrl();
|
||||
case GitLab:
|
||||
return GitLab::defaultUrl();
|
||||
default:
|
||||
throw std::runtime_error("Unhandled case or invalid enum " +
|
||||
std::to_string(static_cast<int>(kind)));
|
||||
}
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(kind)));
|
||||
}
|
||||
|
||||
Account::Kind Account::kindFromString(const QString &kind, bool *ok) {
|
||||
@ -264,10 +261,9 @@ QString Account::kindToString(Kind kind) {
|
||||
return "beanstalk";
|
||||
case GitLab:
|
||||
return "gitlab";
|
||||
default:
|
||||
throw std::runtime_error("Unhandled case or invalid enum " +
|
||||
std::to_string(static_cast<int>(kind)));
|
||||
}
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(kind)));
|
||||
}
|
||||
|
||||
void Account::startProgress() {
|
||||
|
@ -442,10 +442,9 @@ QByteArray Index::fieldName(Index::Field field) {
|
||||
return "after";
|
||||
case Index::Pathspec:
|
||||
return "pathspec";
|
||||
default:
|
||||
throw std::runtime_error("Unhandled case or invalid enum " +
|
||||
std::to_string(static_cast<int>(field)));
|
||||
}
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(field)));
|
||||
}
|
||||
|
||||
QDir Index::indexDir(const git::Repository &repo) {
|
||||
|
@ -74,23 +74,7 @@ public:
|
||||
return (tmp < date);
|
||||
case Index::After:
|
||||
return (tmp > date);
|
||||
case Index::Id: // fall through
|
||||
case Index::Author: // fall through
|
||||
case Index::Email: // fall through
|
||||
case Index::Message: // fall through
|
||||
case Index::Date: // fall through
|
||||
case Index::Path: // fall through
|
||||
case Index::File: // fall through
|
||||
case Index::Scope: // fall through
|
||||
case Index::Context: // fall through
|
||||
case Index::Addition: // fall through
|
||||
case Index::Deletion: // fall through
|
||||
case Index::Any: // fall through
|
||||
case Index::Comment: // fall through
|
||||
case Index::String: // fall through
|
||||
case Index::Identifier: // fall through
|
||||
case Index::Is: // fall through
|
||||
case Index::Pathspec:
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
|
@ -613,12 +613,9 @@ QVariant Plugin::optionValue(const QString &key) const {
|
||||
|
||||
case String:
|
||||
return config().value<QString>(kKeyFmt.arg(mName, key), value.toString());
|
||||
|
||||
default:
|
||||
throw std::runtime_error(
|
||||
"Not Implemented or invalid enum" +
|
||||
std::to_string(static_cast<int>(optionKind(key))));
|
||||
}
|
||||
throw std::runtime_error("unreachable; value=" +
|
||||
std::to_string(static_cast<int>(optionKind(key))));
|
||||
}
|
||||
|
||||
Plugin::OptionKind Plugin::optionKind(const QString &key) const {
|
||||
|
@ -97,27 +97,8 @@ void EditorWindow::closeEvent(QCloseEvent *event) {
|
||||
case QMessageBox::Save:
|
||||
editor->save();
|
||||
break;
|
||||
case QMessageBox::NoButton:
|
||||
case QMessageBox::SaveAll:
|
||||
case QMessageBox::Open:
|
||||
case QMessageBox::Yes:
|
||||
case QMessageBox::No:
|
||||
case QMessageBox::Abort:
|
||||
case QMessageBox::Retry:
|
||||
case QMessageBox::Ignore:
|
||||
case QMessageBox::Close:
|
||||
case QMessageBox::Discard:
|
||||
case QMessageBox::Help:
|
||||
case QMessageBox::Apply:
|
||||
case QMessageBox::Reset:
|
||||
case QMessageBox::RestoreDefaults:
|
||||
case QMessageBox::FirstButton:
|
||||
case QMessageBox::YesAll:
|
||||
case QMessageBox::NoAll:
|
||||
case QMessageBox::Default:
|
||||
case QMessageBox::Escape:
|
||||
case QMessageBox::FlagMask:
|
||||
case QMessageBox::ButtonMask:
|
||||
default:
|
||||
// no-op
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
break;
|
||||
|
||||
default:
|
||||
// no-op
|
||||
break; // FIXME: Report error?
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user