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

Fix gutenberg/gutenberg-coding-standards licensing issues #61913

Merged
merged 5 commits into from
Aug 12, 2024

Conversation

anton-vlasenko
Copy link
Contributor

@anton-vlasenko anton-vlasenko commented May 23, 2024

What?

This PR:

  1. removes third-party code from the gutenberg/gutenberg-coding-standards (GBCS) package and removes unused code;
  2. switches GBCS to the GPL-2.0-or-later license as it provides more freedoms and access to licensees than MIT-license code.

Why?

Ensure the package does not use any third-party code.

How?

  • change the license to GPL-2.0-or-later;
  • Remove third-party code from the SinceTagSniff::find_docblock() method;
  • Remove third-party code from the SinceTagSniff::is_function_call() method;
  • Remove the SinceTagSniff::find_hook_docblock() method and add the new find_previous_line_token() method (refactoring);
  • Fix typo in the SinceTagSniff::process() method;
  • Remove unused code from bootstrap.php and make variables use snake case;
  • Add the License section to the README.md file;

Testing Instructions

  1. Review the code changes and ensure that all CI jobs pass successfully.
  2. Navigate to test/php/gutenberg-coding-standards/.
  3. Run composer update.
  4. Run composer run check-all.
  5. Ensure there are no errors in the console.

Testing Instructions for Keyboard

Screenshots or screencast

@anton-vlasenko anton-vlasenko added the [Type] Build Tooling Issues or PRs related to build tooling label May 23, 2024
Copy link

github-actions bot commented May 23, 2024

Flaky tests detected in 2716212.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9214390920
📝 Reported issues:

@anton-vlasenko anton-vlasenko force-pushed the fix/remove-3rd-party-code-from-gbcs branch from 5d89eb5 to 71c3429 Compare May 27, 2024 15:59
@anton-vlasenko anton-vlasenko force-pushed the fix/remove-3rd-party-code-from-gbcs branch from 0d70552 to 4ce49e0 Compare June 5, 2024 17:34
@WordPress WordPress deleted a comment from github-actions bot Jun 5, 2024
Copy link

github-actions bot commented Jun 5, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: anton-vlasenko <antonvlasenko@git.wordpress.org>
Co-authored-by: rodrigoprimo <rodrigosprimo@git.wordpress.org>
Co-authored-by: azaozz <azaozz@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@anton-vlasenko anton-vlasenko force-pushed the fix/remove-3rd-party-code-from-gbcs branch from 06edf90 to f734bfd Compare June 24, 2024 13:01
Copy link
Contributor

@rodrigoprimo rodrigoprimo left a comment

Choose a reason for hiding this comment

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

Good job, @anton-vlasenko! I reviewed this PR and left a few comments. There is just one detail that might need to be addressed before merging this PR which is updating a docblock description to reflect the changes made to a method.

I checked the code changes. I don't know about the legal aspects of the licenses, so I don't know if the changes in this PR fix the licensing issues as indicated in the PR title.

@@ -65,7 +67,7 @@ public function setCliValues( $filename, $config ) {
if ( ! isset( $GLOBALS['PHP_CODESNIFFER_RULESETS']['Gutenberg'] )
|| ( ! $GLOBALS['PHP_CODESNIFFER_RULESETS']['Gutenberg'] instanceof Ruleset )
) {
throw new \RuntimeException( $error_message );
throw new \RuntimeException( $error_message ); //phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- this is non-production code.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this was not needed before and now it is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The errors likely appeared because I used composer run check-cs this time, instead of just composer run lint as I had previously done.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the additional details.

Just a nitpick, but I believe the recommended format for the ignore comment includes a space after the two forward slashes (https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file). So, // phpcs:ignore instead of //phpcs:ignore. The current version works so feel free to ignore this remark.

Also, not something to be addressed in this PR, but I wonder if composer run check-cs should be run in CI so that it is easier to catch future coding standard violations like this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know. Fixed in 333ccc1.

Also, not something to be addressed in this PR, but I wonder if composer run check-cs should be run in CI so that it is easier to catch future coding standard violations like this one?

Yes, I thought about it, and that would be the right way to do it, in my opinion.
I just don't see it as a high-priority task since there is not a lot of development happening right now (all known issues have been addressed), and it's not likely that the GBCS package will grow significantly in the near future.

@anton-vlasenko anton-vlasenko force-pushed the fix/remove-3rd-party-code-from-gbcs branch from cff54f7 to f1e6818 Compare July 19, 2024 18:03
@anton-vlasenko
Copy link
Contributor Author

Thank you for the code review, @rodrigoprimo.
I've replied to your comments. Please let me know if you have any additional notes or remarks.

Copy link
Contributor

@rodrigoprimo rodrigoprimo left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, @anton-vlasenko. I just replied to all of your comments. There is just one nitpick that I found, but feel free to ignore it.

This PR looks good to me. Similar to what I did in previous PRs that I reviewed, I'm not approving this one as I'm not part of the Gutenberg project and could be easily missing something important.

@anton-vlasenko anton-vlasenko force-pushed the fix/remove-3rd-party-code-from-gbcs branch 2 times, most recently from 4050b2c to f843b61 Compare August 9, 2024 20:36
@anton-vlasenko anton-vlasenko requested a review from azaozz August 9, 2024 21:01
Copy link
Contributor

@azaozz azaozz left a comment

Choose a reason for hiding this comment

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

As far as I see this is good to go. Using the same dual-licensing GPL and MPL as the rest of Gutenberg seems best.

- remove third-party code from the SinceTagSniff::find_docblock() method;
- remove third-party code from the SinceTagSniff::is_function_call() method;
- remove the SinceTagSniff::find_hook_docblock() method and add the new find_previous_line_token() method (refactoring);
- fix typo in the SinceTagSniff::process() method;
- remove unused code from bootstrap.php and make variables use snake case;
… environment variable in the context of Gutenberg.
@anton-vlasenko anton-vlasenko force-pushed the fix/remove-3rd-party-code-from-gbcs branch from f843b61 to ded90f0 Compare August 10, 2024 12:14
@anton-vlasenko anton-vlasenko merged commit ba8c2c0 into trunk Aug 12, 2024
60 checks passed
@anton-vlasenko anton-vlasenko deleted the fix/remove-3rd-party-code-from-gbcs branch August 12, 2024 11:06
@github-actions github-actions bot added this to the Gutenberg 19.1 milestone Aug 12, 2024
@anton-vlasenko
Copy link
Contributor Author

Thank you everyone!

getdave pushed a commit that referenced this pull request Aug 14, 2024
1. change the license to `GPL-2.0-or-later`;
2. remove third-party code from the `SinceTagSniff::find_docblock()` method;
3. remove third-party code from the `SinceTagSniff::is_function_call()` method;
4. remove the `SinceTagSniff::find_hook_docblock()` method and add the new `find_previous_line_token()` method (refactoring);
5. fix typo in the `SinceTagSniff::process()` method;
6. remove unused code from `bootstrap.php` and make variables use snake case;
7. add the `License` section to the `README.md` file.

Co-authored-by: anton-vlasenko <antonvlasenko@git.wordpress.org>
Co-authored-by: rodrigoprimo <rodrigosprimo@git.wordpress.org>
Co-authored-by: azaozz <azaozz@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Build Tooling Issues or PRs related to build tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants