Skip to main content
Version: v2

Code quality

Vortex ships 10 code quality tools that check the code of a Drupal project, 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 still on your branch, so review can focus on what the code does. The defaults work for Drupal projects without changes, and every tool except Hadolint and SDC Devel keeps them in 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 and fix what they report, and how the CI pipeline 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

Running​

ahoy lint runs the back-end linters (PHPCS, PHPStan, and Rector), the front-end linters (Twig CS Fixer, ESLint, and Stylelint), and Gherkin Lint for the Behat features. That's 7 of the 10 tools: SDC Devel needs a provisioned site, so it has its own ahoy lint-sdc command, and DCLint and Hadolint run outside Ahoy.

The checks are grouped into Ahoy commands, each with a matching fix command where the tools support automatic fixes:

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 you fix what they find by hand.

Each command runs its tools one after another and stops at the first one that fails. In ahoy lint, a PHPCS violation therefore keeps PHPStan, Rector, the front-end linters, and Gherkin Lint from running until you fix it.

Confirm that every check passed: run echo $? straight after the command. It prints 0 when every tool passed, and a non-zero code when 1 of them failed. After ahoy lint, a 0 covers only the 7 tools it runs, not SDC Devel, DCLint, or Hadolint.

Vortex doesn't install DCLint or Hadolint, so neither has an Ahoy command. To run them by hand, install them on your machine, as the DCLint and Hadolint pages describe. In continuous integration, they run from their official Docker images.

Continuous integration​

The same linters run in the lint job of the continuous integration pipeline and fail the build on violations. Some findings, such as DCLint warnings, appear in the job log without failing the build; each tool's page says which. The deployment job waits for the lint job, so a branch that fails linting doesn't deploy. SDC Devel runs in the test job instead, after the site is provisioned.

To let the build pass anyway, set a tool's 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. See Ignore tool failures for the variable each tool uses.