It's commonly assumed that a contributed module's project name matches the machine name of the module. (IE the actual filename, etc.).

I propose that this should be a standard, as it's commonly assumed, and creates issues when it's not the case. For example:

https://www.drupal.org/node/427770
https://www.drupal.org/node/1730182
https://www.drupal.org/node/467944
https://www.drupal.org/node/2404827

A project can have more than one module in it - EG views and views_ui. One module is typically the main module though, so I think it would be reasonable to make the standard something along the lines of: "A project which is a module should contain a module with a machine name matching the project's machine name."

This is about creating a policy that recommends (or even eventually enforces) consistency, but only once a developer has decided what the project name is: it's not about saying what they should and shouldn't call their project.

Comments

rupertj created an issue. See original summary.

autopoietic’s picture

Possibly impractical, but would it also be helpful to suggest that submodules followed some sort of naming convention to avoid namespace conflicts?

eg

  • views, views_ui
  • mymodule, mymodule_doesanothercleverthing, mymodule_ui
pfrenssen’s picture

I think naming conventions for projects are probably out of scope for the coding standards.

rupertj’s picture

Could you suggest a better location? Out of all the possible issue queues I could have put this in, it felt like the best one, although I'll admit I wasn't totally convinced it was the correct place.

jp.stacey’s picture

I also think it's worth clarifying (maybe in the description?) that this issue isn't about naming conventions so much; the original proposal, stripped of e.g. views_ui suggestions, is:

"A project which is a module should contain a module with a machine name matching the project's machine name."

This is really about a policy that recommends (or even eventually enforces) consistency, but only once the developer has decided what the project name is: it's not about saying what they should and shouldn't call their project.

rupertj’s picture

Issue summary: View changes

Good point. Added that.

pfrenssen’s picture

Project: Coding Standards » Documentation
Component: Coding Standards » Policies and Procedures

Could you suggest a better location? Out of all the possible issue queues I could have put this in, it felt like the best one, although I'll admit I wasn't totally convinced it was the correct place.

I think this is something for the documentation queue. The current documentation for creating full projects is Creating a new full project, so that's where the decision will be documented. I will move this to the documentation queue.

I am in favor of this proposal, but we have to be realistic that this can only be a guideline and it will be impossible to enforce after the fact for backwards compatibility reasons.

  • Once a project has been published with a wrong name it cannot change it except in a new major release. Changing a module name breaks all existing implementations. This is why for example the Google Analytics project has only been willing to fix their name in the Drupal 8 version.
  • It is technically possible to enforce this rule but it is not practical. We would have to write a pre-receive git hook that inspects every commit to see if there is at least one .info.yml file present that matches the project shortname and reject the commit if it doesn't. There is significant overhead involved with this and I don't think our infrastructure team would be willing to accept this. There are so few projects that violate this rule that the disadvantages greatly outweigh the benefits.
  • Not all projects are modules or themes, so it is not guaranteed that every project has a .info.yml file. One famous example is Coder.

That said, it would be a really really good idea to put this clearly in the documentation for creating new projects.

apaderno’s picture

Title: [Policy] Module name should match project name for contrib modules. » [Policy] Module name should match project name for contrib modules