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: Baseline with ignorelines not fully working #428

Closed
joshlopes opened this issue Apr 26, 2024 · 0 comments · Fixed by #430
Closed

Bug: Baseline with ignorelines not fully working #428

joshlopes opened this issue Apr 26, 2024 · 0 comments · Fixed by #430
Labels
bug Something isn't working

Comments

@joshlopes
Copy link

joshlopes commented Apr 26, 2024

Bug Report

Q A
BC Break no
Library Version 0.3.29
PHP version 8.3

Summary

Current behavior

Let's assume we have the following

{
        {
            "fqcn": "App\Application\Foo",
            "line": 1,
            "error": "depends on App\\Ui\\Bar, but should not depend on these namespaces: App\\Ui\\*, App\\Tests\\* because of component architecture"
        },
        {
            "fqcn": "App\Application\Foo",
            "line": 3,
            "error": "depends on App\\Ui\\Baz, but should not depend on these namespaces: App\\Ui\\*, App\\Tests\\* because of component architecture"
        },
        {
            "fqcn": "App\Application\Foo",
            "line": 2,
            "error": "depends on App\\Ui\\Bar, but should not depend on these namespaces: App\\Ui\\*, App\\Tests\\* because of component architecture"
        },
}

What happens is that when doing the phparkitect check --ignore-baseline-linenumbers, the function used to remove in the udiff is check for the error and fqn first and then spaceship the sort -- and that messes up the cursor in one of the arrays and not fully cleaning up post doing it. In the case above we could be NOT removing the line 3 (BAZ) because it moved the cursor past that error when looking for BAR

How to reproduce

This is a little tricky, you basically need to create a baseline where the initial sorting using lines differ from the sort when ignoring lines. I can't share the current baseline where this happens because is from my company and I'm not allowed to do that.

Expected behavior

Everything that is on my baseline should be removed. Doing phparkitect generate-baseline and post phparkictect check --ignore-baseline-numbers should ALWAYS be successful. Because the initial sorting is taking in consideration lines, and later during comparing is not fully trusting that sort, it's breaking this removal.

@AlessandroMinoccheri AlessandroMinoccheri added the bug Something isn't working label Apr 30, 2024
marmichalski added a commit to marmichalski/arkitect that referenced this issue May 1, 2024
AlessandroMinoccheri pushed a commit that referenced this issue May 3, 2024
…ption (#430)

* Test case for #428

* Handle unordered baseline violations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants