robotology-playground / clang-format

2 stars 0 forks source link

Minimum clang-format version? #2

Open traversaro opened 6 years ago

traversaro commented 6 years ago

I tried using the clang-format file contained in this repo with clang-format 3.8, and I obtained a lot of errors of this kind:

Error reading /home/straversaro/src/gazebo-fmi/./.clang-format: Invalid argument
YAML:92:24: error: unknown key 'SortUsingDeclarations'

I had to comment several properties to get it to work, see:

---
Language:        Cpp
# BasedOnStyle:  WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
# AlignEscapedNewlines: Left
AlignOperands:   true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
  AfterClass:      false
  AfterControlStatement: false
  AfterEnum:       false
  AfterFunction:   true
  AfterNamespace:  false
  AfterObjCDeclaration: false
  AfterStruct:     false
  AfterUnion:      false
  BeforeCatch:     false
  BeforeElse:      false
  IndentBraces:    false
  # SplitEmptyFunction: true
  # SplitEmptyRecord: true
  # SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeBraces: WebKit
# BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
# BreakConstructorInitializers: BeforeComma
# BreakAfterJavaFieldAnnotations: false
# BreakStringLiterals: true
ColumnLimit:   100
CommentPragmas:  '^ IWYU pragma:'
# CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat:   false
ExperimentalAutoDetectBinPacking: false
# FixNamespaceComments: true
ForEachMacros:
  - foreach
  - Q_FOREACH
  - BOOST_FOREACH
IncludeCategories:
  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
    Priority:        2
  - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
    Priority:        3
  - Regex:           '.*'
    Priority:        1
# IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentWidth:     4
IndentWrappedFunctionNames: false
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd:   ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
# PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments:  true
SortIncludes:    true
# SortUsingDeclarations: true
SpaceAfterCStyleCast: false
# SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles:  false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard:        Cpp11
TabWidth:        8
UseTab:          Never
...

There a minimum required version of clang-format to use the provided file? @diegoferigo

diegoferigo commented 6 years ago

Yes there is. I always kept this file updated with the most recent version of clang, and the last edit was supporting clang 5 in https://github.com/robotology-playground/clang-format/commit/447b53444248b6cfdc0e08a2365851776a1b64ed. I still have to check if clang 6 introduced anything new. Probably to ensure backward compatibility we should create various branches for different clang versions.

traversaro commented 6 years ago

Unless there is something that we cannot absolutely miss, I think it make sense to just require the default version provided in the latest Ubuntu LTS (for developers I think we can be a bit more strict, and just support that http://wiki.icub.org/wiki/YARP_Supported_Distributions ).

We can have multiple branches for more recent options, but I don't think it make sense to use them in the actual robotology repositories when 80% (rough estimate of the number of developers running the katest Ubuntu LTS) of the developers cannot use them.