Description
Preconditions (*)
None. This issue applies to every Magento 2 release since its creation.
Magento 2.4-develop
Steps to reproduce (*)
Execute a global search of @SuppressWarnings
in the packages located under the magento vendor.
Using PHPStorm to perform the search, I get 8462 (eight thousand four hundred and sixty two) occurences of @SuppressWarnings
.
Expected result (*)
There should be zero occurence of @SuppressWarnings
in the Core source code of Magento 2.
Actual result (*)
There are lots of @SuppressWarnings
in the Core source code of Magento 2.
What does it mean?
It means that the Core maintainers are deliberately hiding potential code quality issues from the Core source code by using directives that make the code quality audit tools ignoring some issues.
For example, the Magento\Framework\View\Result\Page
class alone is plagued by four potential quality code violations that would never be noticed by the code quality auditing tool:
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.DepthOfInheritance)
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
In other words: Magento 2 code quality may be a a fraud, and a deliberate one.
I'm not saying that it is. Magento 2 code quality may be absolutely perfect, but these directives that suppress code quality warnings cast a shadow of doubt over the honesty of the maintainers. Magento 2 Core maintainers should seriously consider removing all these @SuppressWarnings
directives, run their code quality audit and publish the result. This is the only way to remove the doubts.