From c21203f34bd6bfcaf809cec4e1f8ffec62576fff Mon Sep 17 00:00:00 2001 From: Emma Roy Date: Thu, 1 Oct 2026 22:32:23 -0400 Subject: [PATCH 1/3] update submitty_test with twig-lint, yaml-lint, shell-lint --- .../testing/linting_static_analysis.md | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/_docs/developer/testing/linting_static_analysis.md b/_docs/developer/testing/linting_static_analysis.md index 68856b9b..9a449be3 100644 --- a/_docs/developer/testing/linting_static_analysis.md +++ b/_docs/developer/testing/linting_static_analysis.md @@ -133,10 +133,13 @@ bash .setup/SUBMITTY_TEST.sh [options] - `phpcs`: Runs PHP CodeSniffer. [option: `--fix`] - `phpstan`: Runs PHP static analysis. [option: `--memory-limit <#>G`, `--generate-baseline`] - `php-lint`: Runs both PHP CodeSniffer and PHPStan (default options only). +- `twig-lint`: Lints all Twig templates. [option: `--format FORMAT`, `--show-deprecations`, `/path/to/file`] - `php-unit`: Runs PHP unit tests. [option: `--filter testFunctionName`, `--debug`] - `js-lint`: Runs eslint. [option: `--fix`] - `js-unit`: Runs the jest test suite. [option: `--api`] - `css-lint`: Runs stylelint. [option: `--fix`] +- `shell-lint`: Runs ShellCheck. +- `yaml-lint`: Runs yamllint. - `py-flake8`: Runs flake8. [option: `/path/to/specific_file.py`] - `py-pylint`: Runs pylint. [option: `/path/to/specific_file.py`] - `py-lint`: Runs pylint & flake8. [option: `/path/to/specific_file.py`] @@ -155,6 +158,13 @@ submitty_test phpcs --fix submitty_test phpstan ``` +## Twig Linting: +```bash +submitty_test twig-lint +submitty_test --show-deprecations +submitty_test /app/templates/File.twig # or any other path to a Twig file +``` + ## PHP Unit Testing: ```bash @@ -231,6 +241,38 @@ npm run css-stylelint:fix See also: [CSS Style Guide](/developer/coding_style_guide/css) +## Shell Linting + +Code in Submitty's `filename.sh` files is linted using [ShellCheck](https://github.com/koalaman/shellcheck/wiki). As with other languages, `submitty_test` can be used as an alias for the `SUBMITTY_TEST.sh` script. + +```bash +submitty_test shell-lint +``` + +Alternatively, you can run ShellCheck on your host system or on vagrant by running: + +```bash +python3 run_shellcheck.py +``` + +***NOTE:** To run the `run_shellcheck.py` wrapper script for shellcheck, you must be in the project root on your host system or in `/usr/local/submitty/GIT_CHECKOUT/Submitty` on the VM.* + +## YAML Linting + +YAML and YML are linted using [yamllint](https://yamllint.readthedocs.io/en/stable/). As with other languages, `submitty_test` can be used as an alias for the `SUBMITTY_TEST.sh` script. + +```bash +submitty_test yaml-lint +``` + +Alternatively, you can run yamllint on your host system (yamllint is not installed on the VM) by running: + +```bash +yamllint . +``` + +***NOTE:** For yamllint to see the .yamllint baseline file, you must be in the project root on your host system.* + ## Python Linting Python is linted using [flake8](https://flake8.pycqa.org/en/latest/) and [pylint](https://pylint.readthedocs.io/en/stable/) in Submitty. As with other languages, `submitty_test` can be used as an alias for the `SUBMITTY_TEST.sh` script. From 8d796bea2a6ba30bad6a8956ccbe492ef03ec4cc Mon Sep 17 00:00:00 2001 From: Emma Roy Date: Tue, 13 Oct 2026 18:16:58 -0400 Subject: [PATCH 2/3] update submitty_test docs with ruff instructions --- .../testing/linting_static_analysis.md | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/_docs/developer/testing/linting_static_analysis.md b/_docs/developer/testing/linting_static_analysis.md index 9a449be3..f49b0e95 100644 --- a/_docs/developer/testing/linting_static_analysis.md +++ b/_docs/developer/testing/linting_static_analysis.md @@ -140,9 +140,8 @@ bash .setup/SUBMITTY_TEST.sh [options] - `css-lint`: Runs stylelint. [option: `--fix`] - `shell-lint`: Runs ShellCheck. - `yaml-lint`: Runs yamllint. -- `py-flake8`: Runs flake8. [option: `/path/to/specific_file.py`] -- `py-pylint`: Runs pylint. [option: `/path/to/specific_file.py`] -- `py-lint`: Runs pylint & flake8. [option: `/path/to/specific_file.py`] +- `py-lint`: Runs ruff check. [option: `--fix`, `/path/to/specific_file.py`] +- `py-format`: Runs ruff format. [option: `--fix`, `/path/to/specific_file.py`] - `py-unit`: Runs all Python unit tests except `migration`. - `py-unit-utils` / `py-unit-migration` / `py-unit-autograder` / `py-unit-daemon`: Runs the respective Python unit test suite. [option: module, class, function ...] @@ -161,8 +160,8 @@ submitty_test phpstan ## Twig Linting: ```bash submitty_test twig-lint -submitty_test --show-deprecations -submitty_test /app/templates/File.twig # or any other path to a Twig file +submitty_test twig-lint --show-deprecations +submitty_test twig-lint app/templates/File.twig # or any valid path to a (real) Twig file ``` ## PHP Unit Testing: @@ -275,12 +274,22 @@ yamllint . ## Python Linting -Python is linted using [flake8](https://flake8.pycqa.org/en/latest/) and [pylint](https://pylint.readthedocs.io/en/stable/) in Submitty. As with other languages, `submitty_test` can be used as an alias for the `SUBMITTY_TEST.sh` script. +Python is linted using [ruff](https://docs.astral.sh/ruff/) with `ruff check`. As with other languages, `submitty_test` can be used as an alias for the `SUBMITTY_TEST.sh` script. ```bash -submitty_test py-lint # option: /path/to/specific_file.py -submitty_test py-flake8 # option: /path/to/specific_file.py -submitty_test py-pylint # option: /path/to/specific_file.py +submitty_test py-lint +submitty_test py-lint --fix +submitty_test py-lint /path/to/specific_file.py +``` + +## Python Formatting + +Python is formatted using [ruff](https://docs.astral.sh/ruff/) with `ruff format`. By default, this will be check only, eg `ruff format --check`. As with other languages, `submitty_test` can be used as an alias for the `SUBMITTY_TEST.sh` script. + +```bash +submitty_test py-format +submitty_test py-format --fix +submitty_test py-format /path/to/specific_file.py ``` See also: [Python Style Guide](/developer/coding_style_guide/python) From ce19c0fe30fcedcfb29ae7c76beb241ea74fcc9c Mon Sep 17 00:00:00 2001 From: Emma Roy Date: Tue, 13 Oct 2026 18:31:23 -0400 Subject: [PATCH 3/3] update python linting / static analysis instructions --- .../coding_style_guide/python.md | 14 ++++----- .../testing/linting_static_analysis.md | 31 +++++-------------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/_docs/developer/software_and_system_design/coding_style_guide/python.md b/_docs/developer/software_and_system_design/coding_style_guide/python.md index 626a1430..5d72c06e 100644 --- a/_docs/developer/software_and_system_design/coding_style_guide/python.md +++ b/_docs/developer/software_and_system_design/coding_style_guide/python.md @@ -7,14 +7,14 @@ redirect_from: __Minimum Version__: 3.8 -For Python, we use [flake8](http://flake8.pycqa.org/en/latest/) and [pylint](https://pylint.readthedocs.io/en/stable/) +For Python, we use [ruff](https://docs.astral.sh/ruff/) to check Python code such that it follows things laid out in [PEP-8](https://www.python.org/dev/peps/pep-0008/), -[PEP-257](https://www.python.org/dev/peps/pep-0257/), etc. The code is linted as part of our automated Travis-CI -testsuite to ensure compliance. To locally lint the code, you will need to install four modules: +[PEP-257](https://www.python.org/dev/peps/pep-0257/), etc. The code is linted as part of our automated GitHub CI +testsuite to ensure compliance. To locally lint the code, you will need to install ruff: ```bash -pip3 install flake8 flake8-bugbear pylint +pip install ruff ``` -and then you can just run `flake8` at the root to check all files or pass it an individual file to check just that. -To see all files that are currently checked as part of Travis-CI, please look at the `.flake8` config file. +and then you can just run `ruff check` at the root to check all files or pass it an individual file to check just that. +To see all files that are currently checked as part of GitHub CI, please look at the `pyproject.toml` config file. -For pylint, you can just run `pylint --recursive=y .` at the root to check all files or pass it an individual file. +For formatting, you can run `ruff format --check` to see formatting fixes, and `ruff format` to automatically apply them. diff --git a/_docs/developer/testing/linting_static_analysis.md b/_docs/developer/testing/linting_static_analysis.md index f49b0e95..6cfd8f0f 100644 --- a/_docs/developer/testing/linting_static_analysis.md +++ b/_docs/developer/testing/linting_static_analysis.md @@ -14,39 +14,24 @@ Be sure to start with the [Initial Set Up](/developer/testing/#initial-set-up) i ## Python Linting -The Python code of Submitty is linted using [flake8](https://flake8.pycqa.org/en/latest/), -[flake8-bugbear](https://github.com/PyCQA/flake8-bugbear), and [pylint](https://pylint.readthedocs.io/en/stable/). -You can run the Python linter locally (on your host operating system) by running the following command from the root -level of Submitty source tree: +The Python code of Submitty is linted using [ruff](https://docs.astral.sh/ruff/) with the command `ruff check`. +Assuming you have it installed, you can run Ruff locally (on your host machine) by running the following commands from the root of your Submitty repository: ```bash -# from root level of Submitty repository using flake8 -python3 -m flake8 - -# from root level of Submitty repository using pylint -python3 -m pylint --recursive=y . +ruff check ``` Optionally, you can pass in a specific file or directory to only lint that file or directory, e.g.: ```bash -# from root level of Submitty repository... to lint a specific file using flake: -python3 -m flake8 bin/generate_repos.py - -# from root level of Submitty repository... to lint a specific file using pylint: -python3 -m pylint bin/generate_repos.py +ruff check /path/to/specific_file.py ``` -If you wish to automatically fix the basic linting problems, you can use [black formatter](https://github.com/psf/black): +If you wish to automatically fix the basic linting problems, you can use `ruff format`: ```bash -# install black formatter -pip install git+https://github.com/psf/black - -# formats all the files in that directory -black ./files/location/ - -# formats specified file -black ./location/file.py +ruff format +ruff format --check +ruff format /path/to/specific_file.py ``` See also: [Python Style Guide](/developer/coding_style_guide/python)