-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added formatting checks for C/C++ and python code (#1348)
- Loading branch information
1 parent
f3d072d
commit 1ba5159
Showing
59 changed files
with
317 additions
and
333 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
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,4 @@ | ||
--- | ||
BasedOnStyle: Google | ||
IndentWidth: 4 | ||
... |
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,34 @@ | ||
name: Formatting | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
jobs: | ||
code-format-checks: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: DoozyX/clang-format-lint-action@v0.14 | ||
with: | ||
source: '.' | ||
extensions: 'h,c,cc,cpp,proto,java' | ||
clangFormatVersion: 14 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.11 | ||
- name: Install dependencies | ||
run: | | ||
pip install 'black==24.10.0' 'isort==5.13.2' | ||
- name: Run black | ||
run: | | ||
python -m black --check --diff ./ | ||
- name: Run isort | ||
run: | | ||
python -m isort --profile=black --check-only ./ |
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 |
---|---|---|
|
@@ -38,6 +38,9 @@ | |
# CMake | ||
cmake-build-*/ | ||
|
||
# Python | ||
/*venv/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
#include <jni.h> | ||
|
||
#include <string> | ||
|
||
extern "C" | ||
JNIEXPORT jstring | ||
extern "C" JNIEXPORT jstring | ||
|
||
JNICALL | ||
Java_com_example_android_bazel_MainActivity_stringFromJNI( | ||
JNIEnv *env, | ||
jobject /* this */) { | ||
JNICALL | ||
Java_com_example_android_bazel_MainActivity_stringFromJNI( | ||
JNIEnv *env, jobject /* this */) { | ||
std::string hello = "Hello from C++"; | ||
return env->NewStringUTF(hello.c_str()); | ||
} |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#include <stdio.h> | ||
|
||
#include "hello.h" | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
hello_func(); | ||
return 0; | ||
int main(int argc, char* argv[]) { | ||
hello_func(); | ||
return 0; | ||
} |
3 changes: 1 addition & 2 deletions
3
examples/cmake_android/java/com/example/android/bazel/MainActivity.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#include "hello.h" | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
hello_func(); | ||
return 0; | ||
int main(int argc, char* argv[]) { | ||
hello_func(); | ||
return 0; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#include "version123/hello.h" | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
hello_func(); | ||
return 0; | ||
int main(int argc, char* argv[]) { | ||
hello_func(); | ||
return 0; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#include "hello.h" | ||
|
||
void hello_func(void) { | ||
printf("Hello World!\n"); | ||
printf("Hello World!\n"); | ||
|
||
return; | ||
return; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
#include "hello.h" | ||
|
||
void hello_func(char* name) { | ||
printf("Hello, %s!", name); | ||
} | ||
void hello_func(char* name) { printf("Hello, %s!", name); } |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#include "hello.h" | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
hello_func(argv[1]); | ||
return 0; | ||
int main(int argc, char* argv[]) { | ||
hello_func(argv[1]); | ||
return 0; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#include "hello.h" | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
hello_func(); | ||
return 0; | ||
int main(int argc, char* argv[]) { | ||
hello_func(); | ||
return 0; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#include "hello.h" | ||
|
||
void hello_func(void) { | ||
printf("Hello World!\n"); | ||
printf("Hello World!\n"); | ||
|
||
return; | ||
return; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#include "hello.h" | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
hello_func(); | ||
return 0; | ||
int main(int argc, char* argv[]) { | ||
hello_func(); | ||
return 0; | ||
} |
7 changes: 3 additions & 4 deletions
7
examples/cmake_hello_world_lib/static/hello_client_version123.c
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#include "version123/hello.h" | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
hello_func(); | ||
return 0; | ||
int main(int argc, char* argv[]) { | ||
hello_func(); | ||
return 0; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#include "hello.h" | ||
|
||
void hello_func(void) { | ||
printf("Hello World!\n"); | ||
printf("Hello World!\n"); | ||
|
||
return; | ||
return; | ||
} |
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
#include "liba.h" | ||
|
||
std::string hello_liba(void) { | ||
return "Hello from LIBA!"; | ||
} | ||
std::string hello_liba(void) { return "Hello from LIBA!"; } |
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
#define LIBA_H_ (1) | ||
|
||
#include <stdio.h> | ||
|
||
#include <string> | ||
|
||
std::string hello_liba(void); | ||
|
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
#include "libb.h" | ||
|
||
std::string hello_libb(void) { | ||
return hello_liba() + " Hello from LIBB!"; | ||
} | ||
std::string hello_libb(void) { return hello_liba() + " Hello from LIBB!"; } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#include "libc.h" | ||
|
||
std::string hello_libc(void) { | ||
return hello_liba() + " " + hello_libb() + " Hello from LIBC!"; | ||
return hello_liba() + " " + hello_libb() + " Hello from LIBC!"; | ||
} |
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 |
---|---|---|
|
@@ -2,7 +2,9 @@ | |
#define LIBC_H_ (1) | ||
|
||
#include <stdio.h> | ||
|
||
#include <string> | ||
|
||
#include "liba.h" | ||
#include "libb.h" | ||
|
||
|
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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
#include "libb.h" | ||
|
||
#include <iostream> | ||
#include <stdexcept> | ||
#include <string> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
std:: string result = hello_libb(); | ||
if (result != "Hello from LIBA! Hello from LIBB!") { | ||
throw std::runtime_error("Wrong result: " + result); | ||
} | ||
std::cout << "Everything's fine!"; | ||
#include "libb.h" | ||
|
||
int main(int argc, char* argv[]) { | ||
std::string result = hello_libb(); | ||
if (result != "Hello from LIBA! Hello from LIBB!") { | ||
throw std::runtime_error("Wrong result: " + result); | ||
} | ||
std::cout << "Everything's fine!"; | ||
} |
Oops, something went wrong.