- Issue created by @dharmendra-virasat
- 🇮🇳India vishal.kadam Mumbai
Thank you for applying!
Please read Review process for security advisory coverage: What to expect → for more details and Security advisory coverage application checklist → to understand what reviewers look for. Tips for ensuring a smooth review → gives some hints for a smoother review.
The important notes are the following.
- If you have not done it yet, you should run
phpcs --standard=Drupal,DrupalPractice
on the project, which alone fixes most of what reviewers would report. - For the time this application is open, only your commits are allowed.
- The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status won't be changed by this application and no other user will be able to opt projects into security advisory policy.
- We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.
To the reviewers
Please read How to review security advisory coverage applications → , Application workflow → , What to cover in an application review → , and Tools to use for reviews → .
The important notes are the following.
- It is preferable to wait for a Code Review Administrator before commenting on newly created applications. Code Review Administrators will do some preliminary checks that are necessary before any change on the project files is suggested.
- Reviewers should show the output of a CLI tool → only once per application.
- It may be best to have the applicant fix things before further review.
For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues → .
- If you have not done it yet, you should run
- 🇮🇹Italy apaderno Brescia, 🇮🇹
Remember to change status, as in this queue Active means the project is not ready to be reviewed.
- Status changed to Needs review
about 1 year ago 12:35pm 13 September 2023 - Status changed to Needs work
about 1 year ago 1:58pm 16 September 2023 - 🇮🇳India vinaymahale
Please fix the below PHPCS errors:
FILE: /opigno_lp_create/src/OpignoLPManager.php --------------------------------------------------------------------------------------- FOUND 1 ERROR AFFECTING 1 LINE --------------------------------------------------------------------------------------- 63 | ERROR | Type hint "\Drupal\Core\Form\FormStateInterface" missing for $form_state --------------------------------------------------------------------------------------- FILE: /opigno_lp_create/src/Form/CreateModuleForm.php ------------------------------------------------------------------------------------------ FOUND 1 ERROR AFFECTING 1 LINE ------------------------------------------------------------------------------------------ 43 | ERROR | Type hint "array" missing for $plugin_definition ------------------------------------------------------------------------------------------
- Status changed to Needs review
about 1 year ago 6:04am 18 September 2023 - Status changed to Needs work
about 1 year ago 11:36am 28 September 2023 - 🇮🇹Italy apaderno Brescia, 🇮🇹
- What follows is a quick review of the project; it doesn't mean to be complete
- For each point, the review usually shows some lines that should be fixed (except in the case the point is about the full content of a file); it doesn't show all the lines that need to be changed for the same reason
- A review is about code that doesn't follow the coding standards, contains possible security issue, or doesn't correctly use the Drupal API; the single points aren't ordered, not even by importance
src/Form/TrainingCreateForm.php
/** * {@inheritdoc} */ protected $messenger; /** * {@inheritdoc} */ protected $requestStack; /** * {@inheritdoc} */ protected $configFactory;
Those properties are already defined from the parent class. There is no need to define them again.
public function __construct(OpignoLPManager $opignoLpCreate, Connection $connection, RequestStack $request_stack, MessengerInterface $messenger, ConfigFactoryInterface $configFactory, RendererInterface $renderer) { $this->opignoLpCreate = $opignoLpCreate; $this->database = $connection; $this->requestStack = $request_stack; $this->messenger = $messenger; $this->configFactory = $configFactory; $this->renderer = $renderer; }
For the properties already defined from the parent class, the parent class provides methods to initialize those properties.
/** * Create container. */ public static function create(ContainerInterface $container) { return new static( $container->get('opigno_lp_create.lp_create'), $container->get('database'), $container->get('request_stack'), $container->get('messenger'), $container->get('config.factory'), $container->get('renderer') ); }
For methods inherited from the parent class or defined from an interface, the documentation comment is different.
$form['module_activity']['create_new_activity'] = [ '#type' => 'markup', '#markup' => '<a href="/admin/structure/opigno_activity/add/opigno_h5p" target="__blank">Add New Activity</a><br><br><br>', '#weight' => '3', '#attributes' => [ 'class' => [ 'create-new-activity-link', ], ], ];
For rendering links, Drupal provides a render type (#link).
if ($form_state->getValue('op') == 'Refresh') { return TRUE; }
Form validation handlers are not expected to return any value.
if (empty($form_state->getValue('title'))) { $form_state->setErrorByName('title', $this->t('Title field is required.')); }
For required form values, it is sufficient to mark a form element as required.
if (!preg_match('/^[0-9]*$/', $form_state->getValue('minimum_score_to_validate_step'))) { $form_state->setErrorByName('minimum_score_to_validate_step', $this->t('The score must be an integer.')); }
If the entered value must be an integer, it is sufficient to use the appropriate form element type (number).
src/LPManager.php
/** * Initial lp_create. */ public function lpCreate() { return $this->entityManager->getStorage('node')->loadMultiple([9330]); }
The documentation comment must describe the method purpose, the parameters it accepts (if there are any), and the return value.
It is not clear why the module expect the node whose ID is 9330 exists. - 🇮🇳India dharmendra-virasat
Hi everyone, fixed PHPCS issue and the above request as well. So please review.
- Status changed to Needs review
about 1 year ago 8:29am 6 November 2023 - 🇮🇳India vishal.kadam Mumbai
Remember to change the status to Needs review when the project is ready for review.
- Status changed to Needs work
about 1 year ago 11:59am 6 November 2023 - 🇮🇹Italy apaderno Brescia, 🇮🇹
src/Form/TrainingCreateForm.php
/** * This class restitutes the training create form. */ class TrainingCreateForm extends FormBase {
There is no need to start the description with This class. The training create form. is a sufficient description.
/** * Include the OpignoLPManager service. * * @var \Drupal\opigno_lp_create\OpignoLPManager */
Include the is not necessary in property descriptions.
/** * {@inheritdoc} */ /** * {@inheritdoc} */ protected $renderer;
A documentation comment is not followed by any property.
$render
is not a inherited property and the documentation comment cannot use{@inheritdoc}
./** * Constructs. * * @param \Drupal\opigno_lp_create\OpignoLPManager $opignoLpCreate * provides the OpignoLPManager service. * @param \Drupal\Core\Database\Connection $connection * The Database service. * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * The request stack. * @param \Drupal\Core\Messenger\MessengerInterface $messenger * The messenger service. * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory * The configuration factory service. * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer service. */
The documentation comment for constructors is not mandatory anymore, If it is given, the description must be Constructs a new [class name] object. where [class name] includes the class namespace.
Provides is not necessary in parameter descriptions./** * Create container. */ public static function create(ContainerInterface $container) {
/** * Builds the form for training. * * @param array $form * An associative array containing the structure of the form. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * * @return array * The form array that defines the formbase form. */ public function buildForm(array $form, FormStateInterface $form_state) {
Since those are methods defined in an interface, the documentation comments must be different.
if (!preg_match('/^[0-9]*$/', $form_state->getValue('minimum_score_to_validate_step'))) { $form_state->setErrorByName('minimum_score_to_validate_step', $this->t('The score must be an integer.')); } if (!empty($form_state->getValue('minimum_score_to_validate_step')) && $form_state->getValue('minimum_score_to_validate_step') > 100) { $form_state->setErrorByName('minimum_score_to_validate_step', $this->t('The score must be an integer between 0 to 100.')); }
For numbers, there is the #number form element, which also validates the minimum and maximum allowed values.
$this->messenger->addError($this->t('Something went wrong.'), 'status', TRUE);
The messenger is accessed with
$this->messenger()
and set with$this->setMessenger()
(in the class constructor).src/Form/CreateModuleForm.php
/** * Include the messenger service. * * @var \Drupal\Core\Messenger\MessengerInterface */ protected $messenger;
That is already a parent class's property, which is set by a child class with
$this->setMessenger()
./** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { }
It is not necessary to define an empty method, if the submitted data is not validated.
src/LPManager.php
/** * This is a Drupal 9 custom service. */ class LPManager { /** * The entity manager service. * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ private $entityManager; /** * Initial constructor. */ public function __construct(EntityManager $entityManager) { $this->entityManager = $entityManager; } }
This class is not complete.
The class description does not describe what the class does. Saying it is a Drupal 9 service is not sufficient.
src/OpignoLPManager.php
/** * The entity manager service. * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ private $entityManager; /** * {@inheritdoc} */ private $configFactory; /** * {@inheritdoc} */ private $database; /** * {@inheritdoc} */ public $opignoModuleObj;
Since the class does not extend a parent class nor does it implements an interface,
{@inheritdoc}
cannot be used in the documentation comment. - 🇮🇹Italy apaderno Brescia, 🇮🇹
I am changing priority as per Issue priorities → .
- Status changed to Closed: won't fix
3 months ago 7:21am 13 August 2024 - 🇮🇳India vishal.kadam Mumbai
This thread has been idle, in the Needs work state with no activity for several months. Therefore, I am assuming that you are no longer pursuing this application, and I marked it as Closed (won't fix).
If this is incorrect, and you are still pursuing this application, then please feel free to re-open it and set the issue status to Needs work or Needs review, depending on the current status of your code.