-
Notifications
You must be signed in to change notification settings - Fork 154
Home
Lena Orobei edited this page Feb 12, 2019
·
4 revisions
PHP CodeSniffer is a static code analysis tool to detect violations of a defined Coding Standard.
A Coding Standard in PHP CodeSniffer - a collection of sniff files combined in the ruleset.xml
file.
Each sniff can have its own severity
(priority) and type
(error or warning).
There are few Magento related Coding Standards:
- Magento 2 Core sniffs
- Magento Marketplace Extension Quality Program (in short: MEQP)
- ExtDN PHP CodeSniffer rules (in short: Extdn)
Each of these Coding Standards contain a lot of sniffs in common. However, there are also some differences in the code checking approach. For example:
- The MEQP coding standard uses a
severity
approach (from 10 to 1). The test fails only in the case of aseverity
10 finding (error
). Issues withseverity
from 1 to 9 marked as awarning
and do not cause test failure. - In the Magento Core checking strategy, all findings lead to test failure. Note: By default, PHP CodeSniffer assigns a severity of 5 to all errors and warnings.
- MEQP Coding Standard contains some false-positive sniffs, for which the aim is just to warn developers and draw their attention to the particular code piece.
As a result it leads to inconsistency and code duplication. Extension developers are confused about what code standard to use in their extension development and Magento related projects contribution.
- Make it easier to run static checks for extensions developers.
- Store all related to Magento sniffs in one place.
- Make static check consistent.
- Make rules compatible with IDE.