[education/rkward] /: Add clang format options, and checker

Thomas Friedrichsmeier null at kde.org
Wed Apr 30 19:31:33 BST 2025


Git commit 71d19cbbb2d012436d34bf8117f98fc98c7af1b4 by Thomas Friedrichsmeier.
Committed on 28/04/2025 at 17:16.
Pushed by tfry into branch 'master'.

Add clang format options, and checker

Build is expected to fail with this commit, as code is not yet formatted

A  +15   -0    .clang-format
M  +15   -0    .gitlab-ci.yml
M  +16   -13   CommitPolicy.txt

https://invent.kde.org/education/rkward/-/commit/71d19cbbb2d012436d34bf8117f98fc98c7af1b4

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 000000000..7cd590823
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,15 @@
+# SPDX-FileCopyrightText: None
+# SPDX-License-Identifier: CC0-1.0
+
+BasedOnStyle: LLVM
+# Leave line wrapping to the humans and/or the editor. Suggestion: No longer than 160, where reasonably avoidable
+ColumnLimit: 0
+UseTab: ForIndentation
+TabWidth: 4
+IndentWidth: 4
+AlignAfterOpenBracket: Align
+BreakStringLiterals: true
+BinPackArguments: true
+AllowAllArgumentsOnNextLine: true
+AllowShortIfStatementsOnASingleLine: AllIfsAndElse
+IndentPPDirectives: AfterHash
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3ae3f5ce0..ff7281c0e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -60,3 +60,18 @@ craft_macos_qt6_x86_64:
     - when: manual
       # we don't want the manual job to block the pipeline
       allow_failure: true
+
+clang_format:
+  stage: build
+  image: debian:stable
+  tags:
+    - Linux
+  only:
+    - merge_requests
+    - master
+  before_script:
+    - apt-get update
+    - apt-get install --yes --no-install-recommends git clang-format-14
+  script:
+    - find rkward \( -name "*.cpp" -or -name "*.h"  -or -name "*.js" \) -exec clang-format-14 -i {} \;
+    - git diff --exit-code
diff --git a/CommitPolicy.txt b/CommitPolicy.txt
index 6bdeb548f..9f4350bea 100644
--- a/CommitPolicy.txt
+++ b/CommitPolicy.txt
@@ -9,7 +9,7 @@ Library dependencies
 ====================
 
 It is important to note that RKWard makes a point of _not_ requiring the latest KDE / QT libraries. If you want to use the latest and greatest, be sure to use #ifdef's, and make a best
-effort to support features for older versions of libraries, too. Generally we aim to support the two most recent Ubunut LTS releases.
+effort to support features for older versions of libraries, too. Generally we aim to support the most recent Ubuntu LTS release (plus a reasonable transition period).
 
 Of course, with the switch to KF6, we made a clean cut, thus, currently the minimum requirements are:
 
@@ -31,26 +31,29 @@ Branches and policies
   * merge your commit to master, unless it is really specific to the release-branch (or unless you cherry-picked it from master)
 * released:
   This will be updated for each new stable release, but _only_ for each new stable release. Meant to allow tracking released versions. In general, please don't commit / push anything, here, unless you are the release manager.
-* devel/*
-  For longer, experimental, or disruptive work, consider creating a branch named "devel/feature_description". Do let us know, when the feature is merged (or discarded), and the branch can be removed.
 * work/*
-  The KDE git infrastructure special-cases branches under the prefix "work". Among other things these will allow history-rewrites, and will not produce commit notifications, i.e. the rules are much like for a personal fork.
-  If you want other people to pariticipate on the branch, please use a "devel" branch (see above), instead of a "work" branch, as this allows better collaboration.
-* kde4:
-  The latest KDE4 based development version of RKWard. There may or may not be future bugfix releases for KDE4, but no active development is expected on this branch.
+  The KDE git infrastructure special-cases branches under the prefix "work". Among other things these will allow history-rewrites (please be careful with than, esp. while collaborating with others), and will not produce commit notifications, i.e. the rules are much like for a personal fork. Use this for longer, experimental, and / or potentially disruptive work.
+* kf5:
+  The latest KF5 based development version of RKWard. There may or may not be future bugfix releases for KF5, but no active development is expected on this branch.
 
 Testing
 =======
 
-Only some of RKWard (mostly: the plugins) is currently covered by automated tests. To run these, use
-  make plugintests
-More elaborate documentation is available at https://rkward.kde.org/Automated_Plugin_Testing . Running tests is particularly important when making changes to the "plugin" and "plugins"
-subdirectories.
-
-Note that there are some false positives or unstable tests (failing in some locales, for instance). Check the diffs to find out, exactly how the test failed, or run tests before
+There are two types of autotest that you are encourage to run:
+1. bin/core_text
+These should generally succeed in all cases, and are enforced by the CI. Note that false positives can happen, occasionally, esp. due to timeouts, though.
+2. make plugintests
+More elaborate documentation on the latter is available at https://rkward.kde.org/Automated_Plugin_Testing . Running tests is particularly important when making changes to the "plugin" and "plugins"
+subdirectories. Note that there are some false positives or unstable tests (failing in some locales, for instance). Check the diffs to find out, exactly how the test failed, or run tests before
 and after your changes. If in any doubt, ask on the mailing list rkward-devel at kde.org .
 
 Review
 ======
 
 There is no strict policy on code reviews. It is never wrong to ask for review on https://invent.kde.org/education/rkward
+
+Code formatting
+===============
+
+Code formatting is enforced using clang-format, and there is a CI job to check the formatting on merge requests and on master. Code formatting is certainly not the first or most important thing we
+are going to check in a merge request, but to save yourself and us some trouble, just run ```clang-format-14 -i your_source_files.cpp``` on your code.



More information about the rkward-tracker mailing list