Skip to content
Open
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
Language: Cpp
BasedOnStyle: WebKit
BasedOnStyle: WebKit
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,4 @@ CheckOptions:
value: '1'
- key: readability-uppercase-literal-suffix.NewSuffixes
value: ''
...
26 changes: 22 additions & 4 deletions .github/workflows/cpp-lint-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ name: cpp-linter as action
on:
workflow_dispatch:
workflow_call:
# pull_request:


jobs:
test:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
clang-version: ['11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22']
clang-version: ['12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22']
fail-fast: false

runs-on: ${{ matrix.os }}
Expand All @@ -33,13 +34,20 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: >-
apt-get update &&
apt-get install -y libc6 cmake gcc g++ wget lsb-release
apt-get install -y
libc6
cmake
gcc
g++
wget
software-properties-common
lsb-release
- name: Generate compilation database
if: steps.cache-build.outputs.cache-hit != 'true'
run: mkdir build && cmake -Bbuild src
run: mkdir build && cmake -B build -S src

- name: Run linter as action
uses: cpp-linter/cpp-linter-action@main
uses: cpp-linter/cpp-linter-action@v3.0.0-rc0
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -54,6 +62,7 @@ jobs:
thread-comments: ${{ matrix.clang-version == '17' && 'update' }}
file-annotations: ${{ matrix.clang-version == '17' }}
extra-args: -std=c++14 -Wall
step-summary: true

- name: Fail fast?!
# if: steps.linter.outputs.checks-failed > 0
Expand All @@ -64,3 +73,12 @@ jobs:
echo "clang-tidy: ${{ steps.linter.outputs.clang-tidy-checks-failed }}"
# for actual deployment
# run: exit 1

- name: Apply patch
if: steps.linter.outputs.fix-patch-path != ''
shell: bash
env:
PATCH_PATH: ${{ steps.linter.outputs.fix-patch-path }}
run: |-
echo "applying patch"
git apply ${PATCH_PATH}
32 changes: 24 additions & 8 deletions .github/workflows/cpp-lint-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ on:
description: 'which branch to test'
default: 'main'
required: true
pull_request:

jobs:
cpp-linter:
runs-on: windows-latest

strategy:
matrix:
clang-version: ['11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22']
repo: ['cpp-linter/cpp-linter']
clang-version: ['12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22']
repo: ['cpp-linter/cpp-linter-rs']
branch: ['${{ inputs.branch }}']
fail-fast: false

Expand All @@ -31,10 +32,14 @@ jobs:
python-version: 3.x

- name: Install workflow deps
run: python -m pip install clang-tools git+https://github.com/${{ matrix.repo }}/@${{ matrix.branch }}
# run: python -m pip install clang-tools git+https://github.com/${{ matrix.repo }}/@${{ matrix.branch }}
# python -m pip install clang-tools
# python -m pip install git+https://github.com/${{ matrix.repo }}.git@${{ matrix.branch }}
run: |
python -m pip install -i https://test.pypi.org/simple/ cpp-linter==2.0.0rc22

- name: Install clang-tools
run: clang-tools --install ${{ matrix.clang-version }} --directory ${{ runner.temp }}/llvm
# - name: Install clang-tools
# run: clang-tools --install ${{ matrix.clang-version }} --directory ${{ runner.temp }}/llvm

- name: Setup VS dev env
uses: TheMrMilchmann/setup-msvc-dev@v4
Expand All @@ -50,23 +55,26 @@ jobs:

- name: Generate compiler database
if: steps.cache-build.outputs.cache-hit != 'true'
run: mkdir build && cmake -Bbuild src -G "NMake Makefiles"
run: mkdir build && cmake -B build -S src -G "NMake Makefiles"

- name: Run linter as package
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CPP_LINTER_COLOR: true
run: >
cpp-linter
-s=file
-v=debug
-i=build
-p=build
-V=${{ runner.temp }}/llvm
-f=false
-V=${{ matrix.clang-version }}
-l=false
--step-summary=true
--extra-arg="-std=c++14 -Wall"
--thread-comments=${{ matrix.clang-version == '17' && 'update' }}
-a=${{ matrix.clang-version == '17' }}
--pr-review=${{ matrix.clang-version == '17' }}

- name: Fail fast?!
if: steps.linter.outputs.checks-failed > 0
Expand All @@ -77,3 +85,11 @@ jobs:
echo "clang-tidy: ${{ steps.linter.outputs.clang-tidy-checks-failed }}"
# for actual deployment
# run: exit 1

- name: Apply patch
if: steps.linter.outputs.fix-patch-path != ''
env:
PATCH_PATH: ${{ steps.linter.outputs.fix-patch-path }}
run: |-
echo "applying patch"
git apply $env:PATCH_PATH
21 changes: 11 additions & 10 deletions src/demo.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/** This is a very ugly test code (doomed to fail linting) */
#include "demo.hpp"
Comment thread
github-actions[bot] marked this conversation as resolved.
#include <cstdio>
#include <cstddef>
#include <stdio.h>
Comment thread
github-actions[bot] marked this conversation as resolved.
Comment on lines 2 to +3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic(s)

Suggested change
#include "demo.hpp"
#include <cstdio>
#include <cstddef>
#include <stdio.h>
#include <cstdio>


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy suggestion

Suggested change
auto main() -> int
{

// using size_t from cstddef
size_t dummyFunc(size_t i) { return i; }

int main()
{
for (;;)
break;


int main(){

for (;;) break;
Comment thread
github-actions[bot] marked this conversation as resolved.

Comment on lines +6 to +11

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic(s)

Suggested change
int main(){
for (;;) break;
for (;;) {
break;
}


printf("Hello world!\n");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

src/demo.cpp:13:5 warning: [cppcoreguidelines-pro-type-vararg]

do not call c-style vararg functions

   13 |     printf("Hello world!\n");
      |     ^


return 0;
}



Comment thread
github-actions[bot] marked this conversation as resolved.
return 0;}
Comment on lines +15 to +18

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy suggestion

Suggested change
return 0;}
return 0;
}

11 changes: 3 additions & 8 deletions src/demo.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once


Expand All @@ -5,12 +5,10 @@
class Dummy {
char* useless;
int numb;
Comment thread
github-actions[bot] marked this conversation as resolved.
Dummy() :numb(0), useless("\0"){}
Comment on lines 6 to +8

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic(s)

Suggested change
char* useless;
int numb;
Dummy() :numb(0), useless("\0"){}
char* useless { "\0" };
int numb { 0 };
Dummy() { }


public:
Comment thread
github-actions[bot] marked this conversation as resolved.
void *not_usefull(char *str){
useless = str;
return 0;
}
void *not_useful(char *str){useless = str;}
Comment on lines 10 to +11

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic(s)

Suggested change
public:
void *not_usefull(char *str){
useless = str;
return 0;
}
void *not_useful(char *str){useless = str;}
public:
auto not_useful(char* str) -> void* { useless = str; }

};


Expand All @@ -28,14 +26,11 @@









struct LongDiff
{

long diff;
Comment thread
github-actions[bot] marked this conversation as resolved.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy suggestion

Please remove the line(s)

  • 35

};