Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No violations detected when there are. #429

Open
NoahNxT opened this issue Apr 29, 2024 · 1 comment
Open

No violations detected when there are. #429

NoahNxT opened this issue Apr 29, 2024 · 1 comment

Comments

@NoahNxT
Copy link

NoahNxT commented Apr 29, 2024

Q A
Library version 0.3.29
PHP version 8.3

Support Question

I made a config fully custom to the project we are working on, but for some reason even when there are violations it always gives me the NO VIOLATIONS DETECTED! result.

image

Hereby an example:

I created a rule for all my enums to be uniform named and be the type of an Enum:

    $classSet = ClassSet::fromDir(__DIR__ . '/Modules');

    $layeredArchitectureRules = Architecture::withComponents()
            ->component('Enum')->definedBy('Modules\*\App\Domains\*\Enums\*')    
            ->component('Trait')->definedBy('Modules\*\App\Domains\*\Traits\*')
            ->where('Enum')->mayDependOnComponents('Trait')
            ->rules();

    $rules[] = Rule::allClasses()
        ->that(new ResideInOneOfTheseNamespaces('Modules\*\App\Domains\*\Enums'))
        ->should(new HaveNameMatching('*Enum'))
        ->because('we want uniform naming');
    $rules[] = Rule::allClasses()
        ->that(new ResideInOneOfTheseNamespaces('Modules\*\App\Domains\*\Enums'))
        ->should(new IsEnum())
        ->because('Enums should be enums');

    $config->add($classSet, ...$rules, ...$layeredArchitectureRules);

I created a fake file in the folder:

image

The path of the file is:
/Modules/Hrm/App/Domains/Base/Enums/test.php

The command I'm running:
./vendor/bin/phparkitect check

Any Idea what is happening? Can't seem to find any other options anymore.

@fain182
Copy link
Collaborator

fain182 commented Apr 30, 2024

You can try to debug rules by using for example:
phparkitect debug:expression ResideInOneOfTheseNamespaces "Modules\*\App\Domains\*\Enums\*"

So you can check if the problem is that is not considering the class with the problems or if the problem is somewhere else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants