To ensure the Coding Standards of Submitty, we use a mixture of linting and static analysis for each specific programming language. A linter is per Wikipedia is a “tool that analyzes source code to flag programming errors, bugs, stylistic errors, and suspicious constructs.” Static analysis constructs an abstract syntax tree of the program and is able to validate specific details such as the right number of types of parameters, functions return what they say they do, etc.
The Python code of Submitty is linted using flake8 and flake8-bugbear. You can run the Python linter locally by running the following command from the root level of Submitty source tree:
python3 -m flake8
Optionally, you can pass in a specific file or directory to only lint that file or directory. Currently, we exclude a number of legacy source code files. from Python linting, though there is effort to bring more and more of them under flake8.
See also: Python Style Guide
The PHP code of Submitty is linted using phpcs. You can run the PHP Linter locally:
# at root level of repository php site/vendor/bin/phpcs --standard=site/tests/ruleset.xml # or if in the /site/ directory php vendor/bin/phpcs --standard=tests/ruleset.xml
Similarly, you can pass a specific file or directory to
See also: PHP Style Guide
PHP Static Analysis
The PHP code of Submitty is statically analyzed by phpstan. To run it locally, you can do the following:
# at root level of repository php site/vendor/bin/phpstan analyze -c site/phpstan.neon site/app # or if in the /site/ directory php vendor/bin/phpstan analyze app
Unlike flake8 and phpcs, a path or file MUST be passed to phpstan.