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

[Bug]: @pest-arch-ignore-line and @pest-arch-ignore-next-line directives don't work #1227

Closed
pascalchevrel opened this issue Sep 10, 2024 · 4 comments · May be fixed by pestphp/pest-plugin-arch#18
Labels

Comments

@pascalchevrel
Copy link

What Happened

I should be able to exclude specific lines in my code with @pest-arch-ignore-line and @pest-arch-ignore-next-line as indicated in the documentation.

I can't make it work by following the documentation steps, so either there is a bug in code or there is a bug in the documentation.

How to Reproduce

Add an architecture test to prevent the use of die. Either explicitly, or via a preset:

test('Classes don\'t use die')
    ->expect(['die'])
    ->not->toBeUsed();

or

arch()
   ->preset()
   ->php();

In a class method have a die() with one of the following directives:

public static function hola(): void
{
    die('This line will be ignored'); // @pest-arch-ignore-line
}

or

public static function hola(): void
{
    // @pest-arch-ignore-next-line
    die('This line will be ignored');
}

Run Pest:

   FAILED  Tests\Architecture\ArchitectureTest > Classes don't use die                                                                                                                                                        ArchExpectationFailedException   
  Expecting 'die' not to be used on 'Yolo\Hello'.

  at app/Yolo/Hello.php:9
      5▕ class Hello
      6▕ {
      7▕     public static function hola(): void
      8▕     {
  ➜   9▕         die('This line will be ignored'); // @pest-arch-ignore-line
     10▕     }
     11▕ }

  1   app/Yolo/Hello.php:9

Sample Repository

https://github.com/pascalchevrel/arch_preset

Pest Version

3.0.1

PHP Version

8.3.6

Operation System

Linux

Notes

No response

@nunomaduro
Copy link
Member

@pascalchevrel seems that the problem comes from: https://github.com/pestphp/pest-plugin-arch/blob/3.x/src/Blueprint.php. I've added the @pest-arch-ignore-line when expectations are done in a certain way, but not in all of them.

Can you check, and try to fix it?

@pascalchevrel
Copy link
Author

Sorry, filing bugs is one thing but fixing the technical issue is way beyond my technical skills, I fiddled with the files in the Expectation directory to see if an obvious fix was doable, but it's not :)

@nunomaduro
Copy link
Member

I've removed the feature; just use the regular ->ignoring for now: https://pestphp.com/docs/arch-testing#modifiers

@StyxUA
Copy link

StyxUA commented Sep 11, 2024

@nunomaduro Would that be ok for me to try and fix this?

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

Successfully merging a pull request may close this issue.

3 participants