Info and routing files¶
Rules for the .info.yml file of a module, theme or profile and for .routing.yml files. They need
yml in Mago's extensions, as Install shows. Mago reads a YAML file as text
outside PHP tags, and these rules read the YAML in it.
drupal/info-auto-added-keys¶
- Level: warning
- Fix: none
- Source: Coder's
Drupalstandard - Ports:
Drupal.InfoFiles.AutoAddedKeys:Project,Timestamp,Version
Coder asks for no project, datestamp or version key in an .info.yml file. The drupal.org
packaging script adds them to the info files of a release, so the files in the repository mustn't
have them.
Reports:
- a
project,datestamporversionkey in an.info.ymlfile, each on its line.
Not reported:
versionin an info file under acore/directory;- a key below the
# Information added by Drupal.org packaging scriptcomment. It was written by the script, in a release installed by Composer.
Compared with Coder
- Coder reports the keys on the first line of the file.
- Coder also reports the keys written by the packaging script, so it reports every installed module of a site.
drupal/info-core-version-requirement¶
- Level: warning
- Fix: none
- Source: Coder's
DrupalPracticestandard - Ports:
DrupalPractice.InfoFiles.CoreVersionRequirement.CoreVersionRequirement
DrupalPractice asks for a core_version_requirement key in the .info.yml file of an extension.
Drupal installs the extension only on the core versions that the key names.
Reports:
- an
.info.ymlfile with atypekey and nocore_version_requirementkey.
Not reported:
- a test module, with
package: Testing; - a file whose name has a dot before
.info.yml, since a config file can be named that way.
Example
# Reported.
name: Example
type: module
description: 'Provides examples.'
# Fine.
name: Example
type: module
description: 'Provides examples.'
core_version_requirement: ^10.3 || ^11
Compared with Coder
- Coder skips a file with a dot anywhere in its path before
.info.yml, such as in a directory namedmy.site. The rule looks at the file name only.
drupal/info-dependencies-array¶
- Level: error
- Fix: none
- Source: Coder's
Drupalstandard - Ports:
Drupal.InfoFiles.DependenciesArray.Dependencies
Coder asks for the dependencies of an .info.yml file as a list.
Reports:
- a
dependencieskey in an.info.ymlfile that doesn't hold a list, such asdependencies: drupal:node.
Example
# Reported.
name: Example
type: module
dependencies: drupal:node
# Fine.
name: Example
type: module
dependencies:
- drupal:node
drupal/info-description¶
- Level: warning
- Fix: none
- Source: Coder's
DrupalPracticestandard - Ports:
DrupalPractice.InfoFiles.Description:Empty,Missing
DrupalPractice asks for a description in the .info.yml file of an extension.
Reports:
- an
.info.ymlfile with atypekey and nodescription; - an empty description, on its line.
Not reported:
- the files skipped by
drupal/info-core-version-requirement.
Compared with Coder
- Coder reports an empty description on the first line of the file.
drupal/info-namespaced-dependency¶
- Level: warning
- Fix: none
- Source: Coder's
DrupalPracticestandard - Ports:
DrupalPractice.InfoFiles.NamespacedDependency.NonNamespaced
DrupalPractice asks for each dependency to name its project, as in drupal:node.
Reports:
- a dependency in an
.info.ymlfile without the name of its project, such as- nodefor- drupal:node.
The rule reads the lines of a dependencies: list until a line that is neither a dependency nor a
comment.
Not reported:
- a list written on one line, as in
[node]; - a theme.
drupal/routing-access¶
- Level: warning
- Fix: none
- Source: Coder's
DrupalPracticestandard - Ports:
DrupalPractice.Yaml.RoutingAccess:OpenCallback,PermissionFound
Coder's DrupalPractice standard checks the access requirements of routes.
Reports:
- an
_access: 'TRUE'line in a.routing.ymlfile without a comment on the line above. A route that anyone may open needs a comment that says why; - an
_permission: 'access administration pages'line in a.routing.ymlfile. That permission lets a user view an administration page. A page that changes settings needsadminister site configuration.
The rule matches the lines as written, with single quotes.
Not reported:
_access: "TRUE", with double quotes.
Example
# Reported.
example.page:
path: '/example'
defaults:
_controller: '\Drupal\example\Controller\ExampleController::page'
requirements:
_access: 'TRUE'
# Fine.
example.page:
path: '/example'
defaults:
_controller: '\Drupal\example\Controller\ExampleController::page'
requirements:
# The page shows only public information.
_access: 'TRUE'