diff --git a/.clang-format b/.clang-format index 99ec0442e0..05555b9d18 100644 --- a/.clang-format +++ b/.clang-format @@ -5,7 +5,7 @@ AccessModifierOffset: -1 AlignAfterOpenBracket: Align AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false -AlignEscapedNewlinesLeft: true +AlignEscapedNewlines: Left AlignOperands: true AlignTrailingComments: false AllowAllParametersOfDeclarationOnNextLine: true @@ -32,12 +32,20 @@ BraceWrapping: BeforeCatch: false BeforeElse: false IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true BreakBeforeBinaryOperators: None BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true ColumnLimit: 80 CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 @@ -45,7 +53,11 @@ Cpp11BracedListStyle: true DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false -ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH IncludeCategories: - Regex: '^<.*\.h>' Priority: 1 @@ -53,9 +65,12 @@ IncludeCategories: Priority: 2 - Regex: '.*' Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' IndentCaseLabels: true IndentWidth: 2 IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: false MacroBlockBegin: '' MacroBlockEnd: '' @@ -64,6 +79,7 @@ NamespaceIndentation: None ObjCBlockIndentWidth: 2 ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: false +PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 1 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 @@ -73,7 +89,9 @@ PenaltyReturnTypeOnItsOwnLine: 200 PointerAlignment: Left ReflowComments: true SortIncludes: false +SortUsingDeclarations: true SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false diff --git a/.travis.yml b/.travis.yml index f25ce5378c..99b6833a33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +sudo: true dist: trusty language: java @@ -11,22 +12,27 @@ matrix: addons: apt: + sources: + - deadsnakes packages: - g++-multilib - lib32stdc++6 - - python3 - - python3-pip - - clang-format-3.8 + - python3.5 before_install: - - .travis-scripts/install.sh + - sudo sh -c 'echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main" > /etc/apt/sources.list.d/llvm.list' + - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - + - sudo apt-get update -q || true + - sudo apt-get install clang-format-5.0 -y install: - - pip3 install --user wpiformat + - wget https://bootstrap.pypa.io/get-pip.py + - sudo python3.5 get-pip.py + - python3.5 -m pip install --user wpiformat - ./gradlew build -PbuildAll script: - - wpiformat -y 2017 -clang 3.8 + - python3.5 -m wpiformat -y 2017 -clang 5.0 - git --no-pager diff --exit-code HEAD # Ensure formatter made no changes - ./gradlew build -PbuildAll diff --git a/src/main/native/cpp/UnlimitedHandleResource.h b/src/main/native/cpp/UnlimitedHandleResource.h index 285afd766f..be426abc65 100644 --- a/src/main/native/cpp/UnlimitedHandleResource.h +++ b/src/main/native/cpp/UnlimitedHandleResource.h @@ -109,8 +109,9 @@ THandle UnlimitedHandleResource::Allocate( } template -inline std::shared_ptr UnlimitedHandleResource< - THandle, TStruct, typeValue, TMutex>::Get(THandle handle) { +inline std::shared_ptr +UnlimitedHandleResource::Get( + THandle handle) { auto index = handle.GetTypedIndex(static_cast(typeValue)); if (index < 0) return nullptr; diff --git a/src/main/native/cpp/UsbCameraImpl.cpp b/src/main/native/cpp/UsbCameraImpl.cpp index 2ae6e8a44d..3f2641e8a1 100644 --- a/src/main/native/cpp/UsbCameraImpl.cpp +++ b/src/main/native/cpp/UsbCameraImpl.cpp @@ -664,9 +664,8 @@ CS_StatusValue UsbCameraImpl::DeviceCmdSetProperty( // Check kind match if ((setString && prop->propKind != CS_PROP_STRING) || - (!setString && - (prop->propKind & (CS_PROP_BOOLEAN | CS_PROP_INTEGER | CS_PROP_ENUM)) == - 0)) + (!setString && (prop->propKind & + (CS_PROP_BOOLEAN | CS_PROP_INTEGER | CS_PROP_ENUM)) == 0)) return CS_WRONG_PROPERTY_TYPE; // Handle percentage property diff --git a/src/main/native/cpp/cscore_c.cpp b/src/main/native/cpp/cscore_c.cpp index 43f582c070..6d782be513 100644 --- a/src/main/native/cpp/cscore_c.cpp +++ b/src/main/native/cpp/cscore_c.cpp @@ -133,9 +133,10 @@ CS_Bool CS_SetSourceVideoModeDiscrete(CS_Source source, int width, int height, int fps, CS_Status* status) { return cs::SetSourceVideoMode( - source, cs::VideoMode{static_cast( - static_cast(pixelFormat)), - width, height, fps}, + source, + cs::VideoMode{static_cast( + static_cast(pixelFormat)), + width, height, fps}, status); }