From 65c8c4a7de2e210b6cc085b8e79252f7218cf798 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Fri, 21 Jul 2023 14:00:05 -0700 Subject: [PATCH] misc: add cpplint (#2430) --- .clang-format | 158 ++++++++++++++++++++++++++++++++++ .vscode/c_cpp_properties.json | 15 +++- .vscode/settings.json | 22 ++++- CPPLINT.cfg | 35 ++++++++ 4 files changed, 226 insertions(+), 4 deletions(-) create mode 100644 .clang-format create mode 100644 CPPLINT.cfg diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..0256e313a --- /dev/null +++ b/.clang-format @@ -0,0 +1,158 @@ +# Generated by running clang-format -style=Google -dump-config > .clang-format, with a few Unfolded modifications at the bottom +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html +--- +# Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 2 + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + CanonicalDelimiter: '' + BasedOnStyle: google +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Auto +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseTab: Never +# Unfolded +ColumnLimit: 120 +... diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 2ed9ddecf..55cf3823a 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -2,8 +2,19 @@ "configurations": [ { "name": "Mac", - "includePath": ["${workspaceFolder}/**", "/usr/local/opt"], - "defines": [], + "includePath": [ + "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include", + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/include", + "${workspaceFolder}/**", + "/usr/local/include", + "/usr/local/opt/boost/include", + "/usr/local/opt/gdal/include", + "/usr/local/opt/boost/include", + "${workspaceFolder}/BuildTools/macosx/libraries/include", + "${workspaceFolder}/BuildTools/macosx/libraries/include/wx-3.2", + "${workspaceFolder}/BuildTools/macosx/libraries/lib/wx/include/osx_cocoa-unicode-3.2" + ], + "defines": ["__WXMAC__"], "macFrameworkPath": [ "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" ], diff --git a/.vscode/settings.json b/.vscode/settings.json index cad7657df..8c7e9339f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,21 @@ { - "cmake.configureOnOpen": false -} \ No newline at end of file + "[cpp]": { + "editor.rulers": [120, 120] + }, + "cmake.configureOnOpen": false, + "editor.formatOnSave": true, // Tell VSCode to format files on save + "clang-format.executable": "/opt/homebrew/bin/clang-format", + "cpplint.cpplintPath": "/opt/homebrew/bin/cpplint", + "C_Cpp.default.systemIncludePath": [ + "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include", + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/include", + "/usr/local/include", + "/usr/local/opt/boost/include", + "${workspaceFolder}/BuildTools/macosx/libraries/include", + "${workspaceFolder}/BuildTools/macosx/libraries/include/wx-3.2", + "${workspaceFolder}/BuildTools/macosx/libraries/lib/wx/include/osx_cocoa-unicode-3.2" + ], + "C_Cpp.default.cStandard": "c11", + "C_Cpp.default.cppStandard": "c++17", + "C_Cpp.default.cpplint.filters": "CPPLINT.cfg" +} diff --git a/CPPLINT.cfg b/CPPLINT.cfg new file mode 100644 index 000000000..301b5581f --- /dev/null +++ b/CPPLINT.cfg @@ -0,0 +1,35 @@ +# Copyright (c) 2020 Unfolded, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# Coding style and rule exceptions are documented at +# https://github.com/UnfoldedInc/deck.gl-native/tree/master/docs/dev/coding-style.md + +# Stop searching for additional config files. +set noparent + +linelength=120 + +# To disable a rule: +filter=-build/header_guard,-build/namespaces,-runtime/references + +# To enable a rule: +#filter=+[RULE] + +# For a list of rules run cpplint --filter=