File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ BasedOnStyle : Google
2+ ColumnLimit : 160
3+ IndentWidth : 4
4+ AccessModifierOffset : -4
5+ BreakBeforeBraces : Allman
6+ SortIncludes : true
7+ AllowShortFunctionsOnASingleLine : Empty
8+ DerivePointerAlignment : false
9+ PointerAlignment : Left
Original file line number Diff line number Diff line change 1+ Checks : >
2+ bugprone-*,
3+ modernize-*,
4+ performance-*,
5+ readability-*,
6+ cppcoreguidelines-*,
7+ misc-*,
8+ -modernize-use-trailing-return-type,
9+ -readability-magic-numbers,
10+ -cppcoreguidelines-avoid-magic-numbers
11+ WarningsAsErrors : ' *'
Original file line number Diff line number Diff line change @@ -71,12 +71,35 @@ jobs:
7171 run : ./build/cpuscope_cli --version
7272
7373 lint :
74- name : Lint (Placeholder)
74+ name : Lint
7575 runs-on : ubuntu-latest
7676 steps :
7777 - uses : actions/checkout@v4
78- - name : Placeholder lint
79- run : echo "Lint checks will be added later"
78+
79+ - name : Install lint dependencies
80+ run : |
81+ sudo apt-get update
82+ sudo apt-get install -y cmake ninja-build ccache clang-format-18 clang-tidy clang-17
83+
84+ - name : Check clang-format version
85+ run : clang-format --version
86+
87+ - name : Configure compile commands
88+ run : |
89+ mkdir -p build
90+ cmake -S . -B build -G Ninja \
91+ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
92+ -DCPUSCOPE_BUILD_TESTS=ON \
93+ -DCMAKE_C_COMPILER=clang-17 \
94+ -DCMAKE_CXX_COMPILER=clang++-17 \
95+ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
96+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
97+
98+ - name : Check formatting
99+ run : scripts/check-format.sh
100+
101+ - name : Run static analysis
102+ run : scripts/lint.sh
80103
81104 sanitizer :
82105 name : Sanitizer Build
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.25)
22
33project (cpuscope VERSION 0.1.0 LANGUAGES C CXX )
44
5+ set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
6+
57if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
68 message (FATAL_ERROR "In-source builds are not allowed. Please use a separate build directory." )
79endif ()
Original file line number Diff line number Diff line change 11#include < iostream>
2- #include < vector >
2+ #include < span >
33#include < string_view>
4+ #include < vector>
45
56#include " cpuscope_lib.hpp"
67
7- int main (int argc, char * argv[])
8+ int main (int argc, char * argv[])
89{
910 std::vector<std::string_view> args;
1011 args.reserve (argc);
11- for (int i = 0 ; i < argc; ++i)
12+
13+ const std::span<char *> arguments (argv, argc);
14+ for (char * arg : arguments)
1215 {
13- args.emplace_back (argv[i] );
16+ args.emplace_back (arg );
1417 }
1518
1619 std::cout << cpuscope::format_message (args) << ' \n ' ;
Original file line number Diff line number Diff line change 44#include < span>
55#include < string>
66#include < string_view>
7- #include < vector>
87
98namespace cpuscope
109{
1110
12- inline std::string format_message (std::span<const std::string_view> args)
13- {
14- return std::format (" CPUScope CLI placeholder: {} arguments received." , args.size ());
15- }
11+ inline std::string format_message (std::span<const std::string_view> args)
12+ {
13+ return std::format (" CPUScope CLI placeholder: {} arguments received." , args.size ());
14+ }
1615
17- } // namespace cpuscope
16+ } // namespace cpuscope
Original file line number Diff line number Diff line change 55namespace cpuscope
66{
77
8- std::string get_version ()
9- {
10- return " 0.1.0" ;
11- }
8+ inline std::string get_version ()
9+ {
10+ return " 0.1.0" ;
11+ }
1212
13- } // namespace cpuscope
13+ } // namespace cpuscope
Original file line number Diff line number Diff line change 1- #include " cpuscope_lib.hpp"
1+ // Linter error: Will be resolved once the library has more functionality and is no longer a
2+ // placeholder.
3+ // #include "cpuscope_lib.hpp"
24
35namespace cpuscope
46{
57
6- // Implementation is header-only for the initial placeholder functionality.
8+ // Implementation is header-only for the initial placeholder functionality.
79
8- } // namespace cpuscope
10+ } // namespace cpuscope
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -e
3+
4+ FAILED=0
5+
6+ while IFS= read -r -d ' ' file; do
7+ if ! diff -u " $file " <( clang-format " $file " ) ; then
8+ FAILED=1
9+ fi
10+ done < <(
11+ find . \
12+ \( -path ./build -o -path ./build-\* -o -path ./.git -o -path ./scripts \) -prune \
13+ -o \( -name " *.cpp" -o -name " *.hpp" \) -print0
14+ )
15+
16+ if [ " $FAILED " -ne 0 ]; then
17+ echo " Formatting issues detected."
18+ exit 1
19+ fi
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -e
3+
4+ find . \( -name " *.cpp" -o -name " *.hpp" \) -exec clang-format -i {} +
You can’t perform that action at this time.
0 commit comments