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

Setup phpcs #43

Open
hfiguiere opened this issue Oct 23, 2024 · 9 comments
Open

Setup phpcs #43

hfiguiere opened this issue Oct 23, 2024 · 9 comments
Milestone

Comments

@hfiguiere
Copy link
Collaborator

Setup phpcs and enforce the Drupal code style.

References https://www.drupal.org/docs/extending-drupal/contributed-modules/contributed-module-documentation/coder/installing-coder

@hfiguiere hfiguiere added this to the 0.9.0-beta6 milestone Oct 25, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 8, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 11, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 11, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 11, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 11, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 11, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 11, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 11, 2024
hfiguiere pushed a commit that referenced this issue Nov 15, 2024
hfiguiere pushed a commit that referenced this issue Nov 15, 2024
hfiguiere pushed a commit that referenced this issue Nov 15, 2024
hfiguiere pushed a commit that referenced this issue Nov 15, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 15, 2024
donquixote added a commit to donquixote/collabora-drupal that referenced this issue Nov 15, 2024
@hfiguiere
Copy link
Collaborator Author

Now all we need is to remove the loosened rules as we go.

@donquixote
Copy link
Collaborator

The indentation change from 4 chars to 2 chars will be quite disruptive, it will touch every line of code.
We should do it once other PRs are merged that still work with 4 chars.

Another thing is the "Copyright" comment at the top of files.
I know that some other projects do it (symfony), but Drupal projects generally don't.

I am actually not sure about the implication of doing or not doing it.
I have found different discussions, like these:
https://softwareengineering.stackexchange.com/questions/125836/do-you-have-to-include-a-license-notice-with-every-source-file
https://opensource.stackexchange.com/questions/292/should-i-include-a-copyright-line-in-every-file

I was curious about the history of this in Drupal, but all I found was this discussion:
https://www.drupal.org/project/drupal/issues/174226

I have not heard of any cases where the lack of a copyright notice in a source file caused problems.
But what do I know :)

@hfiguiere
Copy link
Collaborator Author

The indentation change from 4 chars to 2 chars will be quite disruptive, it will touch every line of code. We should do it once other PRs are merged that still work with 4 chars.

There is no open PR right now. So this could be the time.

Another thing is the "Copyright" comment at the top of files. I know that some other projects do it (symfony), but Drupal projects generally don't.

I am actually not sure about the implication of doing or not doing it. I have found different discussions, like these: https://softwareengineering.stackexchange.com/questions/125836/do-you-have-to-include-a-license-notice-with-every-source-file https://opensource.stackexchange.com/questions/292/should-i-include-a-copyright-line-in-every-file

I was curious about the history of this in Drupal, but all I found was this discussion: https://www.drupal.org/project/drupal/issues/174226

I have not heard of any cases where the lack of a copyright notice in a source file caused problems. But what do I know :)

This is just consistency with what we do at Collabora. Including git "signoff", etc.
I believe the use of SPDX like SPDX-License-Identifier is great because it allow mechanically checking license compliance by being able to audit automatically the license of individual assets / source files. And it's better to do from the get go.

@Kingdutch
Copy link
Contributor

The copyright comment is not included in Drupal projects because when hosting code on Drupal.org and distributing it through Drupal's packagist it must be relicensed using GPL2 or later. See https://www.drupal.org/about/licensing#gpl-compatible and the rest of the documentation on that page.

This also means that in its current form the Collabora module is not adhering to the Drupal licenses and terms. As per point 9 (https://www.drupal.org/about/licensing#project-licensing) I'm not sure whether the way of distributing even matters or just the fact "it's a Drupal module" (although I think in how composer and PHP work these days that might be an interesting claim to contest).

That may be something Collabora wants to discuss internally to see whether relicensing their Drupal module through GPL2 or later is an option.

@donquixote
Copy link
Collaborator

Hello @Kingdutch !
Thank you for the link, I had not read that in detail before.

Still, I don't see that GPL2 would universally imply that you don't put a copyright header per file.
There was even this discussion long time ago, which lead to a copyright notice in index.php.
https://www.drupal.org/project/drupal/issues/174226

Personally I am fine to just follow the convention and drop the copyright notice per file.
But I am still curious.

AaronGilMartinez pushed a commit to donquixote/collabora-drupal that referenced this issue Nov 25, 2024
AaronGilMartinez pushed a commit to donquixote/collabora-drupal that referenced this issue Nov 25, 2024
AaronGilMartinez pushed a commit to donquixote/collabora-drupal that referenced this issue Nov 25, 2024
AaronGilMartinez pushed a commit to donquixote/collabora-drupal that referenced this issue Nov 25, 2024
AaronGilMartinez pushed a commit to donquixote/collabora-drupal that referenced this issue Nov 25, 2024
AaronGilMartinez pushed a commit to donquixote/collabora-drupal that referenced this issue Nov 25, 2024
Issue CollaboraOnline#43: Introduce phpcs, add meaningful doc comments.
@hfiguiere
Copy link
Collaborator Author

IANAL

But MPL-2.0 states:

3.3. Distribution of a Larger Work

You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s).

So as a Drupal + this module, it's covered by GPL-2.0

1.12. “Secondary License”

means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses.

Source: https://www.mozilla.org/en-US/MPL/2.0/

@donquixote
Copy link
Collaborator

I am still not sure about the conclusion here.

I think we don't really have an issue with the license, only whether a copyright notice needs to be repeated per file or not. Even if we would change that notice to say GPL2.

Btw we did miss to add that notice in recent PRs, so here is a PR that would re-add it:

@donquixote
Copy link
Collaborator

IANAL either..
So here is my intermediate conclusion:

  • Anybody (including drupal.org packaging script) can re-license under GPL2, but they must keep the MPL, so that in essence it will have two licenses. Currently the zip file from drupal.org will contain LICENSE and LICENSE.txt, one for MPL and one for GPL2.
  • The file headers in the zip from drupal.org currently only mention the MPL, which matches the "Unmodified MPL-licensed Files - MPL-only" case from https://www.mozilla.org/en-US/MPL/2.0/combining-mpl-and-gpl/.
  • A copyright holder could, if they want to, replace the license, as long as they fully own the work. Any older version obtained by others still has the old license.
  • If the work contains contributions from others, these can be assumed to have contributed with the expectation that the thing will be licensed as MPL. At that point, after accepting these contributions, the original copyright holder can no longer freely change the license.

For now we will just continue with the file headers as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants