use single-line conditional statement (#1383)

This commit is contained in:
Itay Cohen 2019-03-24 10:41:49 +02:00 committed by GitHub
parent 5da91b0a05
commit 85f5494c93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,9 +3,6 @@ Contributing
This page shows some hints about the coding conventions.
*Disclaimer: It is a work in progress and we will provide soon a fully
documented API.*
Coding advices
--------------
@ -62,7 +59,7 @@ General coding guidelines
Coding style
~~~~~~~~~~~~
We follow `these guidelines <https://wiki.qt.io/Qt_Coding_Style>`__ to
In general, we follow `the official Qt guidelines <https://wiki.qt.io/Qt_Coding_Style>`__ to
format the code. If in doubt, you can use `AStyle
2.06 <https://sourceforge.net/projects/astyle/files/astyle/astyle%202.06/>`__
to format the code. The command line for formatting the code according
@ -72,6 +69,28 @@ to the style is:
astyle --project=src/Cutter.astylerc src/filename.cpp
In contrast to the official guidelines of Qt, in Cutter we always use curly braces in conditional statements, even if the body of a conditional statement contains only one line.
.. code:: cpp
// Wrong
if (address.isEmpty())
return false;
// Correct
if (address.isEmpty()) {
return false;
}
// Wrong
for (int i = 0; i < 10; ++i)
qDebug("%i", i);
// Correct
for (int i = 0; i < 10; ++i) {
qDebug("%i", i);
}
Includes
^^^^^^^^