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

Allow missing commas when last element is same line than closer (take #2) #81

Merged
merged 2 commits into from
Nov 29, 2023

Conversation

stronk7
Copy link
Member

@stronk7 stronk7 commented Nov 24, 2023

This is a clone of #80 that was closed by mistake...

Comes with some tests to ensure that the case is now covered and we are allowing to miss those commas in the last array element when the array closer is in same line.

Fixes #76

Holding this as draft PR until PHPCSExtra 1.2.0 is released. Then we'll have to change composer.json to point to that new release and this PR will be ready.

Copy link

codecov bot commented Nov 24, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (aea4999) 96.46% compared to head (1c295bb) 96.17%.

Files Patch % Lines
moodle/Sniffs/Arrays/CommaAfterLastSniff.php 90.14% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #81      +/-   ##
============================================
- Coverage     96.46%   96.17%   -0.30%     
- Complexity      517      543      +26     
============================================
  Files            22       23       +1     
  Lines          1471     1542      +71     
============================================
+ Hits           1419     1483      +64     
- Misses           52       59       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stronk7
Copy link
Member Author

stronk7 commented Nov 29, 2023

Note: I've added a candidate commit here that proceeds to:

  • Copy the PHPCSExtra's CommaAfterLastSniff to our moodle standard.
  • Amend tests, the ruleset.xml to use our copied Sniff instead of the upstream one.
  • Make a note about that commit being reverted once PHPCSExtra releases v1.2.0 and we start using it (I will create issue if we agree that it's a good idea to advance with this alternative plan).

I've commented with the same @ #76.

(note that it's causing the code-coverage check to fail but we shouldn't mind too much. That is tested upstream in PHPCSExtra and here we are just testing the outcome for our very-own allowed multi-line arrays).

Ciao :-)

Comes with some tests to ensure that the case is now covered
and we are allowing to miss those commas in the last array
element when the array closer is in same line.

Fixes moodlehq#76
We need this applied ASAP, because it's causing troubles
with many arrays that are allowed, so we cannot wait for
PHPCSExtra v1.2.0 to be released.

So, with this commit, we are moving to own (copied verbatim)
Sniff. And adjusting tests and other small bits.

Note that this commit will be 100% reverted once PHPCSExtra
is released and then we'll be back to the upstream Sniff.

See moodlehq#82
@stronk7 stronk7 force-pushed the fix_coma_closer_same_line branch from 5ff59e5 to 1c295bb Compare November 29, 2023 16:15
@stronk7
Copy link
Member Author

stronk7 commented Nov 29, 2023

Ok, we are going ahead with this PR now. And #82 will be in charge of reverting commit 1c295bb once the fixed upstream Sniff is released.

@stronk7 stronk7 merged commit f57ae0f into moodlehq:main Nov 29, 2023
5 of 7 checks passed
@stronk7
Copy link
Member Author

stronk7 commented Nov 29, 2023

Self-merged. As commented above, the code-coverage report, missing 7 lines is ignorable, that Sniff is fully tested upstream and here we are only testing that the outcome matches Moodle coding style cases.

@stronk7 stronk7 deleted the fix_coma_closer_same_line branch November 29, 2023 16:22
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.

NormalizedArrays.Arrays.CommaAfterLast sniff is wrong for Moodle
1 participant