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

chore: Tokens - cleanup #8350

Merged
merged 2 commits into from
Jan 5, 2025
Merged

chore: Tokens - cleanup #8350

merged 2 commits into from
Jan 5, 2025

Conversation

keradus
Copy link
Member

@keradus keradus commented Jan 5, 2025

depends on #8349

@keradus keradus marked this pull request as ready for review January 5, 2025 15:40
@coveralls
Copy link

coveralls commented Jan 5, 2025

Coverage Status

coverage: 95.036%. remained the same
when pulling abe5d12 on keradus:8234b
into a730f2f on PHP-CS-Fixer:master.

@keradus keradus merged commit 30071f3 into PHP-CS-Fixer:master Jan 5, 2025
27 checks passed
@keradus keradus deleted the 8234b branch January 5, 2025 15:50
@mvorisek
Copy link
Contributor

mvorisek commented Jan 5, 2025

I advise to revert this, how does this PR make things better?

@keradus
Copy link
Member Author

keradus commented Jan 5, 2025

Happy to hear the reason for revert. Otherwise, hard to discuss.

Why I raised those changes?

  • no need for logic to calculate amount of empty tokens when purpose of function is to remove all empty tokens
  • one error fewer
  • one extra assertion fewer

@mvorisek
Copy link
Contributor

mvorisek commented Jan 5, 2025

Sure 👍

The first assertion is good to make sure the check on l398 did really make it's job. (as it uses cache, this asserts the cache was in consistent state)

The 2nd assertion should be extended to check if really the removed empty tokens match the cache state, if yes, the cache can be set to zero.

As I discovered several bugs of cache update in the past, I find these assertions very valueable as hunting the bugs was very time consuming.

@keradus
Copy link
Member Author

keradus commented Jan 5, 2025

please convert those cases to tests. We barely have any assertions in src/ and I prefer to keep those ensuring mechanisms in tests.

@mvorisek
Copy link
Contributor

mvorisek commented Jan 5, 2025

That is not possible as you told me you do not want private internals tested.

@Wirone
Copy link
Member

Wirone commented Jan 16, 2025

I am not a fan of assert() because I consider this as unreliable. But removing those asserts without providing replacement decreases code quality IMHO. Just my 2 cents.

@keradus
Copy link
Member Author

keradus commented Jan 16, 2025

I disagreed to have them added in first place, I believe Kuba too (and we both complained about messing with internals). they failed to us to provide value in first place.

i decided to merge PR as-is and apply fixes separately, instead of having another few weeks discussion in PR that was having good bunch of optimizations

@mvorisek
Copy link
Contributor

I am not a fan of assert() because I consider this as unreliable. But removing those asserts without providing replacement decreases code quality IMHO. Just my 2 cents.

100%!

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

Successfully merging this pull request may close these issues.

4 participants