To get your extension in the Magento Marketplace you have to comply with there rules. One of these rules is that your code must pass their Magento Marketplace Extension Quality Program Coding Standard, or Marketplace EQP in short. This is a set of custom Code Sniffer tools which inspects your code on quite a few common mistakes. For example:
raw SQL queries;
SQL queries inside a loop;
direct class instantiation;
unnecessary collection loading;
excessive code complexity;
use of dangerous functions;
use of PHP superglobals;
code style issues
The rules have different severities, going from 1 to 10. Your code must pass on level 10 to get your extension in the marketplace, but the lower your score is in general better.
You can always put this check in your CI pipeline or even in a git hook, but then you might need to refactor code very late in the process. The best is to see this immediately when you typing your code.
Next to that it is required for your extension to pass the marketplace test, it is also a good idea to enable this code sniffer while working on a complete Magento store as it prevents common mistakes.
Install the tools
There are 2 ways to install the required tools:
On a global Composer level.
In your current project.
Installing it on the global level was the easiest, but since PHPStorm 2018.3 the settings changed so you are now required to install the extension in your project:
composer global require magento/marketplace-eqp
Next: Open your PHPStorm preferences and navigate to Editor -> Inspections -> PHP -> Quality tools -> PHP Code Sniffer validation and enable it. Change the
Installed standard path setting to the
vendor/magento/marketplace-eqp folder of your project. Don't use the global in your home folder one as you will get this error:
PHP Fatal error: Trait 'MEQP\Utils\Helper' not found
Now click the refresh button next to the
Coding standard dropdown. MEQP1 and MEQP2 should now be available in the dropdown. Select the applicable version and save.
Now is the code sniffer active. Try to use the ObjectManager somewhere. PHPStorm is going to complain at you.