Skip to content

Commit

Permalink
Adds the clang-format linter (#3089)
Browse files Browse the repository at this point in the history
  • Loading branch information
daltonv authored Nov 20, 2023
1 parent 2fa9a62 commit 2d6ae24
Show file tree
Hide file tree
Showing 27 changed files with 654 additions and 16 deletions.
98 changes: 98 additions & 0 deletions .automation/generated/linter-helps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .automation/generated/linter-links-previews.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
"image": null,
"title": "ChkTeX - LaTeX semantic checker"
},
"clang-format": {
"description": "A\u0302\u00ab ClangCheck :: Contents :: Clang-Format Style Options A\u0302\u00bb.",
"image": null,
"title": "ClangFormat \u2014 Clang 18.0.0git documentation"
},
"clippy": {
"description": "A bunch of lints to catch common mistakes and improve your Rust code - rust-lang/rust-clippy",
"image": "https://avatars1.githubusercontent.com/u/5430905?s=400&v=4",
Expand Down
3 changes: 2 additions & 1 deletion .automation/generated/linter-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"checkov": "3.0.40",
"checkstyle": "10.12.5",
"chktex": "1.7.8",
"clang-format": "16.0.6",
"clippy": "0.1.74",
"clj-kondo": "2023.10.20",
"cljstyle": "0.15.0",
Expand Down Expand Up @@ -114,4 +115,4 @@
"vale": "2.29.7",
"xmllint": "21106",
"yamllint": "1.33.0"
}
}
3 changes: 2 additions & 1 deletion .automation/test/c/c_bad_01.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <iostream>

int main() {
int main()
{
std::cout << "Hello World!";
return 0;
}
3 changes: 2 additions & 1 deletion .automation/test/c/c_bad_02.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <iostream>

int main() {
int main()
{
std::cout << "Hello World!";
return 0;
}
6 changes: 3 additions & 3 deletions .automation/test/c/c_good_01.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
6 changes: 3 additions & 3 deletions .automation/test/c/c_good_02.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
6 changes: 3 additions & 3 deletions .automation/test/cpp/cpp_good_01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
6 changes: 3 additions & 3 deletions .automation/test/cpp/cpp_good_02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,7 @@
"weakref",
"webpreview",
"weirdnesses",
"Werror",
"wesh",
"whitespaces",
"windir",
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy-BETA-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ jobs:
"bash_shfmt",
"bicep_bicep_linter",
"c_cpplint",
"c_clang_format",
"clojure_clj_kondo",
"clojure_cljstyle",
"cloudformation_cfn_lint",
"coffee_coffeelint",
"copypaste_jscpd",
"cpp_cpplint",
"cpp_clang_format",
"csharp_dotnet_format",
"csharp_csharpier",
"css_stylelint",
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy-DEV-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ jobs:
"bash_shfmt",
"bicep_bicep_linter",
"c_cpplint",
"c_clang_format",
"clojure_clj_kondo",
"clojure_cljstyle",
"cloudformation_cfn_lint",
"coffee_coffeelint",
"copypaste_jscpd",
"cpp_cpplint",
"cpp_clang_format",
"csharp_dotnet_format",
"csharp_csharpier",
"css_stylelint",
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy-RELEASE-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ jobs:
"bash_shfmt",
"bicep_bicep_linter",
"c_cpplint",
"c_clang_format",
"clojure_clj_kondo",
"clojure_cljstyle",
"cloudformation_cfn_lint",
"coffee_coffeelint",
"copypaste_jscpd",
"cpp_cpplint",
"cpp_clang_format",
"csharp_dotnet_format",
"csharp_csharpier",
"css_stylelint",
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l

- Media

- New linters
- Add [clang-format](https://releases.llvm.org/16.0.0/tools/clang/docs/ClangFormat.html) c & cpp formatting linter

- Fixes

- Doc
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ RUN apk add --no-cache \
php81-simplexml \
dpkg \
py3-pyflakes \
clang16-extra-tools \
nodejs \
npm \
yarn \
Expand Down
2 changes: 2 additions & 0 deletions docs/standalone-linters.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
| BASH_SHFMT | oxsecurity/megalinter-only-bash_shfmt:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-bash_shfmt/beta) |
| BICEP_BICEP_LINTER | oxsecurity/megalinter-only-bicep_bicep_linter:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-bicep_bicep_linter/beta) |
| C_CPPLINT | oxsecurity/megalinter-only-c_cpplint:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-c_cpplint/beta) |
| C_CLANG_FORMAT | oxsecurity/megalinter-only-c_clang_format:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-c_clang_format/beta) |
| CLOJURE_CLJ_KONDO | oxsecurity/megalinter-only-clojure_clj_kondo:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-clojure_clj_kondo/beta) |
| CLOJURE_CLJSTYLE | oxsecurity/megalinter-only-clojure_cljstyle:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-clojure_cljstyle/beta) |
| CLOUDFORMATION_CFN_LINT | oxsecurity/megalinter-only-cloudformation_cfn_lint:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-cloudformation_cfn_lint/beta) |
| COFFEE_COFFEELINT | oxsecurity/megalinter-only-coffee_coffeelint:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-coffee_coffeelint/beta) |
| COPYPASTE_JSCPD | oxsecurity/megalinter-only-copypaste_jscpd:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-copypaste_jscpd/beta) |
| CPP_CPPLINT | oxsecurity/megalinter-only-cpp_cpplint:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-cpp_cpplint/beta) |
| CPP_CLANG_FORMAT | oxsecurity/megalinter-only-cpp_clang_format:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-cpp_clang_format/beta) |
| CSHARP_DOTNET_FORMAT | oxsecurity/megalinter-only-csharp_dotnet_format:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-csharp_dotnet_format/beta) |
| CSHARP_CSHARPIER | oxsecurity/megalinter-only-csharp_csharpier:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-csharp_csharpier/beta) |
| CSS_STYLELINT | oxsecurity/megalinter-only-css_stylelint:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-css_stylelint/beta) |
Expand Down
1 change: 1 addition & 0 deletions flavors/c_cpp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ RUN apk add --no-cache \
openssl \
openjdk11 \
py3-pyflakes \
clang16-extra-tools \
nodejs \
npm \
yarn \
Expand Down
2 changes: 2 additions & 0 deletions flavors/c_cpp/flavor.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
"BASH_SHELLCHECK",
"BASH_SHFMT",
"C_CPPLINT",
"C_CLANG_FORMAT",
"COPYPASTE_JSCPD",
"CPP_CPPLINT",
"CPP_CLANG_FORMAT",
"CSS_STYLELINT",
"CSS_SCSS_LINT",
"DOCKERFILE_HADOLINT",
Expand Down
Loading

0 comments on commit 2d6ae24

Please sign in to comment.