PHPCS: not in lowerCamel format error (ckeditor5)

Created on 17 April 2023, almost 2 years ago
Updated 20 April 2023, almost 2 years ago

Problem/Motivation

Showing phpcs error while running it against CKEditor4To5Upgrade(Drupal\ckeditor5\Plugin\CKEditor4To5UpgradePluginInterface) custom plugins.

Steps to reproduce

Running $ vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /path-to-custom-module shows phpcs error if there is a custom CKEditor4To5Upgrade(CKEditor4To5UpgradePluginInterface) custom plugin.

FOUND 3 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------------------------------------------------------------
47 | ERROR | Public method name "CustomCkeditor5::mapCKEditor4ToolbarButtonToCKEditor5ToolbarItem" is not in lowerCamel format
90 | ERROR | Public method name "CustomCkeditor5::mapCKEditor4SettingsToCKEditor5Configuration" is not in lowerCamel format
97 | ERROR | Public method name "CustomCkeditor5::computeCKEditor5PluginSubsetConfiguration" is not in lowerCamel format
---------------------------------------------------------------------------------------------------------------------------------

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

💬 Support request
Status

Fixed

Version

9.5

Component
CKEditor 5 

Last updated 5 days ago

Created by

🇮🇳India praveenpb Bangalore

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India praveenpb Bangalore

    Hi cilefen, Thanks for your quick response.

    Please find the details below. It seems "Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps" triggering here.

    FOUND 3 ERRORS AFFECTING 3 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    47 | ERROR | Public method name "CustomCkeditor5::mapCKEditor4ToolbarButtonToCKEditor5ToolbarItem" is not in lowerCamel format
    | | (Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps)Files.TxtFileLineLength.TooLong)
    90 | ERROR | Public method name "CustomCkeditor5::mapCKEditor4SettingsToCKEditor5Configuration" is not in lowerCamel format
    | | (Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps)Files.TxtFileLineLength.TooLong)
    97 | ERROR | Public method name "CustomCkeditor5::computeCKEditor5PluginSubsetConfiguration" is not in lowerCamel format
    | | (Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps)

  • @longwave Thank you for locating that issue. What is the scoping for standards fixes? Is this a duplicate?

  • Status changed to Postponed: needs info almost 2 years ago
  • 🇳🇿New Zealand quietone

    The error shows this failing on the sniff "Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps)" which is not enabled in not in the set of standards used by core and neither is "Drupal.NamingConventions.ValidFunctionName".
    That points to this being a configuration error, that is, if one wants to use the same coding standards as core.

    Oh, I see the command is using the 'Drupal' standard which is not what core does.

    @praveenpb, Can you change your command to use the same standard as core --standard="core/phpcs.xml.dist" and report back? The full details of what core does can be found in core/scripts/dev/commit-code-check.sh.

    Thanks

  • 🇬🇧United Kingdom longwave UK

    So the issue here is that core does not follow a particular standard, but custom code that does want to follow all standards is affected by this, because the non-compliant interface methods provided by core are implemented in the custom code. Not sure what we should do about this.

  • 🇮🇳India praveenpb Bangalore

    When I run it with --standard="core/phpcs.xml.dist", it doesn't throw any errors.
    So my questions are,

    1. Which one is the recommended standard to follow with custom code?
    2. Is it fine if we follow what core follows? Otherwise we may face such issues if we implement non-compliant interface methods provided by core right?

    Thanks

  • Status changed to Fixed almost 2 years ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Is it fine if we follow what core follows?

    Yes, that's what I would recommend. In your contrib modules, you can reuse Drupal core's coding standards by running phpcs like this: https://git.drupalcode.org/project/automatic_updates/-/blob/3.0.x/script....

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024