- ๐ฎ๐ณIndia Akram Khan Cuttack, Odisha
Still there are issue remanning
akram.khan@C02FC0PWML7M ~ % phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml /Users/akram.khan/Desktop/Contribution/drupal9.5.x/drupal/json_ld_schema_ui
FILE: ...Contribution/drupal9.5.x/drupal/json_ld_schema_ui/json_ld_schema_ui.module
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
--------------------------------------------------------------------------------
8 | WARNING | [x] Unused use statement
9 | WARNING | [x] Unused use statement
12 | WARNING | [x] Unused use statement
13 | WARNING | [x] Unused use statement
14 | WARNING | [x] Unused use statement
17 | WARNING | [x] Unused use statement
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------FILE: ...m.khan/Desktop/Contribution/drupal9.5.x/drupal/json_ld_schema_ui/README.md
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
70 | WARNING | Line exceeds 80 characters; contains 101 characters
--------------------------------------------------------------------------------FILE: ...l9.5.x/drupal/json_ld_schema_ui/src/Form/EntitySchemaConfigurationForm.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
419 | WARNING | Unused variable $active_properties.
465 | WARNING | Unused variable $active_properties.
--------------------------------------------------------------------------------FILE: ...pal9.5.x/drupal/json_ld_schema_ui/src/Form/EntitySchemaAddPropertyForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
--------------------------------------------------------------------------------
231 | WARNING | [ ] Unused variable $active_properties.
249 | ERROR | [x] list(...) is forbidden, use [...] instead.
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------FILE: .../drupal9.5.x/drupal/json_ld_schema_ui/src/Entity/ContentSchemaSettings.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
207 | ERROR | [x] list(...) is forbidden, use [...] instead.
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------FILE: ...upal9.5.x/drupal/json_ld_schema_ui/src/Plugin/DataType/SchemaOverrides.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
39 | WARNING | Unused variable $schema_type.
41 | WARNING | Unused variable $property_path.
--------------------------------------------------------------------------------Time: 813ms; Memory: 12MB
- ๐ฎ๐ณIndia Akram Khan Cuttack, Odisha
added updated patch and fixed some PHPCS issue
- ๐ฎ๐น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 has been used, which arguments have been used, and which report that command shown.
- Status changed to Needs review
over 1 year ago 6:44am 9 March 2023 - Status changed to Needs work
over 1 year ago 7:58am 9 March 2023 - ๐ฎ๐นItaly apaderno Brescia, ๐ฎ๐น
The Needs work status is for the issue summary that does not report the arguments passed to
phpcs
. - Status changed to Needs review
over 1 year ago 11:11am 13 March 2023 - ๐ฎ๐ณIndia nayana_mvr
Verified the patch #8. The patch applied cleanly but its showing a new warning message now:
FILE: .../contrib/json_ld_schema_ui/src/Plugin/DataType/SchemaOverrides.php ----------------------------------------------------------------------------------------------------------------------------- FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE ----------------------------------------------------------------------------------------------------------------------------- 41 | WARNING | Unused variable $override. ----------------------------------------------------------------------------------------------------------------------------- Time: 665ms; Memory: 14MB
All other issues are fixed.
- Status changed to Needs work
over 1 year ago 8:34am 14 March 2023 - ๐ฎ๐นItaly apaderno Brescia, ๐ฎ๐น
+Settings > Settings_ (`/admin/config/search/schemaorg/settings`). +The default settings for the schema should be fine for most websites. Note that the settings are currently not properly validated, so changing them can break the functionality of the module.
Moving The default settings for the schema on a new line is correct, but then the rest of the text need to be reformatted, as the line containing The default settings for the schema is too short.
- ๐ฎ๐ณIndia TanujJain-TJ
after applying #8 got this phpcs error
FILE: /src/Form/EntitySchemaConfigurationForm.php -------------------------------------------------------------------------------- FOUND 2 ERRORS AFFECTING 2 LINES -------------------------------------------------------------------------------- 272 | ERROR | [x] Array indentation error, expected 8 spaces but found 10 273 | ERROR | [x] Array indentation error, expected 8 spaces but found 10 -------------------------------------------------------------------------------- PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY -------------------------------------------------------------------------------- FILE: src/Plugin/DataType/SchemaOverrides.php -------------------------------------------------------------------------------- FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE -------------------------------------------------------------------------------- 41 | WARNING | Unused variable $override. --------------------------------------------------------------------------------
Adding a new patch to fix this error and for now commenting the code to remove unused variable error as it was todo, also addressing changes mentioned in #14.
- Status changed to RTBC
over 1 year ago 7:53am 1 May 2023 - ๐ฎ๐ณIndia Mahima_Mathur23
Verified the patch.
The changes raised by @apaderno have been incorporated and there are no more Phpcs errors.Moving to RTBC.
- Status changed to Needs work
over 1 year ago 8:14am 1 May 2023 - ๐ฎ๐นItaly apaderno Brescia, ๐ฎ๐น
- $active_properties = &$schema_properties; foreach (array_slice($property_path, 1, -1) as $property) { $active_properties = &$active_properties[$property]['properties']; }
Since the line initializing
$active_properties
has been removed, how can$active_properties = &$active_properties[$property]['properties'];
work?// Traverse the property path so we know where to set the values. - $active_properties = &$schema_properties; foreach (array_slice(explode('|', $property_path), 1) as $property_label) { $active_properties = &$active_properties[$property_label]['properties']; }
Similarly, how can
$active_properties = &$active_properties[$property_label]['properties'];
work?- foreach ($value as $schema_type => $overrides) { - // @todo Validate schema types here. - foreach ($overrides as $property_path => $override) { - // @todo Validate property path here. - } - } - + // Commenting to remove phpcs error of unused variable + // foreach ($value as $overrides) { + // // @todo Validate schema types here. + // foreach ($overrides as $override) { + // // @todo Validate property path here. + // } + // } + // change line indentation after removing comment. parent::setValue($value, $notify);
No, code is not commented out just to avoid to get a PHP_CodeSniffer error.
Furthermore, the commented out code is not even correctly indented. - ๐ฎ๐นItaly apaderno Brescia, ๐ฎ๐น
- - // Traverse the property path so we know where to set the new one. - $active_properties = &$schema_properties; - foreach (array_slice(explode('|', $form_state->get('property_path')), 1) as $property) { - $active_properties = &$active_properties[$property]['properties']; - } - - $property = $form_state->getValue('property'); - $property_type = $form_state->getValue('property_type'); - $property_label = $this->schemaData->getSchemaLabel($property); - - // Simple values default to empty strings that can't be overridden. - if ($property_type == '***simple***') { - $active_properties[$property_label] = [ - 'default_value' => '', - 'allow_override' => FALSE, - ]; - } - // Complex values default to setting the @type property of the subtype. - else { - list($sub_type_id, $hash) = explode('#', $property_type); - if ($hash == 'enum') { - $active_properties[$property_label] = [ - 'default_value' => '', - 'allow_override' => FALSE, - 'enum_type' => $sub_type_id, - ]; - } - else { - $sub_type_label = $this->schemaData->getSchemaLabel($sub_type_id); - $active_properties[$property_label]['properties']['@type'] = [ - 'default_value' => $sub_type_label, - 'allow_override' => FALSE, - ]; - } - } -
- $property_path = explode('|', $values['property_path']); - - // Traverse the property path so we know which one to remove. - $active_properties = &$schema_properties; - foreach (array_slice($property_path, 1, -1) as $property) { - $active_properties = &$active_properties[$property]['properties']; - } - $property = end($property_path); - unset($active_properties[$property]);
- $php_safe_id = str_replace('.', '_', $schema_setting->id()); - $values = $form_state->getValue([$php_safe_id, 'properties']); - $schema_properties = $schema_setting->getSchemaProperties(); - foreach ($values as $property_path => $property_values) { - if (empty($property_values['table'])) { - continue; - } - - // Traverse the property path so we know where to set the values. - $active_properties = &$schema_properties; - foreach (array_slice(explode('|', $property_path), 1) as $property_label) { - $active_properties = &$active_properties[$property_label]['properties']; - } - - foreach ($property_values['table'] as $property_label => $property_settings) { - if (!isset($property_settings['default_value'])) { - continue; - } - - $active_properties[$property_label]['default_value'] = $property_settings['default_value']; - $active_properties[$property_label]['allow_override'] = (bool) $property_settings['allow_override']; - } - } -
Why is all that code removed? It does not seem that is required by the PHP_CodeSniffer report shown in the issue summary.
- foreach ($value as $schema_type => $overrides) { - // @todo Validate schema types here. - foreach ($overrides as $property_path => $override) { - // @todo Validate property path here. - } - }
Why should that code, which contains also two
@todo
comments, be removed? - Status changed to Needs review
9 months ago 10:28am 8 February 2024 - ๐ช๐ธSpain gxleano Cรกceres
This issue will be fixed on https://www.drupal.org/project/json_ld_schema_ui/issues/3330907 ๐ Fix the issues reported by phpcs Needs review .
Closing for duplicated.
- Status changed to Closed: duplicate
9 months ago 11:12am 1 March 2024