Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting improvements for core component: #201

Merged
merged 5 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/clp-core-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:
- name: "Run lint task"
shell: "bash"
working-directory: "./components/core"
run: "task lint"
run: "task lint_check"
6 changes: 6 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
extends: "default"

yaml-files:
- ".clang-format"
- ".yamllint"
- "*.yaml"
- "*.yml"

ignore: |
components/core/build/
components/core/cmake-build-debug/
Expand Down
117 changes: 60 additions & 57 deletions components/core/.clang-format
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
# yamllint disable-line rule:document-start
---
ColumnLimit: 100
IndentWidth: 4
# yamllint disable-line rule:document-start
---
Language: Cpp
Language: "Cpp"
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: None
AlignEscapedNewlines: DontAlign
AlignOperands: Align
AlignTrailingComments: Never
AlignAfterOpenBracket: "BlockIndent"
AlignArrayOfStructures: "None"
AlignConsecutiveAssignments: "None"
AlignConsecutiveBitFields: "None"
AlignConsecutiveDeclarations: "None"
AlignConsecutiveMacros: "None"
AlignEscapedNewlines: "DontAlign"
AlignOperands: "Align"
AlignTrailingComments:
Kind: "Never"
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortBlocksOnASingleLine: "Always"
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortFunctionsOnASingleLine: "Inline"
AllowShortIfStatementsOnASingleLine: "Never"
AllowShortLambdasOnASingleLine: "All"
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterReturnType: "None"
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AlwaysBreakTemplateDeclarations: "Yes"
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: Both
BitFieldColonSpacing: "Both"
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: MultiLine
AfterControlStatement: "MultiLine"
AfterEnum: false
AfterFunction: false
AfterNamespace: false
Expand All @@ -46,45 +49,45 @@ BraceWrapping:
SplitEmptyFunction: false
SplitEmptyNamespace: false
SplitEmptyRecord: false
BreakAfterAttributes: Never
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakAfterAttributes: "Never"
BreakBeforeBinaryOperators: "All"
BreakBeforeBraces: "Custom"
BreakBeforeConceptDeclarations: "Always"
BreakBeforeInlineASMColon: "OnlyMultiline"
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakConstructorInitializers: "BeforeColon"
BreakInheritanceList: "BeforeColon"
BreakStringLiterals: true
CompactNamespaces: true
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
EmptyLineAfterAccessModifier: "Never"
EmptyLineBeforeAccessModifier: "LogicalBlock"
FixNamespaceComments: true
IncludeBlocks: Regroup
IncludeBlocks: "Regroup"
IncludeCategories:
# NOTE: A header is grouped by first matching regex
# Third-party headers. Update when adding new third-party libraries.
- Regex: '^<(archive|boost|catch2|date|fmt|json|log_surgeon|mariadb|spdlog|sqlite3|yaml-cpp|zstd)'
- Regex: "^<(archive|boost|catch2|date|fmt|json|log_surgeon|mariadb|spdlog|sqlite3|yaml-cpp|zstd)"
Priority: 3
# C system headers
- Regex: '^<.+.h>'
- Regex: "^<.+\\.h>"
Priority: 1
# C++ standard libraries
- Regex: '^<.+>'
- Regex: "^<.+>"
Priority: 2
# Project headers
- Regex: '^".+"'
- Regex: "^\".+\""
Priority: 4
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: Indent
IndentExternBlock: "Indent"
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentPPDirectives: "BeforeHash"
IndentRequiresClause: false
IndentWrappedFunctionNames: false
InsertBraces: true
Expand All @@ -97,46 +100,46 @@ IntegerLiteralSeparator:
Hex: 4
HexMinDigits: 4
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
LineEnding: LF
LambdaBodyIndentation: "Signature"
LineEnding: "LF"
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
NamespaceIndentation: "Inner"
PPIndentWidth: -1
PackConstructorInitializers: CurrentLine
PackConstructorInitializers: "CurrentLine"
PenaltyBreakOpenParenthesis: 25
PenaltyBreakBeforeFirstCallParameter: 25
PenaltyReturnTypeOnItsOwnLine: 100
PointerAlignment: Left
QualifierAlignment: Custom
PointerAlignment: "Left"
QualifierAlignment: "Custom"
QualifierOrder:
- static
- friend
- inline
- "static"
- "friend"
- "inline"
# constexpr west as explained in https://www.youtube.com/watch?v=z6s6bacI424
- constexpr
- type
- const
- volatile
ReferenceAlignment: Pointer
- "constexpr"
- "type"
- "const"
- "volatile"
ReferenceAlignment: "Pointer"
ReflowComments: true
RemoveBracesLLVM: false
RemoveSemicolon: true
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Always
RequiresClausePosition: "OwnLine"
RequiresExpressionIndentation: "OuterScope"
SeparateDefinitionBlocks: "Always"
ShortNamespaceLines: 0
SortIncludes: CaseInsensitive
SortUsingDeclarations: Lexicographic
SortIncludes: "CaseInsensitive"
SortUsingDeclarations: "Lexicographic"
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceAroundPointerQualifiers: "Default"
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParens: "ControlStatements"
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
Expand All @@ -151,6 +154,6 @@ SpacesInLineCommentPrefix:
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Latest
Standard: "Latest"
TabWidth: 4
UseTab: Never
UseTab: "Never"
31 changes: 26 additions & 5 deletions components/core/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,30 @@ tasks:
cmds:
- "rm -rf {{.BUILD_DIR}}"

lint_check:
dir: "{{.TASKFILE_DIR}}"
cmds:
- task: "lint"
vars:
FLAGS: "--dry-run"
sources: &lint_source_files
- ".clang-format"
- "src/{**/*.cpp,**/*.h,**/*.hpp,**/*.inc}"
- "Taskfile.yml"
- "tests/{**/*.cpp,**/*.h,**/*.hpp,**/*.inc}"

lint_fix:
dir: "{{.TASKFILE_DIR}}"
cmds:
- task: "lint"
vars:
FLAGS: "-i"
sources: *lint_source_files

lint:
internal: true
requires:
vars: ["FLAGS"]
deps: ["lint_venv"]
dir: "{{.TASKFILE_DIR}}"
cmds:
Expand All @@ -21,18 +44,16 @@ tasks:
-type f \
\( -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" -o -iname "*.inc" \) \
-print0 | \
xargs -0 clang-format --dry-run -Werror
sources:
- "src/{**/*.cpp,**/*.h,**/*.hpp,**/*.inc}"
- "tests/{**/*.cpp,**/*.h,**/*.hpp,**/*.inc}"
xargs -0 clang-format {{.FLAGS}} -Werror

lint_venv:
internal: true
cmds:
- "python3 -m venv '{{.LINT_VENV_DIR}}'"
# Remove calls to `hash` since Task uses `gosh` rather than `bash`.
# NOTE: Older versions of Python's venv would only call `hash` if they detected the running
# shell was one that had the command, but that's not the case in newer versions.
- "sed -i 's/^\\s*hash\\s\\+.*//g' \"{{.LINT_VENV_DIR}}/bin/activate\""
- "sed -i 's/^\\s*hash\\s\\+.*/true/g' \"{{.LINT_VENV_DIR}}/bin/activate\""
- |
. "{{.LINT_VENV_DIR}}/bin/activate"
pip3 install --upgrade pip
Expand Down
3 changes: 1 addition & 2 deletions components/core/src/EncodedVariableInterpreter.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "EncodedVariableInterpreter.hpp"

#include <cmath>

#include <cassert>
#include <cmath>

#include "Defs.h"
#include "ffi/ir_stream/decoding_methods.hpp"
Expand Down
2 changes: 1 addition & 1 deletion components/core/src/streaming_archive/writer/Segment.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "Segment.hpp"

#include <cmath>
#include <sys/stat.h>

#include <climits>
#include <cmath>
#include <cstring>

#include "../../ErrorCode.hpp"
Expand Down
Loading