Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Console] Remove redundant method getSaturation()#50317

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
ivanpepelko wants to merge0 commits intosymfony:6.3fromivanpepelko:6.2

Conversation

@ivanpepelko
Copy link
Contributor

@ivanpepelkoivanpepelko commentedMay 14, 2023
edited
Loading

QA
Branch?6.2
Bug fix?yes
New feature?no
Deprecations?no
Ticketsnone
LicenseMIT
Doc PRnone
  1. ingetSaturation(),$diff is compared againstint zero. This will only yieldtrue when RGB values contain min/max color value (0 or255). It will be alwaysfalse for floats.
  2. indegradeHexColorToAnsi4() value returned fromgetSaturation() isrounded, which returns float, thus making comparison toint zero useless.
  3. in the same method, bitwise operations (finalreturn statement) will convert number toint anyway, so the explicit cast was removed

In conclusion,getSaturation is redundant. Tests are expanded to show that even in min/max cases everything works fine.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

Copy link
Contributor

@maxbeckersmaxbeckers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM

@fabpot
Copy link
Member

Merging in 6.3 as this is not a bug fix, but mainly an improvement.

@fabpotfabpot modified the milestones:6.2,6.3May 15, 2023
@fabpotfabpot changed the base branch from6.2 to6.3May 15, 2023 08:49
@fabpot
Copy link
Member

Thank you@ivanpepelko.

fabpot added a commit that referenced this pull requestMay 15, 2023
…epelko)This PR was submitted for the 6.2 branch but it was merged into the 6.3 branch instead.Discussion----------[Console] Remove redundant method getSaturation()| Q             | A| ------------- | ---| Branch?       | 6.2| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       | none| License       | MIT| Doc PR        | none1. in `getSaturation()`, `$diff` is compared against `int` zero. This will only yield `true` when RGB values contain min/max color value (`0` or `255`). It will be always `false` for floats.2. in `degradeHexColorToAnsi4()` value returned from `getSaturation()` is `round`ed, which returns float, thus making comparison to `int` zero useless.3. in the same method, bitwise operations (final `return` statement) will convert number to `int` anyway, so the explicit cast was removedIn conclusion, `getSaturation` is redundant. Tests are expanded to show that even in min/max cases everything works fine.Commits-------38021b5 [Console] Remove redundant method getSaturation()
@fabpotfabpot closed thisMay 15, 2023
@downhiller
Copy link

I think the main issue was a bug on line 167:

return (int) $diff * 100 / $v;

should have been

return (int) ($diff * 100 / $v);

$diff was always less between 0.0 and 1.0, so would always (int) to 0, or 1.

My contribution feels a bit redundant given that they've moved on and refactored a while back, but might help someone wondering why getSaturation doesn't return anything useful.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@chalasrchalasrchalasr approved these changes

+1 more reviewer

@maxbeckersmaxbeckersmaxbeckers approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.3

Development

Successfully merging this pull request may close these issues.

7 participants

@ivanpepelko@carsonbot@fabpot@downhiller@nicolas-grekas@chalasr@maxbeckers

[8]ページ先頭

©2009-2025 Movatter.jp