-
Notifications
You must be signed in to change notification settings - Fork 5
add format script #11
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,104 @@ | ||
--- | ||
# SPDX-FileCopyrightText: 2019 Christoph Cullmann <[email protected]> | ||
# SPDX-FileCopyrightText: 2019 Gernot Gebhard <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
# This file got automatically created by ECM, do not edit | ||
# See https://clang.llvm.org/docs/ClangFormatStyleOptions.html for the config options | ||
# and https://community.kde.org/Policies/Frameworks_Coding_Style#Clang-format_automatic_code_formatting | ||
# for clang-format tips & tricks | ||
--- | ||
Language: JavaScript | ||
DisableFormat: true | ||
--- | ||
|
||
# Style for C++ | ||
Language: Cpp | ||
|
||
# base is WebKit coding style: https://webkit.org/code-style-guidelines/ | ||
# below are only things set that diverge from this style! | ||
BasedOnStyle: WebKit | ||
|
||
# enforce C++11 (e.g. for std::vector<std::vector<lala>> | ||
Standard: Cpp11 | ||
|
||
# 4 spaces indent | ||
TabWidth: 4 | ||
IndentWidth: 4 | ||
UseTab: Always | ||
|
||
SpacesInLineCommentPrefix: | ||
Minimum: 1 | ||
Maximum: 1 | ||
|
||
# 2 * 80 wide lines | ||
ColumnLimit: 160 | ||
|
||
# sort includes inside line separated groups | ||
SortIncludes: true | ||
|
||
# break before braces on function, namespace and class definitions. | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterClass: false | ||
AfterCaseLabel: false | ||
|
||
# CrlInstruction *a; | ||
DerivePointerAlignment: false | ||
PointerAlignment: Left | ||
ReferenceAlignment: Left | ||
|
||
# only clang format 14 | ||
# RemoveBracesLLVM: true | ||
|
||
#QualifierAlignment: Left | ||
|
||
# horizontally aligns arguments after an open bracket. | ||
AlignAfterOpenBracket: Align | ||
|
||
# don't move all parameters to new line | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
|
||
# no single line functions | ||
AllowShortFunctionsOnASingleLine: None | ||
|
||
# always break before you encounter multi line strings | ||
AlwaysBreakBeforeMultilineStrings: true | ||
|
||
# don't move arguments to own lines if they are not all on the same | ||
BinPackArguments: false | ||
|
||
# don't move parameters to own lines if they are not all on the same | ||
BinPackParameters: false | ||
|
||
# In case we have an if statement with multiple lines the operator should be at the beginning of the line | ||
# but we do not want to break assignments | ||
BreakBeforeBinaryOperators: NonAssignment | ||
|
||
# format C++11 braced lists like function calls | ||
Cpp11BracedListStyle: true | ||
|
||
# do not put a space before C++11 braced lists | ||
SpaceBeforeCpp11BracedList: false | ||
|
||
# remove empty lines | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
|
||
# no namespace indentation to keep indent level low | ||
NamespaceIndentation: None | ||
|
||
# we use template< without space. | ||
SpaceAfterTemplateKeyword: false | ||
|
||
# Always break after template declaration | ||
AlwaysBreakTemplateDeclarations: true | ||
|
||
# macros for which the opening brace stays attached. | ||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE , wl_resource_for_each, wl_resource_for_each_safe ] | ||
|
||
# keep lambda formatting multi-line if not empty | ||
AllowShortLambdasOnASingleLine: Empty | ||
|
||
# We do not want clang-format to put all arguments on a new line | ||
AllowAllArgumentsOnNextLine: false |
This file contains hidden or 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 hidden or 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,41 @@ | ||
#!/bin/bash | ||
|
||
# Variable that will hold the name of the clang-format command | ||
FMT="" | ||
|
||
FOLDERS=("src" "test") | ||
|
||
# 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 check clang-format-13 | ||
for clangfmt in clang-format{,-13}; 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. Please install clang-format version 13 or above" | ||
exit 1 | ||
fi | ||
|
||
function format() { | ||
# ignore getRSS.h file | ||
for f in $(find $@ -name '*.h' ! -iname 'getRSS.h' -or -name '*.m' -or -name '*.mm' -or -name '*.c' -or -name '*.cpp'); do | ||
echo "format ${f}"; | ||
${FMT} -i ${f}; | ||
done | ||
|
||
echo "~~~ $@ Done ~~~"; | ||
} | ||
|
||
# Check all of the arguments first to make sure they're all directories | ||
for dir in ${FOLDERS[@]}; do | ||
if [ ! -d "${dir}" ]; then | ||
echo "${dir} is not a directory"; | ||
else | ||
format ${dir}; | ||
fi | ||
done |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we used the clang format action? This would allow us to drop the script and pull the action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this is possible, the benefit of the script is that it can be run locally, so if you would like to format your code, just execute the script. But if you like we can also use the action.
I would first prefer to fix the codebase and then adding this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. We can keep the script then. I was seeing your action file was using it and running the diff. Wasn't actually formatting then committing and a color diff would have been nice. I stumbled across this and figured it made more sense to do this and run the format on it one time locally like you said.
If you want I can run it and merge or you can do that within this one. Whatever works best for the work you are doing let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to first merge the other two branches, because otherwise a merge gets really a mess. So this is on hold for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay that is what I figured you wanted. Adding a TODO after that.