-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add gdscript linter and async-function-name linter (#102)
* refactor: format linter with `gdlint` * add linter to CI * feat: add async-function-name linter * docs: add contributing section with commit hook * add pre-commit hook script for cargo fmt * update rust * fixed taffy version
- Loading branch information
Showing
67 changed files
with
785 additions
and
612 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,99 @@ | ||
# CONTRIBUTING | ||
|
||
## Format GDScript | ||
|
||
When GD files are modified, they must be well-formated. | ||
It requires [godot-gdscript-toolkit](https://github.com/kuruk-mm/godot-gdscript-toolkit) installed | ||
|
||
Installation: | ||
```bash | ||
pip3 uninstall "gdtoolkit==4.*" | ||
pip3 install git+https://github.com/kuruk-mm/godot-gdscript-toolkit.git | ||
``` | ||
|
||
You can autoformat all files running: | ||
```bash | ||
gdformat godot/ | ||
``` | ||
|
||
You can run the linter with: | ||
```bash | ||
gdlint godot/ | ||
``` | ||
|
||
## Format Rust | ||
|
||
Format rust | ||
```bash | ||
cd rust/decentraland-godot-lib | ||
cargo fmt --all | ||
cargo clippy -- -D warnings | ||
``` | ||
|
||
## Git Hooks | ||
|
||
You can add the following hooks at `.git/hooks/pre-commit` | ||
|
||
! Remember to add executable permissions | ||
|
||
```bash | ||
chmod +x .git/hooks/pre-commit | ||
``` | ||
|
||
Script: | ||
```bash | ||
#!/bin/bash | ||
|
||
## FORMAT GDSCRIPT | ||
|
||
# Get modified .gd files | ||
MODIFIED_GD_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.gd$') | ||
|
||
# Check if there are .gd files to lint | ||
if [ ! -z "$MODIFIED_GD_FILES" ]; then | ||
|
||
# Run gdlint on modified files | ||
echo "Running gdlint on modified files..." | ||
gdlint $MODIFIED_GD_FILES | ||
|
||
# Save the exit status of gdlint | ||
GDLINT_EXIT=$? | ||
|
||
# If gdlint finds issues, cancel the commit | ||
if [ $GDLINT_EXIT -ne 0 ]; then | ||
echo "gdlint found issues, please fix them before committing." | ||
exit 1 | ||
fi | ||
|
||
# Run gdformat on modified files | ||
echo "Running gdformat on modified files..." | ||
gdformat -d $MODIFIED_GD_FILES | ||
|
||
# Save the exit status of gdlint | ||
GDFORMAT_EXIT=$? | ||
|
||
# If gdlint finds issues, cancel the commit | ||
if [ $GDFORMAT_EXIT -ne 0 ]; then | ||
echo "gdformat found issues, please fix them before committing." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
## FORMAT RUST | ||
|
||
# Change to the specific Rust directory | ||
cd rust/decentraland-godot-lib | ||
|
||
# Check if cargo fmt would make changes | ||
if ! cargo fmt -- --check | ||
then | ||
echo "Code formatting in 'rust/decentraland-godot-lib' differs from cargo fmt's style" | ||
echo "Run 'cargo fmt --all' inside 'rust/decentraland-godot-lib' to format the code." | ||
exit 1 | ||
fi | ||
|
||
echo "Code formatted" | ||
|
||
# If everything is okay, proceed with the commit | ||
exit 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
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,48 @@ | ||
class-definitions-order: | ||
- tools | ||
- classnames | ||
- extends | ||
- docstrings | ||
- signals | ||
- enums | ||
- consts | ||
- exports | ||
- pubvars | ||
- prvvars | ||
- onreadypubvars | ||
- onreadyprvvars | ||
- staticvars | ||
- others | ||
class-load-variable-name: (([A-Z][a-z0-9]*)+|_?[a-z][a-z0-9]*(_[a-z0-9]+)*) | ||
class-name: ([A-Z][a-z0-9]*)+ | ||
class-variable-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)* | ||
comparison-with-itself: null | ||
constant-name: _?[A-Z][A-Z0-9]*(_[A-Z0-9]+)* | ||
disable: [] | ||
duplicated-load: null | ||
enum-element-name: '[A-Z][A-Z0-9]*(_[A-Z0-9]+)*' | ||
enum-name: ([A-Z][a-z0-9]*)+ | ||
excluded_directories: !!set | ||
.git: null | ||
expression-not-assigned: null | ||
function-argument-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)* | ||
function-arguments-number: 10 | ||
function-name: (_on_([A-Z][a-z0-9]*)+(_[a-z0-9]+)*|_?[a-z][a-z0-9]*(_[a-z0-9]+)*) | ||
function-preload-variable-name: ([A-Z][a-z0-9]*)+ | ||
function-variable-name: '[a-z][a-z0-9]*(_[a-z0-9]+)*' | ||
load-constant-name: (([A-Z][a-z0-9]*)+|_?[A-Z][A-Z0-9]*(_[A-Z0-9]+)*) | ||
loop-variable-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)* | ||
max-file-lines: 1000 | ||
max-line-length: 9999 | ||
max-public-methods: 20 | ||
max-returns: 6 | ||
mixed-tabs-and-spaces: null | ||
no-elif-return: null | ||
no-else-return: null | ||
private-method-call: null | ||
signal-name: '[a-z][a-z0-9]*(_[a-z0-9]+)*' | ||
sub-class-name: _?([A-Z][a-z0-9]*)+ | ||
tab-characters: 1 | ||
trailing-whitespace: null | ||
unnecessary-pass: null | ||
unused-argument: null |
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.