Skip to main content
Version: v1

Code quality

Vortex ships 10 code quality tools for a Drupal project, which check everything from PHP and Twig templates to Docker Compose files and Dockerfiles. They catch coding standard violations, type errors, deprecated APIs and formatting drift while the change is on your branch, so review can focus on what the code does.

The defaults suit a Drupal project as shipped. Every tool except Hadolint and SDC Devel reads its settings from a configuration file in the project root.

This page is for developers working on a project built from Vortex. It shows which tool checks which files, how to run the tools, how to fix what they report and how CI uses them. Each tool's own page covers its configuration and how to ignore a rule.

The following table lists each tool, what it checks and the command that runs it:

ToolChecksCommand
DCLintDocker Compose filesdclint .
ESLintJavaScript and YAML in custom modules, JavaScript in the custom themeahoy lint-fe
Gherkin LintBehat feature filesahoy lint-tests
HadolintDockerfileshadolint .docker/*.dockerfile
PHPCSPHP coding standardsahoy lint-be
PHPStanPHP static analysisahoy lint-be
RectorDeprecated PHP and Drupal code, automated refactoringahoy lint-be
SDC DevelSingle Directory Componentsahoy lint-sdc
StylelintCSS in custom modules, SCSS in the custom themeahoy lint-fe
Twig CS FixerTwig templatesahoy lint-fe

Run the linters​

ahoy lint runs 7 of the 10 tools through ahoy lint-be, ahoy lint-fe and ahoy lint-tests. SDC Devel needs a provisioned site, so it has its own ahoy lint-sdc command. DCLint and Hadolint run outside Ahoy.

The following table lists the Ahoy lint commands and their fix commands:

CommandToolsFix command
ahoy lintThe tools of ahoy lint-be, ahoy lint-fe and ahoy lint-testsahoy lint-fix
ahoy lint-bePHPCS, PHPStan, Rectorahoy lint-be-fix
ahoy lint-feTwig CS Fixer, ESLint, Stylelint (custom modules and the custom theme)ahoy lint-fe-fix
ahoy lint-testsGherkin LintNone
ahoy lint-sdcSDC Devel (requires a provisioned site)None

ahoy lint-fix runs ahoy lint-be-fix and then ahoy lint-fe-fix. ahoy lint-be-fix runs Rector and then PHPCBF, the fixer that ships with PHPCS. ahoy lint-fe-fix runs Twig CS Fixer, ESLint and Stylelint with their fix flags. PHPStan and Gherkin Lint only report problems, so fix what they find by hand.

Each command runs its tools in order and stops at the first tool that fails. A PHPCS violation stops the whole ahoy lint run, so no later tool reports until you fix it.

To confirm that every check passed, run echo $? right after the command. It prints 0 when every tool passed and a non-zero code when a tool failed. After ahoy lint, a 0 covers only the 7 tools it runs.

Vortex doesn't install DCLint or Hadolint in the project. To run them by hand, install them on your machine as the DCLint and Hadolint pages describe. In CI, they run from their official Docker images.

Continuous integration​

Every tool except SDC Devel runs in the lint job of the continuous integration pipeline and fails the build on violations. SDC Devel runs in the build job instead, after the site is provisioned. The deployment job waits for the lint job, so a branch that fails linting doesn't deploy.

Some findings, such as DCLint warnings, appear in the job log without failing the build. Each tool's page says which findings those are.

To let the build pass despite a tool's violations, set its VORTEX_CI_*_IGNORE_FAILURE CI variable to 1. The tool still runs and prints its violations in the job log, so you can see what you're letting through. For the variable each tool uses, see Ignore tool failures.