基础 - 图1

    1. {
    2. // Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and
    3. // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
    4. // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
    5. // same ids are connected.
    6. // Example:
    7. "copyright info":{
    8. "prefix": "//file",
    9. "body": [
    10. "//------------------------------------------------------------------------------",
    11. "//! Copyright(C) 2020-2022, netflt.com",
    12. "//! All rights reserved.",
    13. "// ",
    14. "// name: $TM_FILENAME",
    15. "// author: Danny.Zhu"
    16. "// date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
    17. "//------------------------------------------------------------------------------"
    18. ],
    19. "description": "add copyright information"
    20. },
    21. "simple comment":{
    22. "prefix": "//",
    23. "body": [
    24. "//<! ${1}"
    25. ],
    26. "description": "add simple common"
    27. },
    28. "block comment":{
    29. "prefix": "///",
    30. "body": [
    31. "/***",
    32. "//<! ${1}",
    33. "***/"
    34. ],
    35. "description": "add block common"
    36. },
    37. "TODO": {
    38. "prefix": "//td",
    39. "body": [
    40. "//<! TODO (Danny.Zhu): $1"
    41. ],
    42. "description": "Log output to console"
    43. }
    44. }

    .clang-format

    1. ---
    2. Language: Cpp
    3. # BasedOnStyle: Chromium
    4. SortIncludes: true
    5. AccessModifierOffset: -4
    6. DerivePointerAlignment: false
    7. PointerAlignment: Left
    8. ConstructorInitializerIndentWidth: 4
    9. AlignEscapedNewlines: Left
    10. AlignAfterOpenBracket: Align
    11. AlignConsecutiveMacros: Consecutive
    12. AlignConsecutiveAssignments: None
    13. AlignConsecutiveBitFields: Consecutive
    14. AlignConsecutiveDeclarations: false
    15. AlignOperands: Align
    16. AlignTrailingComments: true
    17. AllowShortBlocksOnASingleLine: Never
    18. AllowShortFunctionsOnASingleLine: Empty
    19. AllowAllArgumentsOnNextLine: true
    20. AllowAllConstructorInitializersOnNextLine: false
    21. AllowAllParametersOfDeclarationOnNextLine: false
    22. AllowShortEnumsOnASingleLine: false
    23. AllowShortLambdasOnASingleLine: Empty
    24. AllowShortIfStatementsOnASingleLine: Never
    25. AllowShortCaseLabelsOnASingleLine: false
    26. AllowShortLoopsOnASingleLine: false
    27. AlwaysBreakTemplateDeclarations: true
    28. BinPackArguments: false
    29. AlwaysBreakBeforeMultilineStrings: false
    30. BreakBeforeBinaryOperators: NonAssignment
    31. BreakBeforeTernaryOperators: true
    32. BreakConstructorInitializersBeforeComma: false
    33. BinPackParameters: false
    34. ColumnLimit: 96
    35. ConstructorInitializerAllOnOneLineOrOnePerLine: false
    36. DerivePointerBinding: false
    37. ExperimentalAutoDetectBinPacking: false
    38. IndentCaseLabels: false
    39. MaxEmptyLinesToKeep: 1
    40. NamespaceIndentation: None
    41. ObjCSpaceBeforeProtocolList: true
    42. PenaltyBreakBeforeFirstCallParameter: 1
    43. PenaltyBreakComment: 300
    44. PenaltyBreakString: 1000
    45. PenaltyBreakFirstLessLess: 120
    46. PenaltyExcessCharacter: 1000000
    47. PenaltyReturnTypeOnItsOwnLine: 1000
    48. AlwaysBreakAfterDefinitionReturnType: None
    49. AlwaysBreakAfterReturnType: None
    50. PointerBindsToType: true
    51. Cpp11BracedListStyle: false
    52. Standard: Auto
    53. IndentWidth: 4
    54. TabWidth: 4
    55. UseTab: Never
    56. BreakBeforeBraces: Custom
    57. AttributeMacros:
    58. - __capability
    59. BraceWrapping:
    60. AfterCaseLabel: false
    61. AfterClass: true
    62. AfterControlStatement: false
    63. AfterEnum: false
    64. AfterFunction: true
    65. AfterNamespace: true
    66. AfterObjCDeclaration: true
    67. AfterStruct: false
    68. AfterUnion: false
    69. AfterExternBlock: true
    70. BeforeCatch: true
    71. BeforeElse: true
    72. BeforeLambdaBody: false
    73. BeforeWhile: false
    74. IndentBraces: false
    75. SplitEmptyFunction: false
    76. SplitEmptyRecord: false
    77. SplitEmptyNamespace: false
    78. SpacesInParentheses: false
    79. SpacesInAngles: false
    80. BreakBeforeConceptDeclarations: true
    81. BreakBeforeInheritanceComma: false
    82. BreakInheritanceList: BeforeComma
    83. BreakConstructorInitializers: BeforeComma
    84. BreakAfterJavaFieldAnnotations: false
    85. BreakStringLiterals: true
    86. CommentPragmas: '^ IWYU pragma:'
    87. CompactNamespaces: false
    88. ContinuationIndentWidth: 4
    89. DeriveLineEnding: true
    90. DisableFormat: false
    91. EmptyLineBeforeAccessModifier: LogicalBlock
    92. FixNamespaceComments: true
    93. ForEachMacros:
    94. - foreach
    95. - Q_FOREACH
    96. - BOOST_FOREACH
    97. StatementAttributeLikeMacros:
    98. - Q_EMIT
    99. IncludeBlocks: Regroup
    100. IncludeCategories:
    101. - Regex: '^<ext/.*\.h>'
    102. Priority: 2
    103. SortPriority: 0
    104. CaseSensitive: false
    105. - Regex: '^<.*\.h>'
    106. Priority: 1
    107. SortPriority: 0
    108. CaseSensitive: false
    109. - Regex: '^<.*'
    110. Priority: 2
    111. SortPriority: 0
    112. CaseSensitive: false
    113. - Regex: '.*'
    114. Priority: 3
    115. SortPriority: 0
    116. CaseSensitive: false
    117. IncludeIsMainRegex: '([-_](test|unittest))?$'
    118. IncludeIsMainSourceRegex: ''
    119. IndentCaseBlocks: false
    120. IndentGotoLabels: true
    121. IndentPPDirectives: BeforeHash
    122. IndentExternBlock: AfterExternBlock
    123. IndentRequires: false
    124. IndentWrappedFunctionNames: true
    125. InsertTrailingCommas: None
    126. JavaScriptQuotes: Leave
    127. JavaScriptWrapImports: true
    128. KeepEmptyLinesAtTheStartOfBlocks: true
    129. MacroBlockBegin: ''
    130. MacroBlockEnd: ''
    131. ObjCBinPackProtocolList: Auto
    132. ObjCBlockIndentWidth: 2
    133. ObjCBreakBeforeNestedBlockParam: true
    134. ObjCSpaceAfterProperty: false
    135. PenaltyBreakAssignment: 2
    136. PenaltyBreakTemplateDeclaration: 10
    137. PenaltyIndentedWhitespace: 0
    138. RawStringFormats:
    139. - Language: Cpp
    140. Delimiters:
    141. - cc
    142. - CC
    143. - cpp
    144. - Cpp
    145. - CPP
    146. - 'c++'
    147. - 'C++'
    148. CanonicalDelimiter: ''
    149. BasedOnStyle: google
    150. - Language: TextProto
    151. Delimiters:
    152. - pb
    153. - PB
    154. - proto
    155. - PROTO
    156. EnclosingFunctions:
    157. - EqualsProto
    158. - EquivToProto
    159. - PARSE_PARTIAL_TEXT_PROTO
    160. - PARSE_TEST_PROTO
    161. - PARSE_TEXT_PROTO
    162. - ParseTextOrDie
    163. - ParseTextProtoOrDie
    164. - ParseTestProto
    165. - ParsePartialTestProto
    166. CanonicalDelimiter: ''
    167. BasedOnStyle: google
    168. ReflowComments: true
    169. SortJavaStaticImport: Before
    170. SortUsingDeclarations: true
    171. SpaceAfterCStyleCast: false
    172. SpaceAfterLogicalNot: false
    173. SpaceAfterTemplateKeyword: true
    174. SpaceBeforeAssignmentOperators: true
    175. SpaceBeforeCaseColon: false
    176. SpaceBeforeCpp11BracedList: true
    177. SpaceBeforeCtorInitializerColon: true
    178. SpaceBeforeInheritanceColon: true
    179. SpaceBeforeParens: ControlStatements
    180. SpaceAroundPointerQualifiers: Default
    181. SpaceBeforeRangeBasedForLoopColon: true
    182. SpaceInEmptyBlock: false
    183. SpaceInEmptyParentheses: false
    184. SpacesBeforeTrailingComments: 1
    185. SpacesInConditionalStatement: false
    186. SpacesInContainerLiterals: false
    187. SpacesInCStyleCastParentheses: false
    188. SpacesInSquareBrackets: false
    189. SpaceBeforeSquareBrackets: false
    190. BitFieldColonSpacing: Both
    191. StatementMacros:
    192. - Q_UNUSED
    193. - QT_REQUIRE_VERSION
    194. UseCRLF: false
    195. WhitespaceSensitiveMacros:
    196. - STRINGIZE
    197. - PP_STRINGIZE
    198. - BOOST_PP_STRINGIZE
    199. - NS_SWIFT_NAME
    200. - CF_SWIFT_NAME
    201. ...

    .clang-tidy

    1. ---
    2. # Configure clang-tidy for this project.
    3. # Here is an explanation for why some of the checks are disabled:
    4. #
    5. # -google-readability-namespace-comments: the *_CLIENT_NS is a macro, and
    6. # clang-tidy fails to match it against the initial value.
    7. #
    8. # -modernize-use-trailing-return-type: clang-tidy recommends using
    9. # `auto Foo() -> std::string { return ...; }`, we think the code is less
    10. # readable in this form.
    11. #
    12. # -modernize-return-braced-init-list: We think removing typenames and using
    13. # only braced-init can hurt readability.
    14. #
    15. # -modernize-avoid-c-arrays: We only use C arrays when they seem to be the
    16. # right tool for the job, such as `char foo[] = "hello"`. In these cases,
    17. # avoiding C arrays often makes the code less readable, and std::array is
    18. # not a drop-in replacement because it doesn't deduce the size.
    19. #
    20. # -performance-move-const-arg: This warning requires the developer to
    21. # know/care more about the implementation details of types/functions than
    22. # should be necessary. For example, `A a; F(std::move(a));` will trigger a
    23. # warning IFF `A` is a trivial type (and therefore the move is
    24. # meaningless). It would also warn if `F` accepts by `const&`, which is
    25. # another detail that the caller need not care about.
    26. #
    27. # -readability-redundant-declaration: A friend declaration inside a class
    28. # counts as a declaration, so if we also declare that friend outside the
    29. # class in order to document it as part of the public API, that will
    30. # trigger a redundant declaration warning from this check.
    31. #
    32. # -readability-function-cognitive-complexity: too many false positives with
    33. # clang-tidy-12. We need to disable this check in macros, and that setting
    34. # only appears in clang-tidy-13.
    35. #
    36. # -bugprone-narrowing-conversions: too many false positives around
    37. # `std::size_t` vs. `*::difference_type`.
    38. #
    39. # -bugprone-easily-swappable-parameters: too many false positives.
    40. #
    41. # -bugprone-implicit-widening-of-multiplication-result: too many false positives.
    42. # Almost any expression of the form `2 * variable` or `long x = a_int * b_int;`
    43. # generates an error.
    44. #
    45. # -bugprone-unchecked-optional-access: too many false positives in tests.
    46. # Despite what the documentation says, this warning appears after
    47. # `ASSERT_TRUE(variable)` or `ASSERT_TRUE(variable.has_value())`.
    48. #
    49. Checks: >
    50. -*,
    51. abseil-*,
    52. bugprone-*,
    53. google-*,
    54. misc-*,
    55. modernize-*,
    56. performance-*,
    57. portability-*,
    58. readability-*,
    59. -google-readability-braces-around-statements,
    60. -google-readability-namespace-comments,
    61. -google-runtime-references,
    62. -misc-non-private-member-variables-in-classes,
    63. -misc-const-correctness,
    64. -misc-use-anonymous-namespace,
    65. -modernize-return-braced-init-list,
    66. -modernize-use-trailing-return-type,
    67. -modernize-use-nodiscard,
    68. -modernize-avoid-c-arrays,
    69. -performance-move-const-arg,
    70. -readability-braces-around-statements,
    71. -readability-identifier-length,
    72. -readability-magic-numbers,
    73. -readability-named-parameter,
    74. -readability-redundant-declaration,
    75. -readability-function-cognitive-complexity,
    76. -readability-convert-member-functions-to-static,
    77. -readability-qualified-auto,
    78. -readability-implicit-bool-conversion,
    79. -bugprone-narrowing-conversions,
    80. -bugprone-easily-swappable-parameters,
    81. -bugprone-implicit-widening-of-multiplication-result,
    82. -bugprone-unchecked-optional-access,
    83. -bugprone-branch-clone
    84. # Turn all the warnings from the checks above into errors.
    85. WarningsAsErrors: "*"
    86. CheckOptions:
    87. - { key: readability-identifier-naming.ClassCase, value: CamelCase }
    88. - { key: readability-identifier-naming.StructCase, value: CamelCase }
    89. - { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
    90. - { key: readability-identifier-naming.FunctionCase, value: camel_back }
    91. - { key: readability-identifier-naming.PrivateMemberPrefix, value: _ }
    92. - { key: readability-identifier-naming.ProtectedMemberPrefix, value: _ }
    93. - { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
    94. - { key: readability-identifier-naming.EnumConstantPrefix, value: k }
    95. - { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
    96. - { key: readability-identifier-naming.ConstexprVariablePrefix, value: k }
    97. - { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
    98. - { key: readability-identifier-naming.GlobalConstantPrefix, value: k }
    99. - { key: readability-identifier-naming.MemberConstantCase, value: CamelCase }
    100. - { key: readability-identifier-naming.MemberConstantPrefix, value: k }
    101. - { key: readability-identifier-naming.StaticConstantCase, value: CamelCase }
    102. - { key: readability-identifier-naming.StaticConstantPrefix, value: k }
    103. - { key: readability-implicit-bool-conversion.AllowIntegerConditions, value: 1 }
    104. - { key: readability-implicit-bool-conversion.AllowPointerConditions, value: 1 }
    105. - { key: readability-function-cognitive-complexity.IgnoreMacros, value: 1 }