Problem/Motivation

getName should be removed and needs to be corrected ad id()
See #2384601: Rename Sensor to SensorPlugin

   public function getName() {
     return $this->id;
   }

Proposed resolution

Remaining tasks

User interface changes

API changes

Comments

Anushka-mp’s picture

Title: Remove getName() use id() instead » Remove getName( ) use id( ) instead
Anushka-mp’s picture

Status: Active » Needs review
StatusFileSize
new15.66 KB

getName() changed to id()

berdir’s picture

Status: Needs review » Needs work

Looks like there are a few wrapper methods and variable names/string placeholders that we should rename as well...

  1. +++ b/monitoring.drush.inc
    @@ -169,7 +169,7 @@ function monitoring_drush_info_single($sensor_name) {
    -  $rows[] = array(String::format("@label (@name)", array('@label' => $sensor_config->getLabel(), '@name' => $sensor_config->getName())), '====================');
    +  $rows[] = array(String::format("@label (@name)", array('@label' => $sensor_config->getLabel(), '@name' => $sensor_config->id())), '====================');
    

    Lets also rename @name to @id.

  2. +++ b/monitoring.drush.inc
    @@ -291,7 +291,7 @@ function monitoring_drush_result_output_table(array $results, $show_exec_time =
    -  $rows[] = array(dt('Name'), $result->getSensorConfig()->getName());
    +  $rows[] = array(dt('Name'), $result->getSensorConfig()->id());
    

    Same here, ID

  3. +++ b/src/Entity/SensorConfig.php
    @@ -127,7 +127,7 @@ class SensorConfig extends ConfigEntityBase {
        * @return string
        *   Sensor ID.
        */
    -  public function getName() {
    +  public function id() {
         return $this->id;
       }
    

    This should now be the same implementation as the parent, so you should be able to remove it?

  4. +++ b/src/Result/SensorResult.php
    @@ -477,7 +477,7 @@ class SensorResult implements SensorResultInterface {
       public function getSensorName() {
    -    return $this->sensorConfig->getName();
    +    return $this->sensorConfig->id();
       }
    

    getSensorId() then here.

  5. +++ b/src/SensorPlugin/SensorPluginBase.php
    @@ -76,7 +76,7 @@ abstract class SensorPluginBase implements SensorPluginInterface {
       public function getSensorName() {
    -    return $this->sensorConfig->getName();
    +    return $this->sensorConfig->id();
       }
    

    Same here.

  6. +++ b/src/SensorRunner.php
    @@ -159,14 +159,14 @@ class SensorRunner {
    -      throw new DisabledSensorException(String::format('Sensor @sensor_name is not enabled and must not be run.', array('@sensor_name' => $sensor_config->getName())));
    +      throw new DisabledSensorException(String::format('Sensor @sensor_name is not enabled and must not be run.', array('@sensor_name' => $sensor_config->id())));
    

    @sensor_name => @sensor_id.

Anushka-mp’s picture

Status: Needs work » Needs review
StatusFileSize
new3.42 KB
new15.89 KB

Leftovers corrected.

Anushka-mp’s picture

getSensorName() usages corrected to getSensorId.

miro_dietiker’s picture

Status: Needs review » Needs work

Good. Still some work.
Regarding usage of getSensorName => getSensorId... Why not use refactoring and it is done automatically?

  1. +++ b/monitoring.drush.inc
    @@ -169,7 +169,7 @@ function monitoring_drush_info_single($sensor_name) {
    +  $rows[] = array(String::format("@label (@id)", array('@label' => $sensor_config->getLabel(), '@id' => $sensor_config->id())), '====================');
    
    +++ b/src/SensorRunner.php
    @@ -159,7 +159,7 @@ class SensorRunner {
    +      throw new DisabledSensorException(String::format('Sensor @sensor_id is not enabled and must not be run.', array('@sensor_id' => $sensor_config->id())));
    

    @id or @sensor_id?
    I think we should consistently use sensor_ prefix in string.

  2. +++ b/monitoring.drush.inc
    @@ -291,7 +291,7 @@ function monitoring_drush_result_output_table(array $results, $show_exec_time =
    +  $rows[] = array(dt('Id'), $result->getSensorConfig()->id());
    

    Id => ID

The last submitted patch, 4: monitoring-2389111-remove-get-name-3.patch, failed testing.

miro_dietiker’s picture

Status: Needs work » Needs review
StatusFileSize
new21.53 KB

OK, some minor fixings. Let's still run the tests again to make sure everything goes well.

I id not unify @id and @sensor_id. There are still many other occurences. Will do a followup for global cleanup.

miro_dietiker’s picture

Status: Needs review » Fixed

Tests pass locally.
Committed, pushed.

Status: Fixed » Needs work

The last submitted patch, 8: monitoring_2389111_id_9.patch, failed testing.

miro_dietiker’s picture

Status: Needs work » Fixed

Too late, bot.

Status: Fixed » Closed (fixed)

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