$ phpcs --standard=Drupalpractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml maxlength/

FILE: C:\Users\SI-001\Downloads\maxlength\src\WidgetSettings.php
---------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
57 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------

Time: 250ms; Memory: 6MB

Issue fork maxlength-3295118

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Rakhi Soni created an issue. See original summary.

rakhi soni’s picture

Assigned: rakhi soni » Unassigned
Status: Active » Needs review
StatusFileSize
new1.39 KB

Kindly review patch,,

akshaydalvi212’s picture

Assigned: Unassigned » akshaydalvi212

Hello @Rakhi Soni,

I will review this patch.

Thanks & regards

akshaydalvi212’s picture

Status: Needs review » Active
StatusFileSize
new83.51 KB

Hello @Rakhi Soni,

After applying the patch, getting some drupal coding standard errors as follows:

I will update the patch which will eliminate the Drupal coding standard errors for the module.

Thanks & regards.

akshaydalvi212’s picture

Assigned: akshaydalvi212 » Unassigned
Status: Active » Needs review
StatusFileSize
new5.71 KB

Hello,

Providing the updated patch, kindly review it and provide your feedback.

Thanks & regards.

atul_ghate’s picture

Assigned: Unassigned » atul_ghate

Hi,
i will review this patch

atul_ghate’s picture

Assigned: atul_ghate » Unassigned
Status: Needs review » Reviewed & tested by the community

This patch resolves all the issues mentioned above#5 changing its status to RTBC

hipp2bsquare’s picture

Status: Reviewed & tested by the community » Needs work

Thank you Rakhi and akshaydalvi212 for your work on this and atul for testing.

After applying this patch to the current dev release, attempting to access a Manage form display page for a content type with fields that utilize the Maxlength widget results in the following error:

The website encountered an unexpected error. Please try again later.
ArgumentCountError: Too few arguments to function Drupal\maxlength\WidgetSettings::__construct(), 0 passed in /app/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 262 and exactly 1 expected in Drupal\maxlength\WidgetSettings->__construct() (line 26 of modules/dev/maxlength/src/WidgetSettings.php).

Can you please take a look?

anoopsingh92’s picture

Assigned: Unassigned » anoopsingh92

Hi @hipp2bsquare,

I am looking into this. Thanks for info the given the error.

Thanks

anoopsingh92’s picture

StatusFileSize
new56.25 KB

Hello

Your patch has been applied successfully.


Lenovo@LAPTOP-PDE747K8 MINGW64 /c/xampp/htdocs/drupal-9/web/modules/contrib/maxlength-3295118 (3295118-drupal-calls-should)
$ git apply -v Drupal-coding-standards-3295118-5.patch
Drupal-coding-standards-3295118-5.patch:9: trailing whitespace.
Maxlength allows site administrators to set hard or soft character
Drupal-coding-standards-3295118-5.patch:19: trailing whitespace.
The Maxlength module helps website authors write concisely
Drupal-coding-standards-3295118-5.patch:20: trailing whitespace.
to better connect with their audiences and adhere
Drupal-coding-standards-3295118-5.patch:30: trailing whitespace.
* To submit bug reports and feature suggestions,
Drupal-coding-standards-3295118-5.patch:40: trailing whitespace.
Install the Maxlength module as you would normally
Checking patch README.md...
Checking patch css/maxlength.css...
Checking patch maxlength.module...
Checking patch maxlength.services.yml...
Checking patch src/WidgetSettings.php...
Applied patch README.md cleanly.
Applied patch css/maxlength.css cleanly.
Applied patch maxlength.module cleanly.
Applied patch maxlength.services.yml cleanly.
Applied patch src/WidgetSettings.php cleanly.
warning: squelched 4 whitespace errors
warning: 9 lines add whitespace errors.

Thanks for the patch.

anoopsingh92’s picture

There is no error So now I am moving it to RTBC.

Thanks

anoopsingh92’s picture

Assigned: anoopsingh92 » Unassigned
Status: Needs work » Reviewed & tested by the community
anoopsingh92’s picture

StatusFileSize
new135.28 KB
new40.25 KB
new131.6 KB

Hello @hipp2bsquare,

I have installed this module and configured the settings of Maxlength It is working fine for me I didn't get this error
The website encountered an unexpected error. Please try again later.

I have attached the screenshots for more clarification.

Thanks

hipp2bsquare’s picture

Status: Reviewed & tested by the community » Needs work

Negative. The patch applies fine but the error still exists.

Steps to reproduce:

  1. Install the patched module.
  2. Go to any content type form display config page, eg /admin/structure/types/manage/page/form-display
hipp2bsquare’s picture

Assigned: Unassigned » cedewey

I'm consistently experiencing this issue when applying this patch to multiple sites running Drupal 9.4.2 Turning this over to CEDewey to confirm.

cedewey’s picture

Assigned: cedewey » Unassigned

I just tested the patch and unfortunately I am also getting the errorArgumentCountError: Too few arguments to function Drupal\maxlength\WidgetSettings::__construct()

I tested this on the main branch of Drupal 9.5.0-dev

adaucyj’s picture

Assigned: Unassigned » adaucyj

I'll work on it.

adaucyj’s picture

Assigned: adaucyj » Unassigned
Status: Needs work » Needs review
StatusFileSize
new253 bytes
new5.75 KB

Could someone review it, please?

mauryarahul11’s picture

Status: Needs review » Needs work

Thanks @adaucyj for the patch, After applying it, i got the following phpcs errors in js files. Hence moving it to Needs Work.

FILE: /maxlength/js/maxlength.js
---------------------------------------------------------------------
FOUND 39 ERRORS AFFECTING 34 LINES
---------------------------------------------------------------------
   8 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
  20 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  25 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
  50 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
  98 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 102 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 115 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 115 | ERROR | [x] Expected 1 space before opening brace; found 0
 126 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 140 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
 149 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 196 | ERROR | [x] Expected 1 space before "+"; 0 found
 196 | ERROR | [x] Expected 1 space after "+"; 0 found
 199 | ERROR | [x] Case breaking statements must be followed by a single blank line
 218 | ERROR | [x] Case breaking statements must be followed by a single blank line
 233 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 243 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
 274 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 277 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 283 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
 289 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 293 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 294 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 298 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 300 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
 303 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 304 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 304 | ERROR | [x] Expected 1 space before opening brace; found 0
 306 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 307 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 307 | ERROR | [x] Expected 1 space before opening brace; found 0
 309 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 310 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 310 | ERROR | [x] Expected 1 space before opening brace; found 0
 317 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 324 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 329 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 339 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 342 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
---------------------------------------------------------------------

lets also include js file exension in phpcs command.

abhijith s’s picture

StatusFileSize
new13.98 KB
new8.13 KB

Fixed the remaining issues mentioned in #19 .

abhijith s’s picture

Status: Needs work » Needs review
emarinho’s picture

Assigned: Unassigned » emarinho

I'll review it!

adaucyj’s picture

Hi, @mauryarahul11. Thanks for the review. As we can see at issue description, its scope is only implements the dependence injection. Maybe there is already a issue created regarding the code standards in the JS file. To keep this issue purpose and avoid conflicts with others issues, would like to suggest use the patch that only corrects the error for what this task was created. We could also change this issue scope (if there is no other issue related) or create a child issue to solve the phpcs in JS files.

emarinho’s picture

Assigned: emarinho » Unassigned
Status: Needs review » Reviewed & tested by the community

Everything works properly when applying patch in #18, however I think that the .js phpcs errors should be handled as @adaucyj mentioned before, maybe creating a child issue seems to be better.

mauryarahul11’s picture

Title: \Drupal calls should be avoided in classes, use dependency injection instead » \Drupal calls should be avoided in classes, use dependency injection instead and coding standards

just updated the issue title to accommodate code standards issue in this issue only.

Thanks!

  • hipp2bsquare committed 8f09eb0 on 2.0.x
    Issue #3295118 by anoopsingh92, adaucyj, akshaydalvi212, Abhijith S,...
hipp2bsquare’s picture

Status: Reviewed & tested by the community » Fixed

Thank you everyone for your work on this issue. This patch has been committed. There are certainly coding standards issues with the JS. However work will soon begin on a CKEditor 5-compatible version of Maxlength, which will include a refactoring of the project's JavaScript. However, do feel welcome to open an issue and submit your patch for the JS standards refactoring, so that it can be reviewed and tested by the community.

Status: Fixed » Closed (fixed)

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