From 9a47dd4133da7d5e5f036e638c2640e3965d3319 Mon Sep 17 00:00:00 2001 From: program-- Date: Wed, 10 Jan 2024 09:38:25 -0800 Subject: [PATCH 1/2] feat: add .clang-* files; update .gitignore to ignore compilation db json --- .clang-format | 45 +++++++++++++++++++++++++++++++++++++++++++++ .clang-tidy | 32 ++++++++++++++++++++++++++++++++ .gitignore | 1 + 3 files changed, 78 insertions(+) create mode 100644 .clang-format create mode 100644 .clang-tidy diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..04afd5c62f --- /dev/null +++ b/.clang-format @@ -0,0 +1,45 @@ +# yaml-language-server: $schema=https://json.schemastore.org/clang-format.json +--- +BasedOnStyle: Google +ColumnLimit: 100 +IndentWidth: 4 +UseTab: Never +--- +Language: Cpp +AlignAfterOpenBracket: BlockIndent +AlignArrayOfStructures: Left +AlignConsecutiveAssignments: Consecutive +AlignConsecutiveBitFields: Consecutive +AlignConsecutiveDeclarations: + Enabled: false +AlignConsecutiveMacros: Consecutive +AlignConsecutiveShortCaseStatements: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCaseColons: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: + Kind: Never +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Empty +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +BitFieldColonSpacing: Both +BreakBeforeBraces: Attach # One True Brace Style +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeComma +BreakInheritanceList: BeforeComma +Cpp11BracedListStyle: true +DerivePointerAlignment: true +FixNamespaceComments: true +NamespaceIndentation: None +SeparateDefinitionBlocks: Always +--- diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..44554721a5 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,32 @@ +--- +Checks: | + clang-diagnostic-*, + clang-analyzer-*, + cppcoreguidelines-*, + modernize-*, + mpi-*, + bugprone-*, + boost-*, + performance-*, + hicpp-*, + google-*, + readability-*, + misc-confusable-identifiers, + misc-const-correctness, + -modernize-use-trailing-return-type, + -cppcoreguidelines-special-member-functions +AnalyzeTemporaryDtors: false +FormatStyle: file +CheckOptions: + - key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic + value: "1" + - key: modernize-loop-convert.MaxCopySize + value: "16" + - key: modernize-loop-convert.MinConfidence + value: reasonable + - key: modernize-pass-by-value.IncludeStyle + value: google + - key: modernize-use-nullptr.NullMacros + value: "NULL" +--- + diff --git a/.gitignore b/.gitignore index 20ffa96238..ef10bce154 100644 --- a/.gitignore +++ b/.gitignore @@ -98,6 +98,7 @@ CMakeCache.txt /cmake_build /build /cmake_build* +compile_commands.json # Prevent ignoring cmake modules !cmake/**/*.cmake From 891335a23482fa039fce00713afb543cb1566985 Mon Sep 17 00:00:00 2001 From: "Justin Singh-M. - NOAA" Date: Wed, 10 Jan 2024 10:13:12 -0800 Subject: [PATCH 2/2] clang-format: use LLVM style instead of google; prevent short ifs on single line [no ci] --- .clang-format | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.clang-format b/.clang-format index 04afd5c62f..291bec3d6a 100644 --- a/.clang-format +++ b/.clang-format @@ -1,6 +1,6 @@ # yaml-language-server: $schema=https://json.schemastore.org/clang-format.json --- -BasedOnStyle: Google +BasedOnStyle: LLVM ColumnLimit: 100 IndentWidth: 4 UseTab: Never @@ -26,7 +26,6 @@ AllowAllArgumentsOnNextLine: false AllowAllParametersOfDeclarationOnNextLine: false AllowShortBlocksOnASingleLine: Empty AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: WithoutElse AllowShortLambdasOnASingleLine: All AllowShortLoopsOnASingleLine: true AlwaysBreakTemplateDeclarations: Yes