Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int evaluate(int x) {
```

```diff
!Line: 9 - warning: Class 'DataProcessor' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor]
!Line: 9 - warning: Class 'DataProcessor' does not have a copy constructor which is recommended since it has dynamic memory/resource management. [noCopyConstructor]

```
<br>
Expand All @@ -74,7 +74,7 @@ int evaluate(int x) {
```

```diff
!Line: 9 - warning: Class 'DataProcessor' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq]
!Line: 9 - warning: Class 'DataProcessor' does not have a operator= which is recommended since it has dynamic memory/resource management. [noOperatorEq]

```
<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int evaluate(int x) {
```

```diff
!Line: 9 - warning: Class 'DataProcessor' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor]
!Line: 9 - warning: Class 'DataProcessor' does not have a copy constructor which is recommended since it has dynamic memory/resource management. [noCopyConstructor]

```
<br>
Expand All @@ -74,7 +74,7 @@ int evaluate(int x) {
```

```diff
!Line: 9 - warning: Class 'DataProcessor' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq]
!Line: 9 - warning: Class 'DataProcessor' does not have a operator= which is recommended since it has dynamic memory/resource management. [noOperatorEq]

```
<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L9-L14
```diff
!Line: 9 - warning: Class 'Example' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor]
!Line: 9 - warning: Class 'Example' does not have a copy constructor which is recommended since it has dynamic memory/resource management. [noCopyConstructor]

```
<br>
Expand All @@ -13,7 +13,7 @@ https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L9-L14

https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L9-L14
```diff
!Line: 9 - warning: Class 'Example' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq]
!Line: 9 - warning: Class 'Example' does not have a operator= which is recommended since it has dynamic memory/resource management. [noOperatorEq]

```
<br>
Expand Down Expand Up @@ -57,7 +57,7 @@ https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L41-L44
</details>

***
<details> <summary> <b> :red_circle: clang-tidy found 21 issues! Click here to see details. </b> </summary> <br>
<details> <summary> <b> :red_circle: clang-tidy found 24 issues! Click here to see details. </b> </summary> <br>

https://github.com/JacobDomagala/TestRepo/blob/<SHA>/another_source.cpp#L1-L3
```diff
Expand All @@ -77,6 +77,15 @@ https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L2-L7



https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L5-L10
```diff
!Line: 5 - error: class 'Example' can be moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage,-warnings-as-errors]

```
<br>



https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L5-L10
```diff
!Line: 5 - error: class 'Example' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions,hicpp-special-member-functions,-warnings-as-errors]
Expand Down Expand Up @@ -212,6 +221,15 @@ https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L33-L38



https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L36-L41
```diff
!Line: 35 - error: pointee of variable 'ptr' of type 'int *' can be declared 'const' [misc-const-correctness,-warnings-as-errors]

```
<br>



https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L36-L41
```diff
!Line: 36 - error: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl,-warnings-as-errors]
Expand All @@ -221,6 +239,15 @@ https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L36-L41



https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L39-L44
```diff
!Line: 39 - error: possibly unsafe 'operator[]', consider bounds-safe alternatives [cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,-warnings-as-errors]

```
<br>



https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L39-L44
```diff
!Line: 39 - error: 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,-warnings-as-errors]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L9-L14
```diff
!Line: 9 - warning: Class 'Example' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor]
!Line: 9 - warning: Class 'Example' does not have a copy constructor which is recommended since it has dynamic memory/resource management. [noCopyConstructor]

```
<br>
Expand All @@ -13,7 +13,7 @@ https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L9-L14

https://github.com/JacobDomagala/TestRepo/blob/<SHA>/source.cpp#L9-L14
```diff
!Line: 9 - warning: Class 'Example' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq]
!Line: 9 - warning: Class 'Example' does not have a operator= which is recommended since it has dynamic memory/resource management. [noOperatorEq]

```
<br>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##[error] Issues found!
cppcheck results:
/github/workspace/source.cpp:9: warning: Class 'Example' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor]
/github/workspace/source.cpp:9: warning: Class 'Example' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq]
/github/workspace/source.cpp:9: warning: Class 'Example' does not have a copy constructor which is recommended since it has dynamic memory/resource management. [noCopyConstructor]
/github/workspace/source.cpp:9: warning: Class 'Example' does not have a operator= which is recommended since it has dynamic memory/resource management. [noOperatorEq]
/github/workspace/source.cpp:36: error: Null pointer dereference: ptr [nullPointer]
/github/workspace/source.cpp:35: note: Assignment 'ptr=nullptr', assigned value is 0
/github/workspace/source.cpp:36: note: Null pointer dereference
Expand All @@ -11,6 +11,7 @@ cppcheck results:
clang-tidy results:
/github/workspace/another_source.cpp:1: error: function 'do_nothing' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage,-warnings-as-errors]
/github/workspace/source.cpp:2: error: included header string is not used directly [misc-include-cleaner,-warnings-as-errors]
/github/workspace/source.cpp:5: error: class 'Example' can be moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage,-warnings-as-errors]
/github/workspace/source.cpp:5: error: class 'Example' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions,hicpp-special-member-functions,-warnings-as-errors]
/github/workspace/source.cpp:9: error: 42 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,-warnings-as-errors]
/github/workspace/source.cpp:11: error: parameter name 'p' is too short, expected at least 3 characters [readability-identifier-length,-warnings-as-errors]
Expand All @@ -26,7 +27,9 @@ clang-tidy results:
/github/workspace/source.cpp:32: error: variable 'y' of type 'int' can be declared 'const' [misc-const-correctness,-warnings-as-errors]
/github/workspace/source.cpp:32: error: variable name 'y' is too short, expected at least 3 characters [readability-identifier-length,-warnings-as-errors]
/github/workspace/source.cpp:33: error: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl,-warnings-as-errors]
/github/workspace/source.cpp:35: error: pointee of variable 'ptr' of type 'int *' can be declared 'const' [misc-const-correctness,-warnings-as-errors]
/github/workspace/source.cpp:36: error: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl,-warnings-as-errors]
/github/workspace/source.cpp:39: error: possibly unsafe 'operator[]', consider bounds-safe alternatives [cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,-warnings-as-errors]
/github/workspace/source.cpp:39: error: 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,-warnings-as-errors]
/github/workspace/source.cpp:39: error: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl,-warnings-as-errors]
/github/workspace/source.cpp:41: error: variable 'unusedvec' of type 'std::vector<int>' can be declared 'const' [misc-const-correctness,-warnings-as-errors]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##[error] Issues found!
cppcheck results:
/github/workspace/source.cpp:9: warning: Class 'Example' does not have a copy constructor which is recommended since it has dynamic memory/resource allocation(s). [noCopyConstructor]
/github/workspace/source.cpp:9: warning: Class 'Example' does not have a operator= which is recommended since it has dynamic memory/resource allocation(s). [noOperatorEq]
/github/workspace/source.cpp:9: warning: Class 'Example' does not have a copy constructor which is recommended since it has dynamic memory/resource management. [noCopyConstructor]
/github/workspace/source.cpp:9: warning: Class 'Example' does not have a operator= which is recommended since it has dynamic memory/resource management. [noOperatorEq]
/github/workspace/source.cpp:36: error: Null pointer dereference: ptr [nullPointer]
/github/workspace/source.cpp:35: note: Assignment 'ptr=nullptr', assigned value is 0
/github/workspace/source.cpp:36: note: Null pointer dereference
Expand All @@ -11,6 +11,7 @@ cppcheck results:
clang-tidy results:
/github/workspace/another_source.cpp:1: error: function 'do_nothing' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage,-warnings-as-errors]
/github/workspace/source.cpp:2: error: included header string is not used directly [misc-include-cleaner,-warnings-as-errors]
/github/workspace/source.cpp:5: error: class 'Example' can be moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage,-warnings-as-errors]
/github/workspace/source.cpp:5: error: class 'Example' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions,hicpp-special-member-functions,-warnings-as-errors]
/github/workspace/source.cpp:9: error: 42 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,-warnings-as-errors]
/github/workspace/source.cpp:11: error: parameter name 'p' is too short, expected at least 3 characters [readability-identifier-length,-warnings-as-errors]
Expand All @@ -26,7 +27,9 @@ clang-tidy results:
/github/workspace/source.cpp:32: error: variable 'y' of type 'int' can be declared 'const' [misc-const-correctness,-warnings-as-errors]
/github/workspace/source.cpp:32: error: variable name 'y' is too short, expected at least 3 characters [readability-identifier-length,-warnings-as-errors]
/github/workspace/source.cpp:33: error: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl,-warnings-as-errors]
/github/workspace/source.cpp:35: error: pointee of variable 'ptr' of type 'int *' can be declared 'const' [misc-const-correctness,-warnings-as-errors]
/github/workspace/source.cpp:36: error: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl,-warnings-as-errors]
/github/workspace/source.cpp:39: error: possibly unsafe 'operator[]', consider bounds-safe alternatives [cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,-warnings-as-errors]
/github/workspace/source.cpp:39: error: 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers,-warnings-as-errors]
/github/workspace/source.cpp:39: error: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl,-warnings-as-errors]
/github/workspace/source.cpp:41: error: variable 'unusedvec' of type 'std::vector<int>' can be declared 'const' [misc-const-correctness,-warnings-as-errors]
32 changes: 28 additions & 4 deletions .github/workflows/build_static_analysis_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,39 @@ jobs:
- name: Print image size
run: |
set -euo pipefail
size_bytes="$(docker image inspect static-analysis-base:ci --format '{{.Size}}')"
size_human="$(numfmt --to=iec-i --suffix=B "$size_bytes")"

echo "static-analysis-base:ci size: ${size_human} (${size_bytes} bytes)"
human_size() {
numfmt --to=iec-i --suffix=B "$1"
}

compressed_size() {
local image="$1"
docker save "$image" | gzip -c | wc -c | tr -d ' '
}

ci_image="static-analysis-base:ci"
latest_image="${DOCKERHUB_IMAGE}:latest"

docker pull "$latest_image" >/dev/null

latest_uncompressed_bytes="$(docker image inspect "$latest_image" --format '{{.Size}}')"
latest_compressed_bytes="$(compressed_size "$latest_image")"
ci_uncompressed_bytes="$(docker image inspect "$ci_image" --format '{{.Size}}')"
ci_compressed_bytes="$(compressed_size "$ci_image")"

printf "%-34s %14s %14s\n" "Image" "Uncompressed" "Compressed"
printf "%-34s %14s %14s\n" "$latest_image" "$(human_size "$latest_uncompressed_bytes")" "$(human_size "$latest_compressed_bytes")"
printf "%-34s %14s %14s\n" "$ci_image" "$(human_size "$ci_uncompressed_bytes")" "$(human_size "$ci_compressed_bytes")"

{
echo "### Docker Image Size"
echo
echo "- \`static-analysis-base:ci\`: ${size_human} (${size_bytes} bytes)"
echo "| Image | Uncompressed | Compressed |"
echo "| --- | ---: | ---: |"
echo "| Current Docker Hub latest | $(human_size "$latest_uncompressed_bytes") | $(human_size "$latest_compressed_bytes") |"
echo "| New build | $(human_size "$ci_uncompressed_bytes") | $(human_size "$ci_compressed_bytes") |"
echo
echo "<sub>Compressed size is measured with \`docker save | gzip\`.</sub>"
} >> "$GITHUB_STEP_SUMMARY"

- name: Build action image
Expand Down
14 changes: 9 additions & 5 deletions docker/static_analysis.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:24.04 AS cppcheck-builder

ARG CPPCHECK_VERSION=2.16.0
ARG CPPCHECK_VERSION=2.20.0
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
Expand Down Expand Up @@ -44,7 +44,7 @@ RUN apt-get update \

FROM ubuntu:24.04 AS llvm-repo

ARG CLANG_VERSION=20
ARG CLANG_VERSION=23
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
Expand All @@ -53,13 +53,13 @@ RUN apt-get update \
gnupg \
wget \
&& wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /llvm.gpg \
&& printf "deb [signed-by=/usr/share/keyrings/llvm.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble-%s main\n" "${CLANG_VERSION}" > /llvm.list \
&& printf "deb [signed-by=/usr/share/keyrings/llvm.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble main\n" > /llvm.list \
&& rm -rf /var/lib/apt/lists/*


FROM ubuntu:24.04 AS base

ARG CLANG_VERSION=20
ARG CLANG_VERSION=23
ENV DEBIAN_FRONTEND=noninteractive \
CLANG_VERSION=${CLANG_VERSION} \
CC=clang \
Expand All @@ -69,12 +69,16 @@ ENV DEBIAN_FRONTEND=noninteractive \

COPY --from=python-tools-builder /opt/python-tools /opt/python-tools
COPY --from=cppcheck-builder /opt/cppcheck /opt/cppcheck

RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*

COPY --from=llvm-repo /llvm.gpg /usr/share/keyrings/llvm.gpg
COPY --from=llvm-repo /llvm.list /etc/apt/sources.list.d/llvm.list

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
cmake \
git \
make \
Expand Down
2 changes: 1 addition & 1 deletion entrypoint_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ common_ancestor=${common_ancestor:-""}

CLANG_TIDY_ARGS="${INPUT_CLANG_TIDY_ARGS//$'\n'/}"
CPPCHECK_ARGS="${INPUT_CPPCHECK_ARGS//$'\n'/}"
RUN_CLANG_TIDY_BIN="${RUN_CLANG_TIDY_BIN:-$(command -v run-clang-tidy || command -v "run-clang-tidy-${CLANG_VERSION:-20}" || compgen -c | grep '^run-clang-tidy-[0-9]\+$' | head -n 1 || true)}"
RUN_CLANG_TIDY_BIN="${RUN_CLANG_TIDY_BIN:-$(command -v run-clang-tidy || command -v "run-clang-tidy-${CLANG_VERSION:-23}" || compgen -c | grep '^run-clang-tidy-[0-9]\+$' | head -n 1 || true)}"

if [ -z "$RUN_CLANG_TIDY_BIN" ]; then
debug_print "Error: run-clang-tidy executable not found in PATH."
Expand Down
Loading