Skip to content

Commit

Permalink
Replace C++ linting configs with those managed by yscope-dev-utils; F…
Browse files Browse the repository at this point in the history
…orcibly enable `CMAKE_EXPORT_COMPILE_COMMANDS`. (#15)
  • Loading branch information
kirkrodrigues authored Oct 4, 2024
1 parent 7d7a1c3 commit be24868
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 297 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ build
cmake-build-*
dist

# Generated lint configs
.clang-format
.clang-tidy

# IDEs
.idea
.vscode
23 changes: 10 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,16 @@ if(NOT CMAKE_GENERATOR MATCHES "Unix Makefiles")
)
endif()

# Enable compile commands by default if the generator supports it.
if(NOT DEFINED CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_EXPORT_COMPILE_COMMANDS
ON
CACHE BOOL
"Enable/Disable output of compile commands during generation."
FORCE
)
endif()
if(CMAKE_EXPORT_COMPILE_COMMANDS)
# Disable response files since `clang-tidy` doesn't seem to be able to use them
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
endif()
# Enable exporting compile commands
set(CMAKE_EXPORT_COMPILE_COMMANDS
ON
CACHE BOOL
"Enable/Disable output of compile commands during generation."
FORCE
)

# Disable response files since `clang-tidy` doesn't seem to be able to use them
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES OFF)

# Set the default build type to Release if not specified
if(NOT CMAKE_BUILD_TYPE)
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@ task clean
Follow the steps below to develop and contribute to the project.

## Set up
Before opening the project in an IDE, you'll first need to download and install [emscripten]:
Before opening the project in an IDE, run the commands below.

Download and install [emscripten]:
```shell
task emsdk
```

Set up the config files for our C++ linting tools:
```shell
task lint:cpp-configs
```

## Linting
Before submitting a pull request, ensure you’ve run the linting commands below and either fixed any
violations or suppressed the warning.
Expand Down
3 changes: 3 additions & 0 deletions lint-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ tasks:
cmds:
- task: "yml-fix"

cpp-configs:
cmd: "{{.ROOT_DIR}}/tools/yscope-dev-utils/lint-configs/symlink-cpp-lint-configs.sh"

yml:
aliases:
- "yml-check"
Expand Down
151 changes: 2 additions & 149 deletions src/clp_ffi_js/.clang-format
Original file line number Diff line number Diff line change
@@ -1,75 +1,5 @@
# yamllint disable-line rule:document-start
---
ColumnLimit: 100
IndentWidth: 4
# yamllint disable-line rule:document-start
---
Language: "Cpp"
AccessModifierOffset: -4
AlignAfterOpenBracket: "BlockIndent"
AlignArrayOfStructures: "None"
AlignConsecutiveAssignments: "None"
AlignConsecutiveBitFields: "None"
AlignConsecutiveDeclarations: "None"
AlignConsecutiveMacros: "None"
AlignEscapedNewlines: "DontAlign"
AlignOperands: "Align"
AlignTrailingComments:
Kind: "Never"
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowBreakBeforeNoexceptSpecifier: "OnlyWithParen"
AllowShortBlocksOnASingleLine: "Always"
AllowShortCaseLabelsOnASingleLine: false
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: "Inline"
AllowShortIfStatementsOnASingleLine: "Never"
AllowShortLambdasOnASingleLine: "All"
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: "None"
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: "Yes"
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: "Both"
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: "MultiLine"
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterExternBlock: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyNamespace: false
SplitEmptyRecord: false
BreakAfterAttributes: "Never"
BreakBeforeBinaryOperators: "All"
BreakBeforeBraces: "Custom"
BreakBeforeConceptDeclarations: "Always"
BreakBeforeInlineASMColon: "OnlyMultiline"
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: "BeforeColon"
BreakInheritanceList: "BeforeColon"
BreakStringLiterals: true
CompactNamespaces: true
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: "Never"
EmptyLineBeforeAccessModifier: "LogicalBlock"
FixNamespaceComments: true
IncludeBlocks: "Regroup"
BasedOnStyle: "InheritParentConfig"

IncludeCategories:
# NOTE: A header is grouped by first matching regex
# Project headers
Expand All @@ -87,80 +17,3 @@ IncludeCategories:
# C++ standard libraries
- Regex: "^<.+>"
Priority: 2
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: "Indent"
IndentGotoLabels: false
IndentPPDirectives: "BeforeHash"
IndentRequiresClause: false
IndentWrappedFunctionNames: false
InsertBraces: true
InsertNewlineAtEOF: true
IntegerLiteralSeparator:
Binary: 4
BinaryMinDigits: 4
Decimal: 3
DecimalMinDigits: 5
Hex: 4
HexMinDigits: 4
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: "Signature"
LineEnding: "LF"
MaxEmptyLinesToKeep: 1
NamespaceIndentation: "None"
PPIndentWidth: -1
PackConstructorInitializers: "CurrentLine"
PenaltyBreakOpenParenthesis: 25
PenaltyBreakBeforeFirstCallParameter: 25
PenaltyReturnTypeOnItsOwnLine: 100
PointerAlignment: "Left"
QualifierAlignment: "Custom"
QualifierOrder:
- "static"
- "friend"
- "inline"
# constexpr west as explained in https://www.youtube.com/watch?v=z6s6bacI424
- "constexpr"
- "type"
- "const"
- "volatile"
ReferenceAlignment: "Pointer"
ReflowComments: true
RemoveBracesLLVM: false
RemoveSemicolon: true
RequiresClausePosition: "OwnLine"
RequiresExpressionIndentation: "OuterScope"
SeparateDefinitionBlocks: "Always"
ShortNamespaceLines: 0
SortIncludes: "CaseInsensitive"
SortUsingDeclarations: "Lexicographic"
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: "Default"
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: "ControlStatements"
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParens: "Custom"
SpacesInParensOptions:
InConditionalStatements: false
InCStyleCasts: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: "Latest"
TabWidth: 4
UseTab: "Never"
133 changes: 0 additions & 133 deletions src/clp_ffi_js/.clang-tidy

This file was deleted.

2 changes: 1 addition & 1 deletion tools/yscope-dev-utils

0 comments on commit be24868

Please sign in to comment.