- First commit to issue fork.
- Status changed to Needs work
almost 2 years ago 6:50am 3 February 2023 - ๐ฎ๐ณIndia hardikpandya
I have fixed all phpcs issues apart from .module file issues as I was not sure how to change the static variables defined there. Marking this as `Needs Work` so that someone can pick that up and complete this.
- Assigned to himanshu_jhaloya
- ๐ฎ๐ณIndia himanshu_jhaloya Indore
Fixed phpcs issues applied the patch please review.
- ๐ฎ๐ณIndia Sonal Gyanani
Applying patch #6, but still shows the following error
FILE: ...ues-9.5.x-dev\modules\image_widget_crop\image_widget_crop.module ---------------------------------------------------------------------- FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES ---------------------------------------------------------------------- 8 | WARNING | Global constants should not be used, move it to a | | class or interface 9 | WARNING | Global constants should not be used, move it to a | | class or interface 34 | ERROR | All functions defined in a module file must be | | prefixed with the module's name, found | | "image_widget_cropfield_widget_info_alter" but | | expected | | "image_widget_crop_image_widget_cropfield_widget_info_alter"
- Issue was unassigned.
- ๐ฎ๐ณIndia sahil.goyal
Applying patch for address remaining errors.
- Status changed to Needs review
almost 2 years ago 6:01am 23 February 2023 - ๐ฎ๐ณIndia Akram Khan Cuttack, Odisha
Checked #10 patch it applied smoothly and remove all PHPCS issue now great work by @sahil.goyal . so move to RTBC
- Status changed to RTBC
almost 2 years ago 6:01am 23 February 2023 - Status changed to Needs work
over 1 year ago 11:49am 13 May 2023 - ๐ฎ๐นItaly apaderno Brescia, ๐ฎ๐น
The issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, show which command and arguments have been used, and which report that command shown.
- Assigned to nitin_lama
- Issue was unassigned.
- Assigned to arti_parmar
- ๐ฎ๐นItaly apaderno Brescia, ๐ฎ๐น
- * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory + * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
Code can use a local variable named
$config_factory
. (A method parameter is still a local variable.)Variables should be named using lowercase, and words should be separated either with uppercase characters (example:
$lowerCamelCase
) or with an underscore (example:$snake_case
). Be consistent; do not mix camelCase and snake_case variable naming inside a file.+ * @param \Drupal\Core\Entity\EntityTypeManager $entityTypeManager + * The entity type manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity + * The Entity type manager service. */ - public function __construct(ConfigFactoryInterface $config_factory, FileUsageInterface $file_usage, ImageWidgetCropInterface $iwc_manager) { - parent::__construct($config_factory); + public function __construct(ConfigFactoryInterface $configFactory, FileUsageInterface $file_usage, ImageWidgetCropInterface $iwc_manager, EntityTypeManager $entityTypeManager, EntityTypeManagerInterface $entity) { + parent::__construct($configFactory); $this->settings = $this->config('image_widget_crop_examples.settings'); + $this->entityTypeManager = $entityTypeManager;
As per Drupal coding standards:
[D]o not mix camelCase and snake_case variable naming inside a file
- last update
over 1 year ago 4 pass - ๐ฎ๐ณIndia AkashKumar07
The patch addresses the #19 suggestions. Please review.
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 5:16am 23 June 2023 - Assigned to agunjan085
- Issue was unassigned.
- Status changed to RTBC
over 1 year ago 5:51am 23 June 2023 - ๐ฎ๐ณIndia agunjan085
Hi AkashKumar07
I applied your patch 3333260-20.patch to my local and I confirmed that it fixes all the PHPCS issues.
Please look at the screenshot attached for your reference
Thank you
- Status changed to Needs work
over 1 year ago 4:37pm 23 June 2023 - ๐ฎ๐นItaly apaderno Brescia, ๐ฎ๐น
/** * Implements hook_field_widget_info_alter(). */ -function image_widget_cropfield_widget_info_alter(array &$info) { +function image_widget_crop_widget_info_alter(array &$info) {
Since that is code in the image_widget_crop.module file and the hook is
hook_field_widget_info_alter()
, the correct function name isimage_widget_crop_field_widget_info_alter()
, notimage_widget_crop_widget_info_alter()
.- $js = IMAGE_WIDGET_CROP_JS_CDN; + $js = 'https://cdnjs.cloudflare.com/ajax/libs/cropper/4.0.0/cropper.min.js';
There is nothing wrong in using a constant, even if it would be better to define it with
const
. Actually, the Drupal coding standards says:In Drupal 8 and later, constants should be defined using the
const
PHP language keyword (instead ofdefine()
), because it is better for performance:/** * Indicates that the item should be removed at the next general cache wipe. */ const CACHE_TEMPORARY = -1;
Note that
const
does not work with PHP expressions.define()
should be used when defining a constant conditionally or with a non-literal value:if (!defined('MAINTENANCE_MODE')) { define('MAINTENANCE_MODE', 'error'); }
+ /** + * Constructs a CropWidgetForm object. + *
The class namespace is missing from the description.
+- * @param \Drupal\Core\Image\ImageFactory $imageFactory ++ * @param \Drupal\Core\Image\ImageFactory $image_factory
That part is adding extra
-
and+
.+- public function __construct(EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory, ImageFactory $imageFactory) { ++ public function __construct(EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory, ImageFactory $image_factory) { + $this->entityTypeManager = $entity_type_manager; + $this->cropStorage = $this->entityTypeManager->getStorage('crop'); + $this->cropTypeStorage = $this->entityTypeManager->getStorage('crop_type'); + $this->imageStyleStorage = $this->entityTypeManager->getStorage('image_style'); + $this->fileStorage = $this->entityTypeManager->getStorage('file'); + $this->imageWidgetCropSettings = $config_factory->get('image_widget_crop.settings'); +- $this->imageFactory = $imageFactory; ++ $this->imageFactory = $image_factory;
Drupal coding standards allow to name a local variable
$image_factory
. It is the class properties that should be named$imageFactory
.
Also, that change is still adding extra-
and+
.+ /** + * Drupal\Core\Entity\EntityTypeManager definition. + * + * @var \Drupal\Core\Entity\EntityTypeManager + */ + protected $entityTypeManager;
A property description does not repeat its type.
+ /** + * The storage handler class for files. + * + * @var \Drupal\file\FileStorage + */ + private $fileStorage;
The file storage. is sufficient.
+ * @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager + * The entity type manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity + * The Entity type manager service. */ - public function __construct(ConfigFactoryInterface $config_factory, FileUsageInterface $file_usage, ImageWidgetCropInterface $iwc_manager) { + public function __construct(ConfigFactoryInterface $config_factory, FileUsageInterface $file_usage, ImageWidgetCropInterface $iwc_manager, EntityTypeManager $entity_type_manager, EntityTypeManagerInterface $entity) { parent::__construct($config_factory); $this->settings = $this->config('image_widget_crop_examples.settings'); + $this->entityTypeManager = $entity_type_manager; $this->fileUsage = $file_usage; $this->imageWidgetCropManager = $iwc_manager; + $this->fileStorage = $entity->getStorage('file'); }
Something is wrong in that definition. Why would a method get a
\Drupal\Core\Entity\EntityTypeManager
parameter and a\Drupal\Core\Entity\EntityTypeManagerInterface
parameter, sinceEntityTypeManagerInterface
is the interface implemented by theEntityTypeManager
class?
By the name,$entity
is an entity object. Entity classes do not implementEntityTypeManagerInterface
.- $this->messenger()->addMessage($this->t('The crop "@cropType" was successfully updated for image "@filename".', ['@cropType' => $crop_type->label(), '@filename' => $this->fileStorage->load($field_value['file-id'])->getFilename()])); + $this->messenger()->addMessage($this->t('The crop "@cropType" was successfully updated for image "@filename".', + [ + '@cropType' => $crop_type->label(), + '@filename' => $this->fileStorage->load($field_value['file-id'])->getFilename(), + ])); }
I would leave that code as it is, since it is simpler to understand.
- // If file-id key is not available, set it same as parent elements target_id + // If file-id key is not available, + // set it same as parent elements target_id.
If the file ID key has not been set, set it to the parent elements target ID.
- // Parse all value of a crop_wrapper element and get properties - // associate with her CropType. + // Parse all value of a crop_wrapper element and get properties. foreach ($crop_element['crop_wrapper'] as $crop_type_name => $properties) { $properties = $properties['crop_container']['values'];
I would rather remove that comment, since it is not true the code is parsing values. It is looping over an array, but that does not need any explanation: Every developer knows what
foreach()
does in PHP. - First commit to issue fork.
- last update
over 1 year ago 2 pass, 1 fail - ๐ฎ๐นItaly apaderno Brescia, ๐ฎ๐น
The report is not updated for the recent changes in the ruleset. It also reports errors that are not present in the project files.
- First commit to issue fork.
- last update
about 1 year ago 2 pass, 1 fail - First commit to issue fork.
- last update
12 months ago 2 pass, 1 fail - Status changed to Needs review
12 months ago 1:58pm 28 December 2023 - last update
12 months ago Patch Failed to Apply - Status changed to Needs work
7 months ago 12:31pm 6 June 2024 Hi @sakthi_dev,
Applied MR !15 successfully, but it threw multiple errors.
image_widget_crop git:(c42c4e6) curl https://git.drupalcode.org/project/image_widget_crop/-/merge_requests/15.diff | patch -p1 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 17786 0 17786 0 0 32933 0 --:--:-- --:--:-- --:--:-- 33621 patching file image_widget_crop.module patching file image_widget_crop.services.yml patching file modules/image_widget_crop_examples/src/Form/ImageWidgetCropExamplesForm.php patching file src/Element/ImageCrop.php patching file src/Form/CropWidgetForm.php patching file src/ImageWidgetCropManager.php patching file src/Plugin/Field/FieldWidget/ImageCropWidget.php patching file tests/src/FunctionalJavascript/ImageWidgetCropTest.php โ image_widget_crop git:(c42c4e6) โ cd .. โ contrib git:(master) โ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig image_widget_crop FILE: /Users/PrometInterns/Demo-site/drupal-orgissue-v9/web/modules/contrib/image_widget_crop/image_widget_crop.module ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 8 | WARNING | Global constants should not be used, move it to a class or interface 9 | WARNING | Global constants should not be used, move it to a class or interface 34 | ERROR | All functions defined in a module file must be prefixed with the module's name, found "image_widget_cropfield_widget_info_alter" but expected | | "image_widget_crop_image_widget_cropfield_widget_info_alter" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- FILE: /Users/PrometInterns/Demo-site/drupal-orgissue-v9/web/modules/contrib/image_widget_crop/modules/image_widget_crop_examples/src/Form/ImageWidgetCropExamplesForm.php ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- FOUND 1 ERROR AFFECTING 1 LINE ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 55 | ERROR | Missing short description in doc comment ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- FILE: /Users/PrometInterns/Demo-site/drupal-orgissue-v9/web/modules/contrib/image_widget_crop/src/Form/CropWidgetForm.php --------------------------------------------------------------------------------------------------------------------------------------- FOUND 1 ERROR AFFECTING 1 LINE --------------------------------------------------------------------------------------------------------------------------------------- 10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Extension\ModuleHandlerInterface. --------------------------------------------------------------------------------------------------------------------------------------- PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY --------------------------------------------------------------------------------------------------------------------------------------- FILE: /Users/PrometInterns/Demo-site/drupal-orgissue-v9/web/modules/contrib/image_widget_crop/src/ImageWidgetCropInterface.php ------------------------------------------------------------------------------------------------------------------------------ FOUND 1 ERROR AFFECTING 1 LINE ------------------------------------------------------------------------------------------------------------------------------ 58 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter ------------------------------------------------------------------------------------------------------------------------------ PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY ------------------------------------------------------------------------------------------------------------------------------ Time: 1.02 secs; Memory: 14MB
Kindly check.
Thanks,
Jake- last update
7 months ago 2 pass, 1 fail - ๐ญ๐บHungary Balu Ertl Budapest ๐ช๐บ
Balu Ertl โ made their first commit to this issueโs fork.
- Status changed to Needs review
5 months ago 8:24pm 8 July 2024 - ๐ญ๐บHungary Balu Ertl Budapest ๐ช๐บ
- It took more time to dig it up than expected, but finally, PHPUnit tests are working again after not being run for 1,5 years ago โ .
PHPCS
,Stylelint
, andcomposer-lint
are all green.- I didn't touch
eslint
as JavaScript falls out of my expertise.Cspell
andPHPStan
also could be improved, but they should be good to go for now, I think. - @apaderno โ 's comments went through and fixed those which was still unresolved.
- Status changed to RTBC
about 1 month ago 1:31pm 14 November 2024 - ๐ณ๐ฑNetherlands eelkeblok Netherlands ๐ณ๐ฑ
I scanned through the changes and didn't seen anything major. If there are any left-over concerns, I would advocate for getting the Gitlab and test-changes in first, and then creating follow-up issues for the various linters. I just spent about half an hour hunting down tests breaking in the module because I wanted to try to get ๐ Crop widget not adjusting crop box when crop is applied Needs work over the last hump by writing a test. I first found out tests haven't been running since there is no Gitlab integration and then I found this issue...
- ๐ซ๐ทFrance dqd London | N.Y.C | Paris | Hamburg | Berlin
Thanks for all the hard work in here! Gitlab CI file has been added by Drupal 11 compatibility issue merged into 8.x-2.x dev yesterday and this issue here is one commit behind with conflicts, but only 2 of them really required to look at. Can we please resolve the conflicts so that I can commit asap? https://git.drupalcode.org/project/image_widget_crop/-/merge_requests/15... It is actually just some example and test code which differs and needs to be looked at and a careful decision which variant of change to keep.