Skip to content
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

GDLint Crashes on Static Variable #242

Closed
lunarcloud opened this issue Oct 29, 2023 · 5 comments
Closed

GDLint Crashes on Static Variable #242

lunarcloud opened this issue Oct 29, 2023 · 5 comments
Labels
bug Something isn't working linter

Comments

@lunarcloud
Copy link

lunarcloud commented Oct 29, 2023

Despite #215 , I cannot use a static var. The problem goes away if I remove the "static" keyword from my variable on line 30

File causing issue: lunarcloud/godot-xr-tools - rumble_manager.gd

Godot version: 4.1.2 stable (linux x86_64)

GDScript Toolkit Version: git+https://github.com/Scony/godot-gdscript-toolkit.git (on 29 October 2023)

steps:

sam@sam-desktop:~$ cd ~/GitHub/forks/godot-xr-tools

sam@sam-desktop:~/GitHub/forks/godot-xr-tools$ rm -r .venv

sam@sam-desktop:~/GitHub/forks/godot-xr-tools$ python -m venv .venv

sam@sam-desktop:~/GitHub/forks/godot-xr-tools$ source .venv/bin/activate

(.venv) sam@sam-desktop:~/GitHub/forks/godot-xr-tools$ pip3 install git+https://github.com/Scony/godot-gdscript-toolkit.git
Collecting git+https://github.com/Scony/godot-gdscript-toolkit.git
Cloning https://github.com/Scony/godot-gdscript-toolkit.git to /tmp/pip-req-build-7sxk1lej
Running command git clone --filter=blob:none --quiet https://github.com/Scony/godot-gdscript-toolkit.git /tmp/pip-req-build-7sxk1lej
Resolved https://github.com/Scony/godot-gdscript-toolkit.git to commit 62e429a2c3ae98cf6854a9b8b6d46147ee9ccd9d
Running command git submodule update --init --recursive -q
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting lark[regex]==1.1.5 (from gdtoolkit==4.1.0)
Using cached lark-1.1.5-py3-none-any.whl (107 kB)
Collecting docopt-ng==0.8.1 (from gdtoolkit==4.1.0)
Using cached docopt_ng-0.8.1-py2.py3-none-any.whl (16 kB)
Collecting pyyaml>=5.1 (from gdtoolkit==4.1.0)
Obtaining dependency information for pyyaml>=5.1 from https://files.pythonhosted.org/packages/7b/5e/efd033ab7199a0b2044dab3b9f7a4f6670e6a52c089de572e928d2873b06/PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
Using cached PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.1 kB)
Collecting radon==6.0.1 (from gdtoolkit==4.1.0)
Using cached radon-6.0.1-py2.py3-none-any.whl (52 kB)
Collecting regex (from lark[regex]==1.1.5->gdtoolkit==4.1.0)
Obtaining dependency information for regex from https://files.pythonhosted.org/packages/f2/b8/b1ec82fce93064a73ba67f2bb158ec9cac4a0e8f0b6942268ec963947329/regex-2023.10.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
Using cached regex-2023.10.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (40 kB)
Collecting mando<0.8,>=0.6 (from radon==6.0.1->gdtoolkit==4.1.0)
Using cached mando-0.7.1-py2.py3-none-any.whl (28 kB)
Collecting colorama>=0.4.1 (from radon==6.0.1->gdtoolkit==4.1.0)
Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting six (from mando<0.8,>=0.6->radon==6.0.1->gdtoolkit==4.1.0)
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Using cached PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (757 kB)
Using cached regex-2023.10.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (785 kB)
Building wheels for collected packages: gdtoolkit
Building wheel for gdtoolkit (pyproject.toml) ... done
Created wheel for gdtoolkit: filename=gdtoolkit-4.1.0-py3-none-any.whl size=55582 sha256=2b3ab09043047a7cea05a633d98254256f77b81d3be867dee363f8d183535dab
Stored in directory: /tmp/pip-ephem-wheel-cache-2tgormpf/wheels/13/39/7c/fd019853d9263a8302f89d1eb2999d57b300c8679b58c3b8ef
Successfully built gdtoolkit
Installing collected packages: lark, six, regex, pyyaml, docopt-ng, colorama, mando, radon, gdtoolkit
Successfully installed colorama-0.4.6 docopt-ng-0.8.1 gdtoolkit-4.1.0 lark-1.1.5 mando-0.7.1 pyyaml-6.0.1 radon-6.0.1 regex-2023.10.3 six-1.16.0

(.venv) sam@sam-desktop:~/GitHub/forks/godot-xr-tools$ gdlint --verbose addons/godot-xr-tools/rumble/rumble_manager.gd
INFO:root:No 'gdlintrc' nor '.gdlintrc' found. Using default config...
INFO:root:Loaded config:
INFO:root:('disable', [])
INFO:root:('function-name', '(_on_([A-Z][a-z0-9]*)+(_[a-z0-9]+)*|_?[a-z][a-z0-9]*(_[a-z0-9]+)*)')
INFO:root:('class-name', '([A-Z][a-z0-9]*)+')
INFO:root:('sub-class-name', '_?([A-Z][a-z0-9]*)+')
INFO:root:('signal-name', '[a-z][a-z0-9]*(_[a-z0-9]+)*')
INFO:root:('class-variable-name', '_?[a-z][a-z0-9]*(_[a-z0-9]+)*')
INFO:root:('class-load-variable-name', '(([A-Z][a-z0-9]*)+|_?[a-z][a-z0-9]*(_[a-z0-9]+)*)')
INFO:root:('function-variable-name', '[a-z][a-z0-9]*(_[a-z0-9]+)*')
INFO:root:('function-preload-variable-name', '([A-Z][a-z0-9]*)+')
INFO:root:('function-argument-name', '_?[a-z][a-z0-9]*(_[a-z0-9]+)*')
INFO:root:('loop-variable-name', '_?[a-z][a-z0-9]*(_[a-z0-9]+)*')
INFO:root:('enum-name', '([A-Z][a-z0-9]*)+')
INFO:root:('enum-element-name', '[A-Z][A-Z0-9]*(_[A-Z0-9]+)*')
INFO:root:('constant-name', '_?[A-Z][A-Z0-9]*(_[A-Z0-9]+)*')
INFO:root:('load-constant-name', '(([A-Z][a-z0-9]*)+|_?[A-Z][A-Z0-9]*(_[A-Z0-9]+)*)')
INFO:root:('duplicated-load', None)
INFO:root:('expression-not-assigned', None)
INFO:root:('unnecessary-pass', None)
INFO:root:('unused-argument', None)
INFO:root:('comparison-with-itself', None)
INFO:root:('private-method-call', None)
INFO:root:('class-definitions-order', ['tools', 'classnames', 'extends', 'docstrings', 'signals', 'enums', 'consts', 'exports', 'pubvars', 'prvvars', 'onreadypubvars', 'onreadyprvvars', 'others'])
INFO:root:('max-returns', 6)
INFO:root:('max-public-methods', 20)
INFO:root:('function-arguments-number', 10)
INFO:root:('max-file-lines', 1000)
INFO:root:('trailing-whitespace', None)
INFO:root:('max-line-length', 100)
INFO:root:('tab-characters', 1)
INFO:root:('mixed-tabs-and-spaces', None)
INFO:root:('excluded_directories', {'.git'})
INFO:root:('no-elif-return', None)
INFO:root:('no-else-return', None)
Traceback (most recent call last):
File "/home/sam/GitHub/forks/godot-xr-tools/.venv/bin/gdlint", line 8, in <module>
sys.exit(main())
^^^^^^
File "/home/sam/GitHub/forks/godot-xr-tools/.venv/lib/python3.11/site-packages/gdtoolkit/linter/__main__.py", line 66, in main
problems_total += _lint_file(file_path, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sam/GitHub/forks/godot-xr-tools/.venv/lib/python3.11/site-packages/gdtoolkit/linter/__main__.py", line 134, in _lint_file
problems = lint_code(content, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sam/GitHub/forks/godot-xr-tools/.venv/lib/python3.11/site-packages/gdtoolkit/linter/__init__.py", line 121, in lint_code
problems += class_checks.lint(parse_tree, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sam/GitHub/forks/godot-xr-tools/.venv/lib/python3.11/site-packages/gdtoolkit/linter/class_checks.py", line 38, in lint
problems += [problem for cluster in problem_clusters for problem in cluster]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sam/GitHub/forks/godot-xr-tools/.venv/lib/python3.11/site-packages/gdtoolkit/linter/class_checks.py", line 38, in <listcomp>
problems += [problem for cluster in problem_clusters for problem in cluster]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sam/GitHub/forks/godot-xr-tools/.venv/lib/python3.11/site-packages/gdtoolkit/linter/class_checks.py", line 35, in <genexpr>
function(ast) if name not in disable else []
^^^^^^^^^^^^^
File "/home/sam/GitHub/forks/godot-xr-tools/.venv/lib/python3.11/site-packages/gdtoolkit/linter/class_checks.py", line 71, in _class_definitions_order_check
return [
^
File "/home/sam/GitHub/forks/godot-xr-tools/.venv/lib/python3.11/site-packages/gdtoolkit/linter/class_checks.py", line 74, in <listcomp>
for problem in _class_definitions_order_check_for_class(a_class, order)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sam/GitHub/forks/godot-xr-tools/.venv/lib/python3.11/site-packages/gdtoolkit/linter/class_checks.py", line 87, in _class_definitions_order_check_for_class
statement_section = _map_statement_to_section(statement)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sam/GitHub/forks/godot-xr-tools/.venv/lib/python3.11/site-packages/gdtoolkit/linter/class_checks.py", line 146, in _map_statement_to_section
raise NotImplementedError
NotImplementedError
(.venv) sam@sam-desktop:~/GitHub/forks/godot-xr-tools$
@Scony
Copy link
Owner

Scony commented Oct 30, 2023

Thanks! Just like the error says - it's not implemented. I forgot about the support for linter :) Thanks for bringing it up.

@lunarcloud
Copy link
Author

Is there a way to #gdlint:ignore = ? the single line I'm currently having an issue with in the meantime?

@Scony
Copy link
Owner

Scony commented Nov 1, 2023

@lunarcloud yes, but unfortunately it won't work. The way it's implemented is - it filters out the linter errors once they are calculated. Here we have an exception while calculating so there's no way to avoid that.

@Scony Scony closed this as completed in ad52508 Nov 1, 2023
@AlexTemina
Copy link

Hi! I'm still having the problem with 4.2.1... Installed the lastest mster version and when running gdlint I get:

Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Python310\Scripts\gdlint.exe\__main__.py", line 7, in <module>
  File "C:\Python310\lib\site-packages\gdtoolkit\linter\__main__.py", line 66, in main
    problems_total += _lint_file(file_path, config)
  File "C:\Python310\lib\site-packages\gdtoolkit\linter\__main__.py", line 134, in _lint_file
    problems = lint_code(content, config)
  File "C:\Python310\lib\site-packages\gdtoolkit\linter\__init__.py", line 122, in lint_code
    problems += class_checks.lint(parse_tree, config)
  File "C:\Python310\lib\site-packages\gdtoolkit\linter\class_checks.py", line 38, in lint
    problems += [problem for cluster in problem_clusters for problem in cluster]
  File "C:\Python310\lib\site-packages\gdtoolkit\linter\class_checks.py", line 38, in <listcomp>
    problems += [problem for cluster in problem_clusters for problem in cluster]
  File "C:\Python310\lib\site-packages\gdtoolkit\linter\class_checks.py", line 35, in <genexpr>
    function(ast) if name not in disable else []
  File "C:\Python310\lib\site-packages\gdtoolkit\linter\class_checks.py", line 71, in _class_definitions_order_check
    return [
  File "C:\Python310\lib\site-packages\gdtoolkit\linter\class_checks.py", line 74, in <listcomp>
    for problem in _class_definitions_order_check_for_class(a_class, order)
  File "C:\Python310\lib\site-packages\gdtoolkit\linter\class_checks.py", line 88, in _class_definitions_order_check_for_class
    section_rank = order.index(statement_section)
ValueError: 'staticvars' is not in list

@Scony
Copy link
Owner

Scony commented Dec 7, 2023

@AlexTemina you probably need to regenerate your gdlintrc file. Nevertheless, the above should not happen, I agree.

@Scony Scony reopened this Dec 7, 2023
@Scony Scony closed this as completed in f261487 Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linter
Projects
None yet
Development

No branches or pull requests

3 participants