- Issue created by @Charchil Khandelwal
- @charchil-khandelwal opened merge request.
- Issue was unassigned.
- Status changed to Needs review
almost 2 years ago 10:02am 1 February 2023 - 🇮🇳India Charchil Khandelwal
Created MR for the above issue.
Some warnings and errors are fixed now.
Please review. - Status changed to Needs work
almost 2 years ago 10:04am 1 February 2023 FILE: ...bc\drupal\modules\contextly\src\Contextly\ContextlyDrupalKit.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
401 | ERROR | Type hint "\ContextlyKitApiTokenInterface" missing for
| | $token
----------------------------------------------------------------------FILE: ...htdocs\abc\drupal\modules\contextly\src\ContextlyBaseService.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
346 | WARNING | NodeType::loadMultiple calls should be avoided in
| | classes, use dependency injection instead
480 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
----------------------------------------------------------------------FILE: ...ontextly\src\Controller\ContextlyAjaxEditorRequestController.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
24 | ERROR | The $_POST super global must not be accessed directly;
| | inject the request_stack service and use
| | $stack->getCurrentRequest()->request instead
----------------------------------------------------------------------FILE: ...bc\drupal\modules\contextly\src\Form\ContextlyImageAdminForm.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
65 | WARNING | NodeType::loadMultiple calls should be avoided in
| | classes, use dependency injection instead
----------------------------------------------------------------------FILE: ...abc\drupal\modules\contextly\src\Form\ContextlyTagsAdminForm.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
61 | WARNING | NodeType::loadMultiple calls should be avoided in
| | classes, use dependency injection instead
----------------------------------------------------------------------Need to fix these issues.
- Assigned to mukesh88
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 8:51am 27 March 2023 - Status changed to Needs work
over 1 year ago 1:44pm 27 March 2023 - 🇮🇹Italy apaderno Brescia, 🇮🇹
// @todo: remove if field is exist on admin form. const KIT_PATH = '/libraries/contextly-kit';
That line must be changed to and
phpcs
should have reported it.- $module_path = drupal_get_path('module', 'contextly'); - $js_path = $module_path . '/js/'; - + //$module_path = drupal_get_path('module', 'contextly'); + //$js_path = $module_path . '/js/';
The code should be removed, if it is not necessary. Why has it been commented out? What error did
phpcs
report for those lines?+ /** + * Constructs a ContextlyAjaxEditorRequestController object. + * + * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack + * The request stack. + */ + public function __construct(RequestStack $request_stack) {
The class namespace is missing.
- $params = $_POST; + $params = $this->requestStack->getCurrentRequest()->query->all();
query->all()
is the equivalent of$_GET
. It should berequest->all()
.- $node_types = NodeType::loadMultiple(); + // $node_types = NodeType::loadMultiple();
Either the code is fixed or it is left as it is. We do not comment out the lines reported by
phpcs
. - Status changed to Needs review
over 1 year ago 3:45pm 27 March 2023 - Status changed to Needs work
over 1 year ago 1:16pm 28 March 2023 - 🇮🇹Italy apaderno Brescia, 🇮🇹
Contextly.editor = { - isLoaded: false, - isLoading: false, - hasFailed: false, + isLoaded: FALSE, + isLoading: FALSE, + hasFailed: FALSE,
Those lines are already correct, since that is JavaScript code.
Then, the report shown in the issue summary is not for JavaScript files.- // @todo: remove if field is exist on admin form. + use StringTranslationTrait; + + // @todo remove if field is exist on admin form. const KIT_PATH = '/libraries/contextly-kit';
What follows
@todo
is a sentence: It starts with a capitalized word and it ends with a period.if (empty($url)) { - throw $this->kit->newDrupalException(t('Unable to generate URL for the node #@nid.', [ + throw $this->kit->newDrupalException($this->t('Unable to generate URL for the node #@nid.', [ '@nid' => $node->id(), ]));
An exception message is not translated.
- // TODO Take care about langcode. + // @todo Take care about langcode.
The correct phrase is take care of.
/** * The contextly drupal assets list class. */ -class ContextlyDrupalAssetsList extends ContextlyKitAssetsPackage { +class ContextlyDrupalAssetsList extends \ContextlyKitAssetsPackage {
Those changes are not required from the
phpcs
report. They also seem wrong./** - * Class ContextlyBaseService. + * Class provide functionality for ContextlyBaseService. */ class ContextlyBaseService implements ContextlyBaseServiceInterface, ContainerAwareInterface {
It is not necessary to start a short description with Class; rather, it should start with a verb.
/** - * Interface ContextlyBaseServiceInterface. + * Provide Interface for ContextlyBaseServiceInterface. */ interface ContextlyBaseServiceInterface {
/** - * Class ContextlyLibraryService. + * Class provide functionality for ContextlyLibraryService. */ class ContextlyLibraryService implements ContainerAwareInterface {
No, an interface doesn't provide an interface for itself, nor do a class provide functionality for itself.
- // @todo: check $node why is in url. + // @todo check $node why is in url.
Leaving out that the comment does not make sense, what follows
@todo
is a sentence: It starts with a capitalized word and it ends with a period. url is not correctly spelled, since it is an acronym.+ $entityManager = $this->container->get('entity_type.manager'); + $node_types = $entityManager->getStorage('node_type')->loadMultiple(); + // $a = $config->get();
Code is either fixed or removed; it is not commented out. That is not a change coding standards require.
/** * Description of ConditionalRoutes. * - * @author dj + * Author dj. */ class ConditionalRoutes {
Actually, the existing line is correct.
@author
is a tag and it spelled like that. It is Drupal that does not use that tag, but in that case it should be removed.
If anything needs to be changed, that is the short description. - Status changed to Needs review
over 1 year ago 12:38pm 29 March 2023 - 🇮🇳India TanujJain-TJ
Adding a new patch addressing points from #11, please review.
-
dj1999 →
committed 09c3f0c1 on 8.x-2.x authored by
Charchil Khandelwal →
Issue #3338193: Drupal Coding Standards Issues | phpcs
-
dj1999 →
committed 09c3f0c1 on 8.x-2.x authored by
Charchil Khandelwal →
- Status changed to Fixed
over 1 year ago 1:51pm 3 August 2023