Problem/Motivation

$ phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /var/www/html/web/modules/contrib/cloud/

FILE: /var/www/html/web/modules/contrib/cloud/src/Plugin/Derivative/CloudMenuLinks.php
--------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------
 56 | WARNING | Unused variable $cloud_config_type.
--------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/src/Plugin/Derivative/CloudDesignMenuLinks.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
 70 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 79 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 89 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/src/Plugin/Block/CloudConfigLocationBlock.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
 280 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/src/Plugin/Field/FieldFormatter/CloudImageFormatter.php
-----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------
 95 | WARNING | File::load calls should be avoided in classes, use dependency injection instead
-----------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/src/Plugin/Field/FieldFormatter/InstanceLinkFormatter.php
-------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------
 142 | WARNING | File::load calls should be avoided in classes, use dependency injection instead
-------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/src/Plugin/cloud/server_template/CloudServerTemplatePluginManager.php
-------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------
 176 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 199 | WARNING | Unused variable $url.
-------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/src/Plugin/cloud/project/CloudProjectPluginManager.php
----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------
 173 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 196 | WARNING | Unused variable $url.
----------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/src/Controller/CloudConfigLocationController.php
-------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------
 236 | WARNING | File::load calls should be avoided in classes, use dependency injection instead
 290 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/src/Form/CloudProjectRevisionDeleteForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
 140 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/src/Service/CloudService.php
---------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------
 301 | WARNING | Role::loadMultiple calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/cloud.routing.yml
------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------
 95 | WARNING | Open page callback found, please add a comment before the line why there is no access restriction
------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/tests/src/Functional/Module/CloudModuleTestBase.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
 326 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/tests/src/Functional/cloud/config/CloudConfigTestBase.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
 118 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/gapps/src/Form/Config/GAppsAdminSettings.php
--------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------
 82 | WARNING | Unused variable $config.
--------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/tools/k8s_to_s3/k8s_to_s3.module
--------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------------
 136 | WARNING | Unused variable $key.
 221 | WARNING | Unused variable $containers.
--------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/src/Plugin/Block/ResourcesBlock.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------
 236 | WARNING | Unused private method getInstanceTypePricingLink()
---------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/src/Plugin/Block/DetachedVolumesBlock.php
---------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------
 32 | WARNING | Unused variable $entity_type_id.
---------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/src/Plugin/Validation/Constraint/IpPermissionDataConstraintValidator.php
----------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------------------------------
 126 | WARNING | Unused variable $key.
----------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/src/Plugin/Validation/Constraint/SecurityGroupNameConstraintValidator.php
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
 76 | WARNING | Unused variable $violations.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/AwsCloudKeyPairController.php
----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------
 54 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/src/Form/Config/AwsCloudAdminSettings.php
---------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
---------------------------------------------------------------------------------------------------------------------------------
 346 | WARNING | Unused variable $old_config.
 353 | WARNING | Unused variable $instance_time.
 354 | WARNING | Unused variable $volume_time.
 355 | WARNING | Unused variable $snapshot_time.
 375 | WARNING | File::load calls should be avoided in classes, use dependency injection instead
 449 | WARNING | Unused private method shouldCacheBeCleaned()
---------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/src/Form/Config/AwsCloudAdminNotificationSettings.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
 532 | WARNING | Unused variable $views_settings.
 616 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/src/Form/Ec2/SecurityGroupCopyForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
 113 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/src/Form/Ec2/InstanceMonitorForm.php
----------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------
 133 | WARNING | Unused variable $entity.
----------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/src/Service/Pricing/PricingService.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
 220 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/tests/src/Traits/AwsCloudTestFormDataTrait.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------------------------------------------------------------
  63 | WARNING | Unused variable $cloud_context.
 767 | WARNING | Unused variable $group_id.
 845 | ERROR   | Use of self::$awsCloudSecurityGroupRulesInbound inside closure.
--------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/InstanceTest.php
---------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------
 61 | WARNING | Unused variable $state.
---------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/aws_cloud/aws_cloud.module
--------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------------------------------
 3086 | WARNING | Unused variable $instance_ids_to_notify.
 3964 | WARNING | Unused variable $cloud_config.
 4212 | WARNING | Unused variable $alias.
--------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/docker/src/Service/DockerService.php
------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------
 239 | WARNING | Unused variable $response.
 243 | WARNING | Unused variable $image.
 257 | WARNING | Unused variable $response.
------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Plugin/Derivative/K8sMenuLinks.php
------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------
 241 | WARNING | Variable $namespace is undefined.
 314 | WARNING | Unused private method getNamespaceEntities()
------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Plugin/Block/K8sNamespaceCostsChartBlock.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
 131 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Plugin/cloud/server_template/K8sCloudServerTemplatePlugin.php
---------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
---------------------------------------------------------------------------------------------------------------------------------------------------
 288 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 314 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 451 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 474 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 488 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 494 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
---------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Plugin/cloud/project/K8sCloudProjectPlugin.php
------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------
 238 | WARNING | Unused variable $k8s_cluster.
------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Entity/K8sDeploymentViewsData.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
 33 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 34 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 36 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Entity/K8sPodViewsData.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
 33 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 34 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 36 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Controller/ApiController.php
------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------
 506 | WARNING | Unused variable $node_name.
 535 | WARNING | Unused variable $entity_type_name_capital.
------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Controller/K8sNamespaceCostsChartController.php
-------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------
 277 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Form/Config/K8sAdminSettings.php
----------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------
 153 | WARNING | File::load calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Form/K8sPodLogForm.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
 37 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Service/K8sService.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
 1927 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 1939 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 1945 | WARNING | Unused variable $link.
 2287 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 2309 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 2380 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Service/K8sBatchOperations.php
--------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------------------------
 1875 | WARNING | Unused variable $key.
 2294 | WARNING | Unused variable $rule.
--------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Service/CostFieldsRenderer.php
--------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------
 45 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
--------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/tests/src/Traits/K8sTestFormDataTrait.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------
 1103 | WARNING | Unused variable $random.
---------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/k8s.install
---------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
 1346 | WARNING | Unused variable $k8s_service.
---------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/k8s.module
--------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
--------------------------------------------------------------------------------------------
 1924 | WARNING | Unused variable $project.
 2023 | WARNING | Unused variable $k8s_cluster.
 2061 | WARNING | Unused variable $project.
 2164 | WARNING | #description values usually have to run through t() for translation
 2170 | WARNING | #description values usually have to run through t() for translation
--------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/terraform/src/Traits/TerraformFormTrait.php
-------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------
 226 | WARNING | Unused variable $result.
-------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/terraform/src/Form/Config/TerraformAdminSettings.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------
 128 | WARNING | File::load calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/terraform/src/Form/TerraformWorkspaceCreateForm.php
---------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------
 119 | WARNING | Unused variable $result.
---------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/terraform/src/Form/TerraformRunApplyForm.php
--------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------
 48 | WARNING | Unused variable $result.
--------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/terraform/src/Form/TerraformVariableEditForm.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------
 135 | WARNING | Unused variable $result.
------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/terraform/src/Service/TerraformService.php
------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------
 194 | WARNING | Unused variable $organization.
 313 | WARNING | Unused variable $organization.
------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/openstack/src/Plugin/cloud/server_template/OpenStackServerTemplatePlugin.php
----------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------------------------
 251 | WARNING | Unused variable $result.
----------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/openstack/src/Form/Config/OpenStackAdminSettings.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------
 194 | WARNING | File::load calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/openstack/src/Form/OpenStackNetworkInterfaceEditForm.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
 55 | WARNING | Unused variable $entity.
--------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/openstack/src/Service/OpenStackEc2Service.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
---------------------------------------------------------------------------------------------------------------------------
 122 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 202 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 212 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/openstack/src/Service/OpenStackBatchOperations.php
--------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------
 52 | WARNING | Unused variable $config_factory.
--------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/openstack/tests/src/Functional/OpenStack/OpenStackSecurityGroupTest.php
-----------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------------------
 351 | WARNING | Unused private method createRuleParams()
-----------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/openstack/openstack.module
--------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------
 1234 | WARNING | Unused variable $cloud_context.
--------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/openstack/openstack.info.yml
----------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------
 8 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
----------------------------------------------------------------------------------------------------------

Time: 33.54 secs; Memory: 38MB

Comments

onotm created an issue. See original summary.

onotm’s picture

Status: Active » Needs review
StatusFileSize
new52.08 KB

I fixed the warnings about the T function and unused functions or functions.

I have a question.
There is a warning "\Drupal calls should be avoided in classes, use dependency injection instead". How should I fix this warning?
(I searched this warning, but couldn't find a specific solution)

yas’s picture

Status: Needs review » Needs work

@onotm

Thank you for the refactoring. As for DI, you can refer to our past efforts: https://www.drupal.org/project/issues/cloud?text=dependency+injection&st...

HTH

onotm’s picture

Status: Needs work » Needs review
StatusFileSize
new102.82 KB

Status: Needs review » Needs work

The last submitted patch, 4: 3164928-4.patch, failed testing. View results

onotm’s picture

Status: Needs work » Needs review
StatusFileSize
new103.4 KB

Status: Needs review » Needs work

The last submitted patch, 6: 3164928-6.patch, failed testing. View results

onotm’s picture

Status: Needs work » Needs review
StatusFileSize
new90.23 KB

3164928-4.patch fixes all warnings, but fails K8sCloudConfigTest::testCloudConfig and K8sCloudConfigTest::testK8sMenu.
These test functions say 'Behat\Mink\Exception\ElementNotFoundException: Button with id|name|label|value "Save" not found'.
Currently I am looking for the cause of failure.

Status: Needs review » Needs work

The last submitted patch, 8: 3164928-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

yas’s picture

Title: Refactor the entire source code based on DrupalPractice » Refactor the entire source code based on DrupalPractice (1)
Issue summary: View changes

@onotm

You can separate the issue for the test failure. Please drop the error portion from the current patch and upload it.

onotm’s picture

Status: Needs work » Needs review
StatusFileSize
new102.61 KB

Status: Needs review » Needs work

The last submitted patch, 11: 3164928-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

onotm’s picture

Status: Needs work » Needs review
StatusFileSize
new102.61 KB
onotm’s picture

StatusFileSize
new22.85 KB
onotm’s picture

StatusFileSize
new90.72 KB

Status: Needs review » Needs work

The last submitted patch, 15: 3164928-15.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

onotm’s picture

Status: Needs work » Needs review
StatusFileSize
new90.72 KB
onotm’s picture

StatusFileSize
new84.78 KB

Status: Needs review » Needs work

The last submitted patch, 18: 3164928-18.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

onotm’s picture

StatusFileSize
new77.53 KB
onotm’s picture

StatusFileSize
new76.15 KB
onotm’s picture

StatusFileSize
new75.69 KB
onotm’s picture

StatusFileSize
new75.25 KB
onotm’s picture

StatusFileSize
new77.5 KB
onotm’s picture

StatusFileSize
new50.07 KB
onotm’s picture

StatusFileSize
new101.59 KB
onotm’s picture

StatusFileSize
new87.58 KB
onotm’s picture

StatusFileSize
new75.73 KB
onotm’s picture

StatusFileSize
new74.74 KB
onotm’s picture

StatusFileSize
new101.8 KB
onotm’s picture

StatusFileSize
new99.24 KB
onotm’s picture

Status: Needs work » Needs review
StatusFileSize
new101.45 KB

This patch fixes all but one warning.
The unfixed warning is

FILE: ...s/cloud_service_providers/k8s/src/Service/CostFieldsRenderer.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 46 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
----------------------------------------------------------------------

This warning can be fixed by the following patch.
However, applying this patch fails the test. https://www.drupal.org/pift-ci-job/1814866

diff --git a/modules/cloud_service_providers/k8s/k8s.info.yml b/modules/cloud_service_providers/k8s/k8s.info.yml
index 0368b668..8b97fafd 100644
--- a/modules/cloud_service_providers/k8s/k8s.info.yml
+++ b/modules/cloud_service_providers/k8s/k8s.info.yml
@@ -6,3 +6,4 @@ core_version_requirement: ^8.8 || ^9
 configure: k8s.settings
 dependencies:
   - cloud:cloud
+  - cloud:aws_cloud
diff --git a/modules/cloud_service_providers/k8s/k8s.services.yml b/modules/cloud_service_providers/k8s/k8s.services.yml
index 803c99ae..bf3b05f7 100644
--- a/modules/cloud_service_providers/k8s/k8s.services.yml
+++ b/modules/cloud_service_providers/k8s/k8s.services.yml
@@ -9,4 +9,4 @@ services:
 
   k8s.cost_fields_renderer:
     class: Drupal\k8s\Service\CostFieldsRenderer
-    arguments: ['@module_handler']
+    arguments: ['@module_handler', '@aws_cloud.instance_type_price_data_provider']
diff --git a/modules/cloud_service_providers/k8s/src/Service/CostFieldsRenderer.php b/modules/cloud_service_providers/k8s/src/Service/CostFieldsRenderer.php
index f5461496..8f06c58e 100644
--- a/modules/cloud_service_providers/k8s/src/Service/CostFieldsRenderer.php
+++ b/modules/cloud_service_providers/k8s/src/Service/CostFieldsRenderer.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\k8s\Service;
 
+use Drupal\aws_cloud\Service\Pricing\InstanceTypePriceDataProvider;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 
 /**
@@ -16,15 +17,26 @@ class CostFieldsRenderer implements CostFieldsRendererInterface {
    */
   protected $moduleHandler;
 
+  /**
+   * The data provider of instance type prices.
+   *
+   * @var Drupal\aws_cloud\Service\Pricing\InstanceTypePriceDataProvider
+   */
+  private $priceDataProvider;
+
   /**
    * Constructs a new CostFieldsRenderer object.
    *
    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
    *   The module handler.
+   * @param Drupal\aws_cloud\Service\Pricing\InstanceTypePriceDataProvider $price_data_provider
+   *   The data provider of instance type prices.
    */
-  public function __construct(ModuleHandlerInterface $module_handler) {
+  public function __construct(ModuleHandlerInterface $module_handler,
+                              InstanceTypePriceDataProvider $price_data_provider) {
 
     $this->moduleHandler = $module_handler;
+    $this->priceDataProvider = $price_data_provider;
   }
 
   /**
@@ -43,9 +55,8 @@ class CostFieldsRenderer implements CostFieldsRendererInterface {
       return $build;
     }
 
-    $price_date_provider = \Drupal::service('aws_cloud.instance_type_price_data_provider');
-    $fields = $price_date_provider->getFields();
-    $price_data = $price_date_provider->getDataByRegion($region, NULL, NULL, NULL, $refresh);
+    $fields = $this->priceDataProvider->getFields();
+    $price_data = $this->priceDataProvider->getDataByRegion($region, NULL, NULL, NULL, $refresh);
     $price_info = [];
     foreach ($instance_types ?: [] as $instance_type) {
       foreach ($price_data ?: [] as $item) {
yas’s picture

Status: Needs review » Needs work
  1. +++ b/modules/cloud_service_providers/aws_cloud/src/Plugin/Block/BulkDeleteBlock.php
    @@ -301,7 +301,7 @@ abstract class BulkDeleteBlock extends BlockBase implements ContainerFactoryPlug
    +      throw new AwsCloudBlockException('No entity type id found.');
    

    Keep $this->t(). Use Drupal\Core\StringTranslation\StringTranslationTrait.

  2. +++ b/modules/cloud_service_providers/aws_cloud/src/Plugin/Block/ResourcesBlock.php
    @@ -235,31 +234,4 @@ class ResourcesBlock extends BlockBase implements ContainerFactoryPluginInterfac
    -  /**
    -   * Generate AWS Instance Type Pricing link.
    -   *
    -   * @param string $resource_type
    -   *   The resource type.
    -   * @param string $label
    -   *   The link lable.
    -   *
    -   * @return array
    -   *   The AWS resource link.
    -   */
    -  private function getInstanceTypePricingLink($resource_type, $label) {
    -
    -    // Return immediately if $cloud_context is empty.
    -    $cloud_context = $this->configuration['cloud_context'];
    -    if (empty($cloud_context)) {
    -      return [];
    -    }
    -    $instance = count(aws_cloud_get_instance_types($cloud_context));
    -    $pricing_label = "$instance $label";
    -    $link = Link::createFromRoute($pricing_label, "aws_cloud.${resource_type}",
    -      ['cloud_context' => $cloud_context]
    -    );
    -
    -    return $link;
    -  }
    

    @xiaohua-guan

    Is this OK to delete this code?

  3. +++ b/modules/cloud_service_providers/aws_cloud/src/Plugin/Validation/Constraint/IpPermissionDataConstraintValidator.php
    @@ -123,7 +123,7 @@ class IpPermissionDataConstraintValidator extends ConstraintValidator implements
    -    foreach ($entries as $key => $entry) {
    +    foreach ($entries as $entry) {
    

    Could you please double-check if this code works? foreach ($entities as $key => $entity) and foreach ($entities as $entry) have different meaning; and moreover, the variable name should be $entity (not $entry).

  4. +++ b/modules/cloud_service_providers/aws_cloud/src/Plugin/Validation/Constraint/SecurityGroupNameConstraintValidator.php
    @@ -72,8 +72,6 @@ class SecurityGroupNameConstraintValidator extends ConstraintValidator implement
    -      $violations = $this->context->getViolations();
    

    @baldwinlouie and @kumikoono

    Is this OK to delete this code?

  5. +++ b/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/InstanceTest.php
    @@ -60,7 +60,6 @@ class InstanceTest extends AwsCloudTestBase {
    -    $state = ['available', 'pending', 'failed'];
    

    Please use this code with array_rand() for 'state' => ... below.

  6. +++ b/modules/cloud_service_providers/aws_cloud/tests/src/Traits/AwsCloudTestFormDataTrait.php
    @@ -780,13 +779,6 @@ trait AwsCloudTestFormDataTrait {
    -      if (isset($self_group_id)) {
    -        $group_arr = [$self_group_id, "sg-{$this->getRandomId()}"];
    -        $group_id = $group_arr[array_rand($group_arr)];
    -      }
    -      else {
    -        $group_id = "sg-{$this->getRandomId()}";
    -      }
    

    @baldwinlouie

    Is this OK to delete this code? (not used)

  7. +++ b/modules/cloud_service_providers/k8s/k8s.module
    @@ -1974,9 +1974,6 @@ function k8s_get_user_list() {
     function k8s_form_cloud_project_k8s_delete_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
    -  $project = $form_state
    -    ->getFormObject()
    -    ->getEntity();
    

    @masami, @masatotakada

    Can we delete this code?

  8. +++ b/modules/cloud_service_providers/k8s/k8s.module
    @@ -2075,7 +2072,7 @@ function k8s_cloud_project_delete(EntityInterface $entity) {
    +  foreach ($k8s_cluster_list ?: [] as $cloud_context) {
    

    Could you please double-check if this code works equally as the original one?

  9. +++ b/modules/cloud_service_providers/k8s/k8s.module
    @@ -2111,9 +2108,6 @@ function k8s_form_cloud_project_k8s_add_form_alter(array &$form, FormStateInterf
     function k8s_form_cloud_project_k8s_form_submit(array $form, FormStateInterface $form_state) {
    -  $project = $form_state
    -    ->getFormObject()
    -    ->getEntity();
    

    @masami, @masatotakada

    Can we delete this code?

  10. +++ b/modules/cloud_service_providers/k8s/src/Controller/ApiController.php
    @@ -525,7 +525,7 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
    -      $pod_resources = $this->getPodResources($node->getName(), $cloud_context);
    +      $pod_resources = $this->getPodResources($node_name, $cloud_context);
    

    Delete $node_name = $node->getName();, Keep $pod_resources = $this->getPodResources($node->getName(), $cloud_context);

  11. +++ b/modules/cloud_service_providers/k8s/src/Plugin/Derivative/K8sMenuLinks.php
    @@ -211,6 +211,7 @@ class K8sMenuLinks extends DeriverBase implements ContainerDeriverInterface {
    +    $namespace = NULL;
         foreach ($menu_data ?: [] as $id => $link_data) {
           $links[$id] = $base_plugin_definition;
           $links[$id]['base_route'] = 'k8s.service_providers.menu';
    

    Consider this logic. Please double-check the logic.

  12. +++ b/modules/cloud_service_providers/k8s/src/Plugin/cloud/project/K8sCloudProjectPlugin.php
    @@ -235,7 +234,7 @@ class K8sCloudProjectPlugin extends CloudPluginBase implements CloudProjectPlugi
    -      foreach ($k8s_cluster_list ?: [] as $k8s_cluster => $cloud_context) {
    +      foreach ($k8s_cluster_list ?: [] as $cloud_context) {
    

    Could you please double-check if this code works equally as the original one?

  13. +++ b/modules/cloud_service_providers/k8s/src/Service/K8sBatchOperations.php
    @@ -1889,7 +1889,7 @@ class K8sBatchOperations {
    -      foreach ($endpoint_addresses ?: [] as $key => $address_data) {
    +      foreach ($endpoint_addresses ?: [] as $address_data) {
    

    Could you please double-check if this code works correctly as the original one?

  14. +++ b/modules/cloud_service_providers/k8s/src/Service/K8sClientExtension/K8sClient.php
    @@ -54,9 +54,7 @@ class K8sClient extends Client {
    +        throw new K8sServiceException('Unknown error occurred when calling K8s API.');
    

    Keep $this->t(). Use Drupal\Core\StringTranslation\StringTranslationTrait.

  15. +++ b/modules/cloud_service_providers/k8s/src/Service/K8sClientExtension/K8sClient.php
    @@ -76,9 +74,7 @@ class K8sClient extends Client {
    +      throw new K8sServiceException('An error occurred when calling K8s API.');
    

    Keep $this->t(). Use Drupal\Core\StringTranslation\StringTranslationTrait.

  16. +++ b/modules/cloud_service_providers/k8s/src/Service/K8sService.php
    @@ -1995,20 +1995,12 @@ class K8sService extends CloudServiceBase implements K8sServiceInterface {
    -        $link = [];
    -        if ($entity->hasLinkTemplate('canonical')) {
    -          $link = $entity->toLink($this->t('View'))->toString();
    -        }
    -        elseif ($entity->hasLinkTemplate('edit-form')) {
    -          $link = $entity->toLink('View', 'edit-form')->toString();
    -        }
    -
    

    @masami, @masatotakada

    Can we delete this code?

  17. +++ b/modules/cloud_service_providers/openstack/openstack.module
    @@ -303,7 +303,7 @@ function openstack_form_cloud_config_openstack_region_validate(array &$form, For
    -  $cloud_context = aws_cloud_form_cloud_config_aws_cloud_add_form_create_cloud_context($name, $region_name);
    +  aws_cloud_form_cloud_config_aws_cloud_add_form_create_cloud_context($name, $region_name);
    

    Probably we can delete this line?

  18. +++ b/modules/cloud_service_providers/openstack/openstack.module
    @@ -1252,7 +1252,6 @@ function openstack_form_cloud_server_template_openstack_delete_form_submit(array
    -  $cloud_context = \Drupal::routeMatch()->getParameter('cloud_context');
    

    This code is also duplicated?
    Could you please double-check?
    $cloud_server_template = \Drupal::routeMatch()->getParameter('cloud_server_template');

  19. +++ b/modules/cloud_service_providers/terraform/src/Service/TerraformService.php
    @@ -193,8 +193,6 @@ class TerraformService extends CloudServiceBase implements TerraformServiceInter
    -    $credentials = $this->cloudConfigPluginManager->loadCredentials();
    -    $organization = $credentials['organization'];
    

    @xiaohua-guan

    Can we delete this code?

  20. +++ b/modules/cloud_service_providers/vmware/src/Service/VmwareService.php
    @@ -531,7 +531,6 @@ class VmwareService extends CloudServiceBase implements VmwareServiceInterface {
       public function clearAllEntities() {
    -    $timestamp = time();
    

    @xiaohua-guan

    Could you please double-check this code?

  21. +++ b/modules/tools/k8s_to_s3/k8s_to_s3.module
    @@ -137,7 +137,6 @@ function k8s_to_s3_export_entities() {
    -        $key = k8s_to_s3_build_k8s_s3_key($entity, $entity_type);
    

    @xiaohua-guan

    Can you double-check this code?

  22. +++ b/src/Plugin/cloud/config/CloudConfigPluginManager.php
    @@ -174,10 +174,8 @@ class CloudConfigPluginManager extends CloudPluginManager implements CloudConfig
    -      throw new CloudConfigPluginException($this->t(
    -        'Cannot load cloud service provider (CloudConfig) entity for %entity_bundle', [
    -          '%entity_bundle' => $entity_bundle,
    -        ]
    +      throw new CloudConfigPluginException(sprintf(
    +        'Cannot load cloud service provider (CloudConfig) entity for %s', $entity_bundle
    

    Keep $this->t(). Use Drupal\Core\StringTranslation\StringTranslationTrait.

  23. +++ b/src/Plugin/cloud/project/CloudProjectPluginManager.php
    @@ -191,9 +201,6 @@ class CloudProjectPluginManager extends CloudPluginManager implements CloudProje
    -    $url = new Url('entity.cloud_project.collection', [
    -      'cloud_context' => $cloud_context,
    -    ]);
    

    @masami, @masatotakada

    Can we delete this code? (Not used)

  24. +++ b/src/Plugin/cloud/server_template/CloudServerTemplatePluginManager.php
    @@ -194,9 +205,6 @@ class CloudServerTemplatePluginManager extends CloudPluginManager implements Clo
    -    $url = new Url('entity.cloud_server_template.collection', [
    -      'cloud_context' => $cloud_context,
    -    ]);
    

    @baldwinlouie

    Can we delete this code?

xiaohua guan’s picture

@yas @onotm

My answer is as below.

2. The function getInstanceTypePricingLink can't be deleted because it is called in ResourceBlockTrait::buildResourceTableRows().

19. Yes, it can be deleted.

21. Yes, it can be deleted.

masami’s picture

@yas @onotm

7, 9. I think it better to delete the functions.

16, 23. I think they can be deleted.

What do you think @masatotakada?

baldwinlouie’s picture

@yas and @onotm

4. OK to delete
6. OK to delete
24. OK to delete

MasatoTakada’s picture

@yas @masami @onotm

> 12
$k8s_cluster_list are Multiple array, then I thought we need to clarify key and value.
If this syntax has the same meaning, It is okay to me.
# I guess this error is coming from the latest coding violation. It means the same meaning as original code.
# Actually, I have never done this syntax. I am little bit worried about it.

b/modules/cloud_service_providers/k8s/src/Plugin/cloud/project/K8sCloudProjectPlugin.php
@@ -235,7 +234,7 @@ class K8sCloudProjectPlugin extends CloudPluginBase implements CloudProjectPlugi
-      foreach ($k8s_cluster_list ?: [] as $k8s_cluster => $cloud_context) {
+      foreach ($k8s_cluster_list ?: [] as $cloud_context) {

> 16, 23

I thinks these can be deleted.

kumikoono’s picture

@yas @onotm

4. OK to delete

onotm’s picture

Status: Needs work » Needs review
StatusFileSize
new97.08 KB

Thank you for your comments.

1. This change fixes the "exceptions should not be translated" warning. I added a comment to the code.

2. I removed the getInstanceTypePricingLink function part from the patch.

3. I commented "$key is unused variable" and removed this portion from my patch.

4. No update.

5. I updated the patch like this:

--- a/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/InstanceTest.php
+++ b/modules/cloud_service_providers/aws_cloud/tests/src/Functional/Ec2/InstanceTest.php
@@ -82,7 +82,7 @@ class InstanceTest extends AwsCloudTestBase {
       'instance_id' => 'i-' . $this->getRandomId(),
-      'state' => 'running',
+      'state' => array_rand($state),
       'image_id' => 'ami-' . $this->getRandomId(),

6. No update.

7. I deleted the function k8s_form_cloud_project_k8s_delete_form_alter.

8. I commented "$k8s_cluster is unused variable" and removed this portion from my patch.

9. I deleted the function k8s_form_cloud_project_k8s_form_submit.

10: I updated the patch like this:

--- a/modules/cloud_service_providers/k8s/src/Controller/ApiController.php
+++ b/modules/cloud_service_providers/k8s/src/Controller/ApiController.php
@@ -524,7 +524,6 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
     foreach ($nodes ?: [] as $node) {
-      $node_name = $node->getName();
       $pod_resources = $this->getPodResources($node->getName(), $cloud_context);

11. I removed this change from the patch. This code was to fix the "Variable $namespace is undefined" warning. But now this warning no longer occurs without this change (caused by the coding standard update?).

12. I commented "$k8s_cluster is unused variable" and removed this portion from my patch.

13. I commented "$key is unused variable" and removed this portion from my patch.

14. This change fixes the "exceptions should not be translated" warning. I added a comment to the code.

15. This change fixes the "exceptions should not be translated" warning. I added a comment to the code.

16. No update.

17. I removed this line.

18. Yes, the line was duplicated. I deleted one.

19. No update.

20. It depends on a reply from guan-san.

21. No update.

22. This change fixes the "exceptions should not be translated" warning. I added a comment to the code.

23. No update.

24. No update.

onotm’s picture

@xiaohua-guan
Thank you for your comments.
Cloud you please check 20?

Status: Needs review » Needs work

The last submitted patch, 39: 3164928-33.patch, failed testing. View results

onotm’s picture

Status: Needs work » Needs review
StatusFileSize
new98.17 KB

I fixed errors of the previous patch.
The cause of these errors is that k8s_form_cloud_project_k8s_form_submit has been removed.

1) Drupal\Tests\k8s\Functional\cloud\project\CloudProjectTest::testK8sProjectCrudTest
Exception: Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'k8s_form_cloud_project_k8s_form_submit' not found or invalid function name
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()() (Line: 113)
2) Drupal\Tests\k8s\Functional\cloud\project\CloudProjectTest::testLaunchProject
Exception: Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'k8s_form_cloud_project_k8s_form_submit' not found or invalid function name
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()() (Line: 113)
yas’s picture

Status: Needs review » Needs work

@onotm

Thank you for the update. I think we can refactor the following code:

diff -u b/modules/cloud_service_providers/k8s/src/Plugin/Derivative/K8sMenuLinks.php b/modules/cloud_service_providers/k8s/src/Plugin/Derivative/K8sMenuLinks.php
--- b/modules/cloud_service_providers/k8s/src/Plugin/Derivative/K8sMenuLinks.php
+++ b/modules/cloud_service_providers/k8s/src/Plugin/Derivative/K8sMenuLinks.php
@@ -211,7 +211,6 @@
     array $entity_types,
     array $menu_data) {
 
-    $namespace = NULL;
     foreach ($menu_data ?: [] as $id => $link_data) {
       $links[$id] = $base_plugin_definition;
       $links[$id]['base_route'] = 'k8s.service_providers.menu';

FROM:

if (!empty($namespace) && !empty($link_data['route_parameters']['k8s_namespace'])) {

TO:

if (!empty($link_data['route_parameters']['k8s_namespace'])) {

What do you think?

xiaohua guan’s picture

xiaohua guan’s picture

xiaohua guan’s picture

@yas

I agreed with you. The code "empty($namespace)" can be removed.

onotm’s picture

StatusFileSize
new99.16 KB

@yas @xiaohua-guan
Thank you for your comments.
I updated my patch.

--- a/modules/cloud_service_providers/k8s/src/Plugin/Derivative/K8sMenuLinks.php
+++ b/modules/cloud_service_providers/k8s/src/Plugin/Derivative/K8sMenuLinks.php
@@ -224,7 +224,7 @@ class K8sMenuLinks extends DeriverBase implements ContainerDeriverInterface {

        // Get extra route parameters.
       $extra_route_parameters = [];
-      if (!empty($namespace) && !empty($link_data['route_parameters']['k8s_namespace'])) {
+      if (!empty($link_data['route_parameters']['k8s_namespace'])) {
         $namespace = $this->entityTypeManager
--- a/modules/cloud_service_providers/vmware/src/Service/VmwareService.php
+++ b/modules/cloud_service_providers/vmware/src/Service/VmwareService.php
@@ -530,11 +530,4 @@ class VmwareService extends CloudServiceBase implements VmwareServiceInterface {
     \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();
   }
 
-  /**
-   * {@inheritdoc}
-   */
-  public function clearAllEntities() {
-    $timestamp = time();
-  }
-
 }
onotm’s picture

Status: Needs work » Needs review
yas’s picture

@onotm

Thank you for the update. It is getting closer to finalize.

@masami

Can we delete the following variables?

FILE: /var/www/html/web/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Controller/K8sNamespaceCostsChartController.php
-------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
-------------------------------------------------------------------------------------------------------------------------------------
 73 | WARNING | Unused variable $total_costs.
 76 | WARNING | Unused variable $cpu_capacity.
 80 | WARNING | Unused variable $memory_capacity.
 84 | WARNING | Unused variable $pod_capacity.
-------------------------------------------------------------------------------------------------------------------------------------
masami’s picture

@yas
@onotm
They can be deleted.

yas’s picture

Status: Needs review » Needs work

@masami

Thank you for your confirmation.

@onotm

Could you please update the patch?

onotm’s picture

Status: Needs work » Needs review
StatusFileSize
new100.31 KB

@yas @masami
Thank you. I updated the patch.

yas’s picture

@onotm

Thank you for the update.

@masami

+++ b/modules/cloud_service_providers/k8s/src/Controller/K8sNamespaceCostsChartController.php
@@ -70,19 +70,6 @@ class K8sNamespaceCostsChartController extends K8sCostsControllerBase {
-    $cpu_capacity = array_sum(array_map(static function ($node) {
-      return $node->getCpuCapacity();
-    }, $nodes));
-
-    $memory_capacity = array_sum(array_map(static function ($node) {
-      return $node->getMemoryCapacity();
-    }, $nodes));
-
-    $pod_capacity = array_sum(array_map(static function ($node) {
-      return $node->getPodsCapacity();
-    }, $nodes));

I think we can remove those variables but can we delete entire code? Please let us re-confirm.

masami’s picture

@yas
These code move to K8sBlockTrait, so they can be removed.

yas’s picture

@masami

Thank you for your confirmation.

@all

What do you think?

MasatoTakada’s picture

@Onotomo-san @yas

It looks good to me in my part No12.

baldwinlouie’s picture

@all, patch looks good.

yas’s picture

Status: Needs review » Needs work

@all

Thank you for your review.

@onotm

I'll merge the patch --- Could you please create the patch for 8.x-1.x and 8.x-2.x?

onotm’s picture

Status: Needs work » Needs review
StatusFileSize
new100.57 KB
new95.96 KB
new98.51 KB

@yas
I create the patch for 8.x-1.x and 8.x-2.x and update the patch for 3.x.

yas’s picture

Status: Needs review » Reviewed & tested by the community

@onotm

Thank you for the update and your extra efforts. I'll merge the patch to 8.x-1.x, 8.x-2.x and 3.x and close this issue as Fixed.

  • yas committed 851f728 on 8.x-1.x authored by onotm
    Issue #3164928 by onotm, yas, Xiaohua Guan, Masami, baldwinlouie,...

  • yas committed b76b720 on 8.x-2.x authored by onotm
    Issue #3164928 by onotm, yas, Xiaohua Guan, Masami, baldwinlouie,...

  • yas committed 190df70 on 3.x authored by onotm
    Issue #3164928 by onotm, yas, Xiaohua Guan, Masami, baldwinlouie,...
yas’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.