Commit 689bd09e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

USe if (...) vs if (foo == true) same for == false

parent 1a3eab7e
......@@ -183,7 +183,7 @@ void CrontabWidget::refreshCron()
mTasksWidget->refreshTasks(ctCron);
mVariablesWidget->refreshVariables(ctCron);
if (ctCron->isMultiUserCron() && ctHost()->isRootUser() == false) {
if (ctCron->isMultiUserCron() && !ctHost()->isRootUser()) {
logDebug() << "Disabling view...";
mTasksWidget->treeWidget()->setEnabled(false);
......@@ -369,7 +369,7 @@ void CrontabWidget::print()
{
CrontabPrinter printer(this);
if (printer.start() == false) {
if (!printer.start()) {
logDebug() << "Unable to start printer";
return;
}
......
......@@ -22,8 +22,8 @@ QString CTHelper::exportComment(const QString &comment)
return exportComment;
}
QStringList lines = comment.split(QStringLiteral("\n"));
foreach (const QString &line, lines) {
const QStringList lines = comment.split(QStringLiteral("\n"));
for (const QString &line : lines) {
exportComment += QLatin1String("#") + line + QLatin1String("\n");
}
......
......@@ -27,7 +27,7 @@ public:
bool hasErrorMessage()
{
if (mError.isEmpty() == true) {
if (mError.isEmpty()) {
return false;
}
......
......@@ -31,7 +31,7 @@ CommandLineStatus CommandLine::execute()
{
QProcess process;
if (standardOutputFile.isEmpty() == false) {
if (!standardOutputFile.isEmpty()) {
process.setStandardOutputFile(standardOutputFile);
}
......@@ -47,7 +47,7 @@ CommandLineStatus CommandLine::execute()
CommandLineStatus commandLineStatus;
commandLineStatus.commandLine = commandLine + QLatin1String(" ") + parameters.join(QLatin1String(" "));
if (standardOutputFile.isEmpty() == false) {
if (!standardOutputFile.isEmpty()) {
commandLineStatus.commandLine += QLatin1String(" > ") + standardOutputFile;
}
......@@ -76,7 +76,7 @@ CTCron::CTCron(const QString &crontabBinary, const struct passwd *userInfos, boo
CommandLine readCommandLine;
// regular user, so provide user's own crontab
if (currentUserCron == true) {
if (currentUserCron) {
readCommandLine.commandLine = d->crontabBinary;
readCommandLine.parameters << QStringLiteral("-l");
readCommandLine.standardOutputFile = d->tmpFileName;
......@@ -95,7 +95,7 @@ CTCron::CTCron(const QString &crontabBinary, const struct passwd *userInfos, boo
d->initialTaskCount = 0;
d->initialVariableCount = 0;
if (initializeFromUserInfos(userInfos) == false) {
if (!initializeFromUserInfos(userInfos)) {
ctInitializationError.setErrorMessage(i18n("No password entry found for uid '%1'", getuid()));
logDebug() << "Error in crontab creation of" << userInfos->pw_name;
return;
......@@ -137,7 +137,7 @@ CTCron &CTCron::operator =(const CTCron &source)
return *this;
}
if (source.isSystemCron() == true) {
if (source.isSystemCron()) {
logDebug() << "Affect the system cron";
}
......@@ -167,7 +167,7 @@ void CTCron::parseFile(const QString &fileName)
bool leadingComment = true;
QTextStream in(&file);
while (in.atEnd() == false) {
while (!in.atEnd()) {
QString line = in.readLine();
// search for comments "#" but not disabled tasks "#\"
......@@ -301,7 +301,7 @@ CTSaveStatus CTCron::save()
{
// write to temp file
bool saveStatus = saveToFile(d->tmpFileName);
if (saveStatus == false) {
if (!saveStatus) {
return CTSaveStatus(i18n("Unable to open crontab file for writing"), i18n("The file %1 could not be opened.", d->tmpFileName));
}
......
......@@ -36,8 +36,8 @@ CTHost::CTHost(const QString &cronBinary, CTInitializationError &ctInitializatio
setpwent(); // restart
while ((userInfos = getpwent())) {
if (allowDeny(userInfos->pw_name)) {
QString errorMessage = createCTCron(userInfos);
if (errorMessage.isEmpty() == false) {
const QString errorMessage = createCTCron(userInfos);
if (!errorMessage.isEmpty()) {
ctInitializationError.setErrorMessage(errorMessage);
return;
}
......@@ -67,8 +67,8 @@ CTHost::CTHost(const QString &cronBinary, CTInitializationError &ctInitializatio
passwd *currentUserPassword = getpwuid(uid);
QString errorMessage = createCTCron(currentUserPassword);
if (errorMessage.isEmpty() == false) {
const QString errorMessage = createCTCron(currentUserPassword);
if (!errorMessage.isEmpty()) {
ctInitializationError.setErrorMessage(errorMessage);
return;
}
......@@ -126,7 +126,7 @@ bool CTHost::allowDeny(char *name)
CTSaveStatus CTHost::save()
{
if (isRootUser() == false) {
if (!isRootUser()) {
logDebug() << "Save current user cron";
CTCron *ctCron = findCurrentUserCron();
......@@ -136,7 +136,7 @@ CTSaveStatus CTHost::save()
foreach (CTCron *ctCron, crons) {
CTSaveStatus ctSaveStatus = ctCron->save();
if (ctSaveStatus.isError() == true) {
if (ctSaveStatus.isError()) {
return CTSaveStatus(i18nc("User login: errorMessage", "User %1: %2", ctCron->userLogin(), ctSaveStatus.errorMessage()), ctSaveStatus.detailErrorMessage());
}
}
......@@ -231,7 +231,7 @@ CTCron *CTHost::findUserCron(const QString &userLogin) const
CTCron *CTHost::findCronContaining(CTTask *ctTask) const
{
foreach (CTCron *ctCron, crons) {
if (ctCron->tasks().contains(ctTask) == true) {
if (ctCron->tasks().contains(ctTask)) {
return ctCron;
}
}
......@@ -243,7 +243,7 @@ CTCron *CTHost::findCronContaining(CTTask *ctTask) const
CTCron *CTHost::findCronContaining(CTVariable *ctVariable) const
{
foreach (CTCron *ctCron, crons) {
if (ctCron->variables().contains(ctVariable) == true) {
if (ctCron->variables().contains(ctVariable)) {
return ctCron;
}
}
......
......@@ -59,7 +59,7 @@ CTTask::CTTask(const QString &tokenString, const QString &_comment, const QStrin
int spacePos(tokStr.indexOf(QRegExp(QLatin1String("[ \t]"))));
// If reboot bypass initialize functions so no keys selected in modify task
if (reboot == false) {
if (!reboot) {
//logDebug() << "Line : " << tokStr;
minute.initialize(tokStr.mid(0, spacePos));
......@@ -167,14 +167,14 @@ QString CTTask::exportTask()
exportTask += CTHelper::exportComment(comment);
if (enabled == false) {
if (!enabled) {
exportTask += QLatin1String("#\\");
}
exportTask += schedulingCronFormat();
exportTask += QLatin1String("\t");
if (isSystemCrontab() == true) {
if (isSystemCrontab()) {
exportTask += userLogin + QLatin1String("\t");
}
......@@ -319,7 +319,7 @@ QString CTTask::describeDateAndHours() const
for (int h = 0; h <= 23; h++) {
if (hour.isEnabled(h)) {
for (int m = 0; m <= 59; m++) {
if (minute.isEnabled(m) == true) {
if (minute.isEnabled(m)) {
QString hourString;
if (h < 10) {
hourString = QLatin1String("0") + QString::number(h);
......@@ -435,7 +435,7 @@ QString CTTask::decryptBinaryCommand(const QString &command) const
}
}
if (found == false) {
if (!found) {
fullCommand = command;
}
......@@ -450,7 +450,7 @@ QStringList CTTask::separatePathCommand(const QString &command, bool quoted) con
if (command.at(0) == QLatin1Char('/')) {
QString fullCommand;
if (quoted == true) {
if (quoted) {
fullCommand = command;
} else {
fullCommand = decryptBinaryCommand(command);
......@@ -466,7 +466,7 @@ QStringList CTTask::separatePathCommand(const QString &command, bool quoted) con
pathCommand << path << commandBinary;
} else {
QString fullCommand;
if (quoted == true) {
if (quoted) {
fullCommand = command;
} else {
fullCommand = decryptBinaryCommand(command);
......
......@@ -208,7 +208,7 @@ bool CTUnit::isEnabled(int pos) const
bool CTUnit::isAllEnabled() const
{
for (int i = mMin; i <= mMax; i++) {
if (mEnabled.at(i) == false) {
if (!mEnabled.at(i)) {
return false;
}
}
......
......@@ -78,11 +78,9 @@ CTVariable &CTVariable::operator =(const CTVariable &source)
QString CTVariable::exportVariable()
{
QString exportVariable;
QString exportVariable = CTHelper::exportComment(comment);
exportVariable += CTHelper::exportComment(comment);
if (enabled == false) {
if (!enabled) {
exportVariable += QLatin1String("#\\");
}
......
......@@ -88,7 +88,7 @@ void KCMCron::save()
logDebug() << "Saving crontab...";
CTSaveStatus saveStatus = mCtHost->save();
if (saveStatus.isError() == true) {
if (saveStatus.isError()) {
KMessageBox::detailedError(this, saveStatus.errorMessage(), saveStatus.detailErrorMessage());
}
}
......
......@@ -348,7 +348,7 @@ bool TaskEditorDialog::canReduceMinutesGroup()
{
for (int minuteIndex = 0; minuteIndex <= minuteTotal; ++minuteIndex) {
if (minuteIndex % reducedMinuteStep != 0) {
if (mMinuteButtons[minuteIndex]->isChecked() == true) {
if (mMinuteButtons[minuteIndex]->isChecked()) {
return false;
}
}
......@@ -483,7 +483,7 @@ void TaskEditorDialog::createMinutesGroup(QWidget *main)
//First mandatory increase
increaseMinutesGroup();
if (canReduceMinutesGroup() == true) {
if (canReduceMinutesGroup()) {
reduceMinutesGroup();
}
......@@ -775,7 +775,7 @@ void TaskEditorDialog::slotWizard()
}
bool validCommand = checkCommand();
if (validCommand == false) {
if (!validCommand) {
return;
}
......
......@@ -119,7 +119,7 @@ void VariablesWidget::deleteSelection()
bool VariablesWidget::needUserColumn()
{
CTCron *currentCron = crontabWidget()->currentCron();
if (currentCron->isMultiUserCron() == true && currentCron->isSystemCron() == false) {
if (currentCron->isMultiUserCron() && !currentCron->isSystemCron()) {
return true;
}
......@@ -128,7 +128,7 @@ bool VariablesWidget::needUserColumn()
int VariablesWidget::statusColumnIndex()
{
if (needUserColumn() == true) {
if (needUserColumn()) {
return 3;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment