forked from microsoft/calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the project code style, as it is not consistent. (microsoft#236)
Fixes microsoft#202 This PR fixes code style for the project files. The Problem Different files in the project use different code style. That is not consistent and leads to harder maintenance of the project. Description of the changes: Have investigated and determined the most used code style across the given codebase Have configured IDE and applied code style to all project files. Have crafted clang-formatter config. see https://clang.llvm.org/docs/ClangFormat.html https://clang.llvm.org/docs/ClangFormatStyleOptions.html Some cases were fixed manually How changes were validated: manual/ad-hoc testing, automated testing All tests pass as before because these are only code style changes. Additional Please review, and let me know if I have any mistake in the code style. In case of any mistake, I will change the configuration and re-apply it to the project.
- Loading branch information
Showing
237 changed files
with
12,659 additions
and
11,678 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
AccessModifierOffset: -4 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlines: Right | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: None | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: true | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BreakBeforeBinaryOperators: NonAssignment | ||
BreakBeforeBraces: Allman | ||
BreakBeforeInheritanceComma: false | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakConstructorInitializers: BeforeComma | ||
BreakAfterJavaFieldAnnotations: true | ||
BreakStringLiterals: true | ||
ColumnLimit: 160 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: true | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: false | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: false | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '^<ext/.*\.h>' | ||
Priority: 2 | ||
- Regex: '^<.*\.h>' | ||
Priority: 1 | ||
- Regex: '^<.*' | ||
Priority: 2 | ||
- Regex: '.*' | ||
Priority: 3 | ||
IncludeIsMainRegex: '([-_](test|unittest))?$' | ||
IndentCaseLabels: false | ||
IndentPPDirectives: None | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: false | ||
JavaScriptQuotes: Single | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: All | ||
ObjCBlockIndentWidth: 4 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 60 | ||
PointerAlignment: Left | ||
ReflowComments: true | ||
SortIncludes: false | ||
SortUsingDeclarations: true | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Cpp11 | ||
TabWidth: 4 | ||
UseTab: Never | ||
#... | ||
# unsupported rules | ||
#BreakInheritanceList: AfterColon | ||
#Language: None | ||
#ObjCBinPackProtocolList: Auto | ||
#PenaltyBreakTemplateDeclaration: 10 | ||
#SpaceBeforeCpp11BracedList: false | ||
#SpaceBeforeCtorInitializerColon: true | ||
#SpaceBeforeInheritanceColon: true | ||
#SpaceBeforeRangeBasedForLoopColon: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
function usage { | ||
echo "Usage: $0 DIR..." | ||
exit 1 | ||
} | ||
|
||
# Variable that will hold the name of the clang-format command | ||
FMT="" | ||
|
||
# Some distros just call it clang-format. Others (e.g. Ubuntu) are insistent | ||
# that the version number be part of the command. We prefer clang-format if | ||
# that's present, otherwise we work backwards from highest version to lowest | ||
# version. | ||
for clangfmt in clang-format{,-{4,3}.{9,8,7,6,5,4,3,2,1,0}}; do | ||
if which "$clangfmt" &>/dev/null; then | ||
FMT="$clangfmt" | ||
break | ||
fi | ||
done | ||
|
||
# Check if we found a working clang-format | ||
if [ -z "$FMT" ]; then | ||
echo "failed to find clang-format" | ||
exit 1 | ||
fi | ||
|
||
SRC_PATH="$@" | ||
if [ -z "$SRC_PATH" ]; then | ||
SRC_PATH="../../../src" | ||
fi | ||
|
||
# Check all of the arguments first to make sure they're all directories | ||
for dir in "$SRC_PATH"; do | ||
if [ ! -d "${dir}" ]; then | ||
echo "${dir} is not a directory" | ||
usage | ||
fi | ||
done | ||
|
||
# Run clang-format -i on all of the things | ||
for dir in "$SRC_PATH"; do | ||
pushd "${dir}" &>/dev/null | ||
find . \ | ||
\( -name '*.c' \ | ||
-o -name '*.cc' \ | ||
-o -name '*.cpp' \ | ||
-o -name '*.h' \ | ||
-o -name '*.hh' \ | ||
-o -name '*.hpp' \) \ | ||
-exec "${FMT}" -style=file -i '{}' \; | ||
popd &>/dev/null | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.