Skip to content

Commit

Permalink
Merge pull request #213 from nRF24/clang-format
Browse files Browse the repository at this point in the history
Clang format
  • Loading branch information
TMRh20 authored Jun 24, 2022
2 parents f9b1bc4 + 557dac5 commit 50a25ed
Show file tree
Hide file tree
Showing 24 changed files with 919 additions and 526 deletions.
165 changes: 165 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# See options listed at https://releases.llvm.org/12.0.1/tools/clang/docs/ClangFormatStyleOptions.html
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: Consecutive
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Left
AlignOperands: DontAlign
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros: ["__capability", "__output", "__ununsed"]
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: MultiLine
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakStringLiterals: true
ColumnLimit: 0
# CommentPragmas are a regex pattern indicating the comment is not be touched by the formatter
CommentPragmas: "^ Include gaurd .*"
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false
EmptyLineBeforeAccessModifier: Always
# ---
# only in v13+
# EmptyLineAfterAccessModifier: Leave
# ---
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: ".*"
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: "(Test)?$"
IncludeIsMainSourceRegex: ""
# ---
# only in v13+
# IndentAccessModifiers: false
# ---
IndentCaseLabels: true
IndentCaseBlocks: false
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
# ---
# only in v13+
# ReferenceAlignment: Right
# ---
ReflowComments: true
# ---
# only in v13+
# ShortNamespaceLines: 0
# ---
# Sort**** is about sorting include/using statements alphabetically
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: c++11
StatementAttributeLikeMacros: [emit]
StatementMacros: [Q_UNUSED, QT_REQUIRE_VERSION]
TabWidth: 4
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- PRIPSTR
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
75 changes: 60 additions & 15 deletions .github/workflows/build_arduino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,37 @@ on:
- ".github/workflows/build_arduino.yml"
- "examples/**"

env:
# convenient variable used multiple times
SKETCHES_REPORTS: sketches-reports

jobs:
check_formatting:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Check code formatting
uses: per1234/artistic-style-action@main
with:
options-file-path: ./examples/examples_formatter.conf
name-patterns: |
- '*.ino'
- '*.cpp'
- '*.hpp'
- '*.h'
target-paths: |
- examples
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
# Ubuntu 20.04.4 LTS reunners ship with clang-tools v12
# - name: Install clang-tools
# uses: KyleMayes/install-llvm-action@v1
# with:
# version: 12
- name: Install linter python package
run: python3 -m pip install git+https://github.com/cpp-linter/cpp-linter-action@v1
- name: run linter as a python package
id: linter
run: |
cpp-linter \
--version=12 \
--style=file \
--tidy-checks='-*' \
--files-changed-only='False' \
--extensions=ino
- name: Linter checks failed?
if: steps.linter.outputs.checks-failed > 0
run: exit 1

build:
needs: check_formatting
runs-on: ubuntu-latest
Expand All @@ -42,7 +55,6 @@ jobs:
- "arduino:avr:yun"
- "arduino:avr:uno"
- "arduino:avr:diecimila"
- "arduino:avr:nano"
- "arduino:avr:mega"
- "arduino:avr:megaADK"
- "arduino:avr:leonardo"
Expand All @@ -65,7 +77,6 @@ jobs:
- "arduino:avr:unowifi"
- "arduino:mbed:nano33ble"
- "arduino:samd:mkr1000"
- "arduino:samd:mkrzero"
- "arduino:samd:mkrwifi1010"
- "arduino:samd:nano_33_iot"
- "arduino:samd:mkrfox1200"
Expand All @@ -80,6 +91,15 @@ jobs:
- "arduino:samd:tian"
- "arduino:megaavr:uno2018"
# - "arduino:megaavr:nano4809" # board not found
# By default, don't generate size deltas data.
enable-deltas-report:
- false
# Generate size deltas data for this board
include:
- fqbn: arduino:avr:nano
enable-deltas-report: true
- fqbn: arduino:samd:mkrzero
enable-deltas-report: true

steps:
- name: Checkout
Expand All @@ -101,3 +121,28 @@ jobs:
- source-path: ./
# - name: RF24Network
fqbn: ${{ matrix.fqbn }}
enable-deltas-report: ${{ matrix.enable-deltas-report }}
sketches-report-path: ${{ env.SKETCHES_REPORTS }}
# This step is needed to pass the size data to the report job
- name: Upload sketches report to workflow artifact
if: ${{ matrix.enable-deltas-report }}
uses: actions/upload-artifact@v2
with:
name: ${{ env.SKETCHES_REPORTS }}
path: ${{ env.SKETCHES_REPORTS }}

# When using a matrix to compile for multiple boards, it's necessary to use a separate job for the deltas report
report:
needs: [build]
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Download sketches reports artifact
uses: actions/download-artifact@v2
with:
name: ${{ env.SKETCHES_REPORTS }}
path: ${{ env.SKETCHES_REPORTS }}

- uses: arduino/report-size-deltas@v1
with:
sketches-reports-source: ${{ env.SKETCHES_REPORTS }}
27 changes: 27 additions & 0 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,34 @@ env:
BUILD_TYPE: Release

jobs:
check_formatting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
# Ubuntu 20.04.4 LTS reunners ship with clang-tools v12
# - name: Install clang-tools
# uses: KyleMayes/install-llvm-action@v1
# with:
# version: 12
- name: Install linter python package
run: python3 -m pip install git+https://github.com/cpp-linter/cpp-linter-action@v1
- name: run linter as a python package
id: linter
run: |
cpp-linter \
--version=12 \
--style=file \
--tidy-checks='-*' \
--files-changed-only='False' \
--ignore='examples|examples_pico'
- name: Linter checks failed?
if: steps.linter.outputs.checks-failed > 0
run: exit 1

using_cmake:
needs: check_formatting
runs-on: ubuntu-latest

strategy:
Expand Down
34 changes: 21 additions & 13 deletions .github/workflows/build_platformIO.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,27 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Check code formatting
uses: per1234/artistic-style-action@main
with:
options-file-path: ./examples/examples_formatter.conf
name-patterns: |
- '*.ino'
- '*.cpp'
- '*.hpp'
- '*.h'
target-paths: |
- examples
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
# Ubuntu 20.04.4 LTS reunners ship with clang-tools v12
# - name: Install clang-tools
# uses: KyleMayes/install-llvm-action@v1
# with:
# version: 12
- name: Install linter python package
run: python3 -m pip install git+https://github.com/cpp-linter/cpp-linter-action@v1
- name: run linter as a python package
id: linter
run: |
cpp-linter \
--version=12 \
--style=file \
--tidy-checks='-*' \
--files-changed-only='False' \
--extensions=ino
- name: Linter checks failed?
if: steps.linter.outputs.checks-failed > 0
run: exit 1

build:
needs: [check_formatting, validate_lib_json]
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/build_rp2xxx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,34 @@ env:
BUILD_TYPE: Release

jobs:
check_formatting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
# Ubuntu 20.04.4 LTS reunners ship with clang-tools v12
# - name: Install clang-tools
# uses: KyleMayes/install-llvm-action@v1
# with:
# version: 12
- name: Install linter python package
run: python3 -m pip install git+https://github.com/cpp-linter/cpp-linter-action@v1
- name: run linter as a python package
id: linter
run: |
cpp-linter \
--version=12 \
--style=file \
--tidy-checks='-*' \
--files-changed-only='False' \
--ignore='!examples_pico|'
- name: Linter checks failed?
if: steps.linter.outputs.checks-failed > 0
run: exit 1

build:
needs: check_formatting
runs-on: ubuntu-latest

strategy:
Expand Down
Loading

0 comments on commit 50a25ed

Please sign in to comment.