- Issue created by @adwivedi008
- š®š³India adwivedi008
Resolved above mentioned issues
Please approve
- Status changed to Needs work
about 1 year ago 6:33pm 22 November 2023 - š®š¹Italy apaderno Brescia, š®š¹
A summary must describe what needs to be changed, and eventually why. A screenshot is not sufficient, even in the case a patch/MR is provided.
In the case of bug reports, the steps to reproduce the bug should be provided too. In the case of coding standards issues found using an automatic tool, the report given by that tool must be quoted too, including the arguments passed to that tool, if it is a command line tool. - Status changed to Needs review
about 1 year ago 6:22am 26 November 2023 - š®š³India adwivedi008
@apanderno Hi, I have updated the issue summary steps to reproduce and also the command using which the report is generated.
Moving the issue status to needs review
Please review. - Status changed to Needs work
about 1 year ago 8:40am 26 November 2023 - š®š¹Italy apaderno Brescia, š®š¹
+ /** + * Function to Calculate Time. + */ public function calculateTime(&$form, FormStateInterface $form_state) {
A method description must not start with Function. (This holds true for functions too.)
Given the method parameters, that method seems a from handler/callback, which then should have a different description, basing on exactly what that method is./** - * Class UnixTimeConversionSettings. + * Class Unix Time Conversion Settings. * * @package Drupal\unix_time_conversion\Form\UnixTimeConversionSettings */ class UnixTimeConversionSettings extends ConfigFormBase {
That description is still repeating the class name, not describing what the class does. Class descriptions must not start with Class. (The code makes already clear it is a class.)
+ /** + * The config factory service. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ + protected $configFactory;
The config factory. is sufficient (and what Drupal core uses as description.)
+ /** + * Constructs a new UnixTimeConversionSettings object. + * + * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory + * The config factory service. + */ + public function __construct(ConfigFactoryInterface $config_factory) {
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.
- // Form constructor. - $form = parent::buildForm($form, $form_state); - $config = \Drupal::configFactory()->getEditable('unix_time_conversion.settings'); + $config = $this->configFactory->getEditable('unix_time_conversion.settings'); // Include the helper functions file. module_load_include('inc', 'unix_time_conversion', 'unix_time_conversion.helper_functions'); $form = [];
Calling
parent::buildForm()
is correct. What it is not correct is setting$form
to an empty array after that. That is a bug, though, not something PHP_CodeSniffer reported; this issue should not remove neither of those lines.+ $this->configFactory->getEditable('unix_time_conversion.settings') + ->set('unix_time_conversion_timestamp_field_title', $form_state->getValue('unix_time_conversion_timestamp_field_title')) + ->set('unix_time_conversion_timestamp_field_description', $form_state->getValue('unix_time_conversion_timestamp_field_description')) + ->set('unix_time_conversion_time_to_date_output_format', $form_state->getValue('unix_time_conversion_time_to_date_output_format')) + ->set('unix_time_conversion_date_field_title', $form_state->getValue('unix_time_conversion_date_field_title')) + ->set('unix_time_conversion_time_field_title', $form_state->getValue('unix_time_conversion_time_field_title')) + ->save();
The correct code calls
$this->config('unix_time_conversion.settings')
.+/** + * Class UnixTimeConversionForm. + * + * @package Drupal\unix_time_conversion\Form\UnixTimeConversionForm + */ +class UnixTimestampToDateBlockForm extends FormBase {
The description is merely repeating the class name.
+ /** + * {@inheritdoc} + */ + public function validateForm(array &$form, FormStateInterface $form_state) { + + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + + }
The second method is not necessary, if it does not contain code, as the parent class already defines it.
The first method is not necessary, if it does not contain code. Other classes that extendConfigFormBase
do not define it. (SeeAccountSettingsForm
as example.)+ /** + * The form builder service. + * + * @var \Drupal\Core\Form\FormBuilderInterface + */ + protected $formBuilder;
The form builder. is sufficient.
+/** + * @file * To change this license header, choose License Headers in Project Properties. + * * To change this template file, choose Tools | Templates * and open the template in the editor. */
Since that comment is edited, it should be corrected: It must describe what that file contains. Those are instructions that are true for a specific editor or IDE.
+/** + * @file + * Defines necessary menu's, Permissions, age-calculator form & ajax callbacks. + */
The usual description for a .module file is Hook implementations for the [module name] module. where [module name] is the name of the module given in its .info.yml file.
- Assigned to pray_12
- š®š³India pray_12
Hi,
The above patch #8 does not address #7 comments and has many errors and warnings.
I have addressed #7 comments using patch #2 .
Added both the interdiff file and updated patch file. - Issue was unassigned.
- Status changed to Needs review
12 months ago 6:17am 9 February 2024 Hi,
Applied patch #10, the patch applies cleanly and there are no phpcs errors found.- Status changed to RTBC
6 months ago 11:52pm 14 August 2024 Hi @everyone,
Applied comment #11's patch, confirmed it fixed all reported errors/warnings and it addressed the feedback of comment #7.
ā unix_time_conversion git:(main) ā curl https://www.drupal.org/files/issues/2024-02-09/3403470-10.patch | patch -p1 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 22400 100 22400 0 0 39251 0 --:--:-- --:--:-- --:--:-- 40000 patching file src/Element/TimeElement.php patching file src/Form/DateToUnixTimestampBlockForm.php patching file src/Form/UnixTimeConversionSettings.php patching file src/Form/UnixTimestampToDateBlockForm.php patching file src/Plugin/Block/DateToUnixTimestampBlock.php patching file src/Plugin/Block/UnixTimestampToDateBlock.php patching file unix_time_conversion.helper_functions.inc patching file unix_time_conversion.module ā unix_time_conversion git:(main) ā .. ā contrib git:(main) ā phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig unix_time_conversion ā contrib git:(main) ā
Will now move this to RTBC
Thanks,
Jake- Status changed to Needs work
6 months ago 4:30pm 15 August 2024 - š®š¹Italy apaderno Brescia, š®š¹
Let's create a merge request, now that patches are no longer tested.
- Merge request !4Issue #3403470: Fix the issues reported by PHP_CodeSniffer ā (Open) created by apaderno