diff --git a/.github/workflows/static-code-analysis.yml b/.github/workflows/static-code-analysis.yml new file mode 100644 index 0000000..1632e3d --- /dev/null +++ b/.github/workflows/static-code-analysis.yml @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: BSD-2-Clause +# +# SPDX-FileCopyrightText: 2023 Kai Uwe Broulik + +name: Static Code Analysis + +on: ["push", "pull_request"] + +jobs: + static-code-analysis: + strategy: + matrix: + config: + - {name: "Ubuntu 22.04 (Clang)", os: "ubuntu-22.04", CC: "clang", CXX: "clang++"} + + name: ${{matrix.config.name}} + runs-on: ${{matrix.config.os}} + + steps: + - name: Install dependencies + env: + DEBIAN_FRONTEND: "noninteractive" + run: sudo apt-get update && sudo apt-get install -y build-essential cmake clazy clang-tidy qtbase5-dev qtdeclarative5-dev qtquickcontrols2-5-dev extra-cmake-modules libkf5coreaddons-dev libkf5declarative-dev libkf5sysguard-dev libsensors-dev + + - name: Checkout repository + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Export Compile Commands + env: + CC: ${{matrix.config.CC}} + CXX: ${{matrix.config.CXX}} + BUILD_DIR: "build/" + run: | + cmake -B ${BUILD_DIR} -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCLAZY_RUN=ON + + - name: Clazy + env: + BUILD_DIR: "build/" + run: | + find src/ -name '*.cpp' | xargs clazy-standalone -p ${BUILD_DIR}compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 11d0794..4228bf6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,11 @@ add_feature_info(KINFOCENTER ${BUILD_KINFOCENTER} "Plug-in for KDE's Info Center option(BUILD_EXAMPLES "Build examples" OFF) add_feature_info(BUILD_EXAMPLES ${BUILD_EXAMPLES} "Example code") +option(CLAZY_RUN "Clazy run" OFF) +if (CLAZY_RUN) + add_compile_definitions(-DCLAZY_RUN=1) +endif() + set(API_URL "https://openapi.alphaess.com/api/" CACHE STRING "Default API URL") add_feature_info(API_URL On "Default API URL is '${API_URL}'") diff --git a/src/infocenter/kcm.cpp b/src/infocenter/kcm.cpp index a039a99..6d69eb9 100644 --- a/src/infocenter/kcm.cpp +++ b/src/infocenter/kcm.cpp @@ -64,4 +64,6 @@ bool KCMAlphaCloud::presentationBuild() const #endif } +#ifndef CLAZY_RUN #include "kcm.moc" +#endif diff --git a/src/qml/qmlplugin.cpp b/src/qml/qmlplugin.cpp index 4f2d6d5..40b925f 100644 --- a/src/qml/qmlplugin.cpp +++ b/src/qml/qmlplugin.cpp @@ -208,4 +208,6 @@ void QAlphaCloudQmlPlugin::registerTypes(const char *uri) qmlRegisterUncreatableMetaObject(QAlphaCloud::staticMetaObject, uri, 1, 0, "QAlphaCloud", tr("Cannot create instances of QAlphaCloud.")); } +#ifndef CLAZY_RUN #include "qmlplugin.moc" +#endif diff --git a/src/systemstats/plugin.cpp b/src/systemstats/plugin.cpp index 7548718..ca37c5a 100644 --- a/src/systemstats/plugin.cpp +++ b/src/systemstats/plugin.cpp @@ -145,4 +145,6 @@ void SystemStatsPlugin::update() } } +#ifndef CLAZY_RUN #include "plugin.moc" +#endif