mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-11 07:19:44 -05:00
Add ClangFormat rules
This commit is contained in:
parent
410d88bf99
commit
07bc9a7b4b
@ -30,7 +30,7 @@ BraceWrapping:
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: true
|
||||
|
7
.github/CONTRIBUTING.md
vendored
7
.github/CONTRIBUTING.md
vendored
@ -108,9 +108,12 @@ The Branch Strategy is based on [git-flow-lite](http://nvie.com/posts/a-successf
|
||||
|
||||
### Coding styleguide
|
||||
|
||||
This project follows the [Qt Coding Style](https://wiki.qt.io/Qt_Coding_Style). All submissions are expected to follow this style.
|
||||
The coding style of the project is enforced using llvm's `clang-format` formatting tool. A thorough description
|
||||
of the coding style can be found in the `.clang-format` file, but the main conventions are presented here.
|
||||
|
||||
In particular, code must stick to the following rules:
|
||||
Formatting can be performed automatically by calling `make format` from the `build/` directory.
|
||||
|
||||
Note that [formatting can be disabled on a piece of code](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code) if manual formatting is deemed more readable.
|
||||
|
||||
#### Naming convention
|
||||
`lowerCamelCase`
|
||||
|
@ -279,6 +279,8 @@ if(WITH_TESTS)
|
||||
enable_testing()
|
||||
endif(WITH_TESTS)
|
||||
|
||||
include(CLangFormat)
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
find_package(Qt5 COMPONENTS Core Network Concurrent Widgets Test LinguistTools DBus REQUIRED)
|
||||
elseif(APPLE)
|
||||
|
59
cmake/CLangFormat.cmake
Normal file
59
cmake/CLangFormat.cmake
Normal file
@ -0,0 +1,59 @@
|
||||
# Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 or (at your option)
|
||||
# version 3 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(EXCLUDED_DIRS
|
||||
# third-party directories
|
||||
zxcvbn/
|
||||
http/qhttp/
|
||||
streams/QtIOCompressor
|
||||
# objective-c directories
|
||||
autotype/mac
|
||||
)
|
||||
|
||||
set(EXCLUDED_FILES
|
||||
# third-party files
|
||||
streams/qtiocompressor.cpp
|
||||
streams/qtiocompressor.h
|
||||
gui/KMessageWidget.h
|
||||
gui/KMessageWidget.cpp
|
||||
tests/modeltest.cpp
|
||||
tests/modeltest.h
|
||||
# objective-c files
|
||||
core/ScreenLockListenerMac.h
|
||||
core/ScreenLockListenerMac.cpp
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h)
|
||||
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
|
||||
foreach (EXCLUDED_DIR ${EXCLUDED_DIRS})
|
||||
string(FIND ${SOURCE_FILE} ${EXCLUDED_DIR} SOURCE_FILE_EXCLUDED)
|
||||
if (NOT ${SOURCE_FILE_EXCLUDED} EQUAL -1)
|
||||
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
|
||||
endif ()
|
||||
endforeach ()
|
||||
foreach (EXCLUDED_FILE ${EXCLUDED_FILES})
|
||||
if (${SOURCE_FILE} MATCHES ".*${EXCLUDED_FILE}$")
|
||||
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
|
||||
endif ()
|
||||
endforeach ()
|
||||
endforeach ()
|
||||
|
||||
add_custom_target(
|
||||
format
|
||||
COMMAND clang-format
|
||||
-style=file
|
||||
-i
|
||||
${ALL_SOURCE_FILES}
|
||||
)
|
Loading…
Reference in New Issue
Block a user