-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial 'gdplint' tool structure
- Loading branch information
Showing
5 changed files
with
80 additions
and
0 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,7 @@ | ||
from typing import List | ||
|
||
Problem = str # TODO: dataclass | ||
|
||
|
||
def lint_project(_project_path) -> List[Problem]: | ||
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Godot Project linter | ||
A tool for diagnosing typical Godot project problems. | ||
On success the exitcode is 0. | ||
On failure, python exception or list of problems is shown and exitcode is non-zero. | ||
Usage: | ||
gdplint <project_path>... [options] | ||
Options: | ||
-v --verbose Show extra prints | ||
-h --help Show this screen. | ||
--version Show version. | ||
""" | ||
import sys | ||
import pkg_resources | ||
import logging | ||
from typing import List | ||
|
||
from docopt import docopt | ||
|
||
from gdtoolkit.gdplint import lint_project | ||
|
||
|
||
Path = str | ||
|
||
|
||
def main(): | ||
arguments = docopt( | ||
__doc__, | ||
version="gdlint {}".format(pkg_resources.get_distribution("gdtoolkit").version), | ||
) | ||
|
||
if arguments["--verbose"]: | ||
logging.basicConfig(stream=sys.stdout, level=logging.INFO) | ||
|
||
problems_total = 0 | ||
|
||
project_paths: List[Path] = arguments["<project_path>"] | ||
for project_path in project_paths: | ||
problems_total += _lint_project(project_path) | ||
|
||
if problems_total > 0: | ||
print( | ||
"Failure: {} problem{} found".format( | ||
problems_total, "" if problems_total == 1 else "s" | ||
), | ||
file=sys.stderr, | ||
) | ||
sys.exit(1) | ||
|
||
print("Success: no problems found") | ||
|
||
|
||
def _lint_project(project_path: Path) -> int: | ||
outcome = lint_project(project_path) | ||
print(outcome) | ||
return len(outcome) |
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
Empty file.
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,13 @@ | ||
from gdtoolkit.gdplint import lint_project | ||
|
||
from ..common import write_file | ||
|
||
def test_valid_preload_path(tmp_path): | ||
write_file(tmp_path, "script_a.gd", "") | ||
write_file(tmp_path, "script_b.gd", "const A = preload(\"script_a.gd\")") | ||
assert lint_project(tmp_path) == [] | ||
|
||
def test_invalid_preload_path(tmp_path): | ||
write_file(tmp_path, "script_b.gd", "const A = preload(\"script_a.gd\")") | ||
# assert lint_project(tmp_path) != [] | ||
# TODO: check error precisely |