spryker / architecture-sniffer
Spryker Architecture Sniffer
Installs: 2 289 693
Dependents: 40
Suggesters: 0
Security: 0
Stars: 14
Watchers: 73
Forks: 2
Open Issues: 12
Requires
- php: >=7.4
- laminas/laminas-config: ^2.5.1 || ^3.1.0
- laminas/laminas-filter: ^2.5.1
- phpdocumentor/reflection-docblock: ^5.3.0
- phpmd/phpmd: ^2.10.0
- symfony/finder: ^4.0.0 || ^5.0.0 || ^6.0.0
Requires (Dev)
- codeception/codeception: ^4.1
- codeception/module-asserts: ^1.3
- phpstan/phpstan: ^1.0.0
- spryker/code-sniffer: *
- symfony/var-dumper: ^4.0
- dev-master
- 0.5.7
- 0.5.6
- 0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.0
- dev-feature/DPIB-488-comment-analyzer-tool
- dev-feature/te-10562-rule-to-prevent-deprecated-object-usage-of-json-decode
- dev-feature/te-10423/te-10424-adjust-arch-sniffer
- dev-feature/te-9758/master-kernel-architecture-rule-factory-get-no-new
- dev-poc/facade-function-naming-rule
- dev-feature/te-4011/master-remove-deprecated-messages-from-tests
This package is auto-updated.
Last update: 2024-11-07 21:40:21 UTC
README
Architecture Sniffer for Spryker core, eco-system and applications.
Priority Levels
1
: API and critical2
: Non critical (nice to have)3
: Experimental (inspected code needs further fixing)
We use and recommend minimum priority 2
by default for local and CI checks.
Note: Lower priorities (higher numbers) always include the higher priorities (lower numbers).
Usage
Make sure you include the sniffer as require-dev
dependency:
composer require --dev spryker/architecture-sniffer
Spryker Usage
When using Spryker you can use the Spryker CLI console command for it:
console code:sniff:architecture [-m ModuleName] [optional-sub-path] -v [-p priority]
Verbose output is recommended here.
Manual Usage
You can also manually run the Architecture Sniffer from console by using:
vendor/bin/phpmd src/Pyz/ (xml|text|html) vendor/spryker/architecture-sniffer/src/ruleset.xml --minimumpriority=2
Note: Lower priorities always include the higher priorities in the validation process.
Including the sniffer in PHPStorm
Add a new custom ruleset under Editor -> Inspections -> PHP -> PHP Mess Detector validation
.
Name it Architecture Sniffer
for example.
The customer ruleset is defined in vendor/spryker/architecture-sniffer/src/ruleset.xml
Check Mess Detector Settings
Under Framework & Languages -> PHP -> Mess Detector
you need to define the configuration and set the path to your phpmd (vendor/bin/phpmd). Use local and run Validate
to see if it works.
Writing new sniffs
Add them to inside src folder and add tests in tests
with the same folder structure.
Don't forget to update ruleset.xml
.
Every sniff needs a description as full sentence:
protected const RULE = 'Every Foo needs Bar.'; /** * @return string */ public function getDescription(): string { return static::RULE; }
Every sniff needs to implement either the ClassAware
, FunctionAware
, InterfaceAware
, or MethodAware
interface to be recognised.
To validate that sniffer recognises your rule, check if your rule is listed in Zed UI > Maintenance > Architecture sniffer.
Also note:
- The rule names must be unique across the rulesets.
- Each rule should contain only one "check".
- Each rule always outputs also the reason (violation), not just the occurrence.
Setup
Run
./setup.sh
and
php composer.phar install
Testing
Don't forget to test your changes:
php phpunit.phar
Running code-sniffer on this project
Make sure this repository is Spryker coding standard conform:
php composer.phar cs-check
If you want to fix the fixable errors, use
php composer.phar cs-fix
Once everything is green you can make a PR with your changes.