2017 © Pedro Peláez
 

library architecture-sniffer

Spryker Code Architecture Sniffer

image

spryker/architecture-sniffer

Spryker Code Architecture Sniffer

  • Thursday, July 19, 2018
  • by spryker-bot
  • Repository
  • 53 Watchers
  • 5 Stars
  • 45,191 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 0 Forks
  • 14 Open issues
  • 17 Versions
  • 59 % Grown

The README.md

Architecture Sniffer

CI Coverage Latest Stable Version Minimum PHP Version License Total Downloads, (*1)

Architecture Sniffer for Spryker core, eco-system and applications., (*2)

Priority Levels

  • 1: API and critical
  • 2: 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., (*3)

Note: Lower priorities (higher numbers) always include the higher priorities (lower numbers)., (*4)

Usage

Make sure you include the sniffer as require-dev dependency:, (*5)

composer require --dev spryker/architecture-sniffer

Spryker Usage

When using Spryker you can use the Spryker CLI console command for it:, (*6)

console code:sniff:architecture [-m ModuleName] [optional-sub-path] -v [-p priority]

Verbose output is recommended here., (*7)

Manual Usage

You can also manually run the Architecture Sniffer from console by using:, (*8)

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., (*9)

Including the sniffer in PHPStorm

Add a new custom ruleset under Editor -> Inspections -> PHP -> PHP Mess Detector validation. Name it Architecture Sniffer for example., (*10)

The customer ruleset is defined in vendor/spryker/architecture-sniffer/src/ruleset.xml, (*11)

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., (*12)

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., (*13)

Every sniff needs a description as full sentence:, (*14)

    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., (*15)

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., (*16)

Setup

Run, (*17)

./setup.sh

and, (*18)

php composer.phar install

Testing

Don't forget to test your changes:, (*19)

php phpunit.phar

Running code-sniffer on this project

Make sure this repository is Spryker coding standard conform:, (*20)

php composer.phar cs-check

If you want to fix the fixable errors, use, (*21)

php composer.phar cs-fix

Once everything is green you can make a PR with your changes., (*22)

The Versions

19/07 2018

dev-master

9999999-dev http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

13/06 2018

dev-profuel-patch-1

dev-profuel-patch-1 http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

12/04 2018

dev-feature/core-4299-architecture-sniffer-plugin-and-plugin-interface-naming

dev-feature/core-4299-architecture-sniffer-plugin-and-plugin-interface-naming http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

12/02 2018

dev-fix-factory-pattern

dev-fix-factory-pattern http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

15/12 2017

dev-feature/ignore-deprecated-methods-in-factories

dev-feature/ignore-deprecated-methods-in-factories http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

27/11 2017

dev-feature/remove-bridge-api-check

dev-feature/remove-bridge-api-check http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

24/10 2017

dev-feature/non-action-methods

dev-feature/non-action-methods http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

29/09 2017

dev-feature/dependency-provider-method-names

dev-feature/dependency-provider-method-names http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

01/08 2017

0.4.0

0.4.0.0 http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

13/06 2017

dev-bugfix/bundle-constants

dev-bugfix/bundle-constants http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

11/04 2017

dev-feature/add-rules-2

dev-feature/add-rules-2 http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

22/03 2017

dev-feature/core-984-allow-config-constant-bundle-prefix

dev-feature/core-984-allow-config-constant-bundle-prefix http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

08/03 2017

0.3.0

0.3.0.0 http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

MIT

The Requires

 

The Development Requires

framework standards architecture sniffer

21/04 2016

dev-feature/add-tests

dev-feature/add-tests http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

proprietary

The Requires

 

The Development Requires

framework standards architecture sniffer

11/04 2016

0.2.0

0.2.0.0 http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

proprietary

The Requires

 

The Development Requires

framework standards architecture sniffer

11/04 2016

dev-feature/cleanup

dev-feature/cleanup http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

proprietary

The Requires

 

The Development Requires

framework standards architecture sniffer

08/04 2016

0.1.0

0.1.0.0 http://spryker.com

Spryker Code Architecture Sniffer

  Sources   Download

proprietary

The Requires

 

The Development Requires

framework standards architecture sniffer