arkaitzgarro/elastic-apm-laravel

View on GitHub
src/Collectors/EventDataCollector.php

Summary

Maintainability
A
2 hrs
Test Coverage
A
100%

Method addMeasure has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        string $label,
        float $start,
        float $end,
        string $type = 'request',
        ?string $action = 'request',
Severity: Minor
Found in src/Collectors/EventDataCollector.php - About 45 mins to fix

    Method pushMeasure has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            string $label,
            float $start,
            float $end,
            string $type = 'request',
            ?string $action = 'request',
    Severity: Minor
    Found in src/Collectors/EventDataCollector.php - About 45 mins to fix

      Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          final public function __construct(Application $app, Config $config, RequestStartTime $start_time, EventCounter $event_counter, EventClock $event_clock)
      Severity: Minor
      Found in src/Collectors/EventDataCollector.php - About 35 mins to fix

        Method startMeasure has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                string $name,
                string $type = 'request',
                ?string $action = null,
                ?string $label = null,
                ?float $start_time = null
        Severity: Minor
        Found in src/Collectors/EventDataCollector.php - About 35 mins to fix

          Avoid using static access to class '\Illuminate\Support\Facades\Log' in method 'startMeasure'.
          Open

                      Log::warning("Did not start measure '{$name}' because it's already started.");
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          StaticAccess

          Since: 1.4.0

          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

          Example

          class Foo
          {
              public function bar()
              {
                  Bar::baz();
              }
          }

          Source https://phpmd.org/rules/cleancode.html#staticaccess

          Avoid using static access to class '\Illuminate\Support\Facades\Log' in method 'stopMeasure'.
          Open

                      Log::warning("Did not stop measure '{$name}' because it hasn't been started.");
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          StaticAccess

          Since: 1.4.0

          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

          Example

          class Foo
          {
              public function bar()
              {
                  Bar::baz();
              }
          }

          Source https://phpmd.org/rules/cleancode.html#staticaccess

          Define a constant instead of duplicating this literal "start" 3 times.
          Open

                      'start' => $start - $transactionStart,
          Severity: Critical
          Found in src/Collectors/EventDataCollector.php by sonar-php

          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

          Noncompliant Code Example

          With the default threshold of 3:

          function run() {
            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
            execute('action1');
            release('action1');
          }
          

          Compliant Solution

          ACTION_1 = 'action1';
          
          function run() {
            prepare(ACTION_1);
            execute(ACTION_1);
            release(ACTION_1);
          }
          

          Exceptions

          To prevent generating some false-positives, literals having less than 5 characters are excluded.

          Define a constant instead of duplicating this literal "action" 3 times.
          Open

                      'action' => $action,
          Severity: Critical
          Found in src/Collectors/EventDataCollector.php by sonar-php

          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

          Noncompliant Code Example

          With the default threshold of 3:

          function run() {
            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
            execute('action1');
            release('action1');
          }
          

          Compliant Solution

          ACTION_1 = 'action1';
          
          function run() {
            prepare(ACTION_1);
            execute(ACTION_1);
            release(ACTION_1);
          }
          

          Exceptions

          To prevent generating some false-positives, literals having less than 5 characters are excluded.

          Define a constant instead of duplicating this literal "request" 5 times.
          Open

                  string $type = 'request',
          Severity: Critical
          Found in src/Collectors/EventDataCollector.php by sonar-php

          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

          Noncompliant Code Example

          With the default threshold of 3:

          function run() {
            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
            execute('action1');
            release('action1');
          }
          

          Compliant Solution

          ACTION_1 = 'action1';
          
          function run() {
            prepare(ACTION_1);
            execute(ACTION_1);
            release(ACTION_1);
          }
          

          Exceptions

          To prevent generating some false-positives, literals having less than 5 characters are excluded.

          Define a constant instead of duplicating this literal "label" 3 times.
          Open

                      'label' => $label ?: $name,
          Severity: Critical
          Found in src/Collectors/EventDataCollector.php by sonar-php

          Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

          On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

          Noncompliant Code Example

          With the default threshold of 3:

          function run() {
            prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
            execute('action1');
            release('action1');
          }
          

          Compliant Solution

          ACTION_1 = 'action1';
          
          function run() {
            prepare(ACTION_1);
            execute(ACTION_1);
            release(ACTION_1);
          }
          

          Exceptions

          To prevent generating some false-positives, literals having less than 5 characters are excluded.

          The parameter $start_time is not named in camelCase.
          Open

              public function startMeasure(
                  string $name,
                  string $type = 'request',
                  ?string $action = null,
                  ?string $label = null,
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCaseParameterName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name parameters.

          Example

          class ClassName {
              public function doSomething($user_name) {
              }
          }

          Source

          The property $started_measures is not named in camelCase.
          Open

          abstract class EventDataCollector implements DataCollector
          {
              /** @var Application */
              protected $app;
          
          
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCasePropertyName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name attributes.

          Example

          class ClassName {
              protected $property_name;
          }

          Source

          The parameter $start_time is not named in camelCase.
          Open

              final public function __construct(Application $app, Config $config, RequestStartTime $start_time, EventCounter $event_counter, EventClock $event_clock)
              {
                  $this->app = $app;
                  $this->config = $config;
                  $this->start_time = $start_time;
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCaseParameterName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name parameters.

          Example

          class ClassName {
              public function doSomething($user_name) {
              }
          }

          Source

          The property $event_counter is not named in camelCase.
          Open

          abstract class EventDataCollector implements DataCollector
          {
              /** @var Application */
              protected $app;
          
          
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCasePropertyName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name attributes.

          Example

          class ClassName {
              protected $property_name;
          }

          Source

          The parameter $transaction_name is not named in camelCase.
          Open

              protected function getTransaction(string $transaction_name): ?Transaction
              {
                  try {
                      return $this->agent->getTransaction($transaction_name);
                  } catch (UnknownTransactionException $e) {
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCaseParameterName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name parameters.

          Example

          class ClassName {
              public function doSomething($user_name) {
              }
          }

          Source

          The parameter $event_counter is not named in camelCase.
          Open

              final public function __construct(Application $app, Config $config, RequestStartTime $start_time, EventCounter $event_counter, EventClock $event_clock)
              {
                  $this->app = $app;
                  $this->config = $config;
                  $this->start_time = $start_time;
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCaseParameterName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name parameters.

          Example

          class ClassName {
              public function doSomething($user_name) {
              }
          }

          Source

          The property $start_time is not named in camelCase.
          Open

          abstract class EventDataCollector implements DataCollector
          {
              /** @var Application */
              protected $app;
          
          
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCasePropertyName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name attributes.

          Example

          class ClassName {
              protected $property_name;
          }

          Source

          The property $event_clock is not named in camelCase.
          Open

          abstract class EventDataCollector implements DataCollector
          {
              /** @var Application */
              protected $app;
          
          
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCasePropertyName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name attributes.

          Example

          class ClassName {
              protected $property_name;
          }

          Source

          The parameter $event_clock is not named in camelCase.
          Open

              final public function __construct(Application $app, Config $config, RequestStartTime $start_time, EventCounter $event_counter, EventClock $event_clock)
              {
                  $this->app = $app;
                  $this->config = $config;
                  $this->start_time = $start_time;
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCaseParameterName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name parameters.

          Example

          class ClassName {
              public function doSomething($user_name) {
              }
          }

          Source

          The parameter $transaction_name is not named in camelCase.
          Open

              protected function shouldIgnoreTransaction(string $transaction_name): bool
              {
                  $pattern = $this->config->get('elastic-apm-laravel.transactions.ignorePatterns');
          
                  return $pattern && preg_match($pattern, $transaction_name);
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCaseParameterName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name parameters.

          Example

          class ClassName {
              public function doSomething($user_name) {
              }
          }

          Source

          The variable $event_clock is not named in camelCase.
          Open

              final public function __construct(Application $app, Config $config, RequestStartTime $start_time, EventCounter $event_counter, EventClock $event_clock)
              {
                  $this->app = $app;
                  $this->config = $config;
                  $this->start_time = $start_time;
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCaseVariableName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name variables.

          Example

          class ClassName {
              public function doSomething() {
                  $data_module = new DataModule();
              }
          }

          Source

          The variable $start_time is not named in camelCase.
          Open

              final public function __construct(Application $app, Config $config, RequestStartTime $start_time, EventCounter $event_counter, EventClock $event_clock)
              {
                  $this->app = $app;
                  $this->config = $config;
                  $this->start_time = $start_time;
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCaseVariableName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name variables.

          Example

          class ClassName {
              public function doSomething() {
                  $data_module = new DataModule();
              }
          }

          Source

          The variable $start_time is not named in camelCase.
          Open

              public function startMeasure(
                  string $name,
                  string $type = 'request',
                  ?string $action = null,
                  ?string $label = null,
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCaseVariableName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name variables.

          Example

          class ClassName {
              public function doSomething() {
                  $data_module = new DataModule();
              }
          }

          Source

          The variable $event_counter is not named in camelCase.
          Open

              final public function __construct(Application $app, Config $config, RequestStartTime $start_time, EventCounter $event_counter, EventClock $event_clock)
              {
                  $this->app = $app;
                  $this->config = $config;
                  $this->start_time = $start_time;
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCaseVariableName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name variables.

          Example

          class ClassName {
              public function doSomething() {
                  $data_module = new DataModule();
              }
          }

          Source

          The variable $transaction_name is not named in camelCase.
          Open

              protected function getTransaction(string $transaction_name): ?Transaction
              {
                  try {
                      return $this->agent->getTransaction($transaction_name);
                  } catch (UnknownTransactionException $e) {
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCaseVariableName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name variables.

          Example

          class ClassName {
              public function doSomething() {
                  $data_module = new DataModule();
              }
          }

          Source

          The variable $transaction_name is not named in camelCase.
          Open

              protected function shouldIgnoreTransaction(string $transaction_name): bool
              {
                  $pattern = $this->config->get('elastic-apm-laravel.transactions.ignorePatterns');
          
                  return $pattern && preg_match($pattern, $transaction_name);
          Severity: Minor
          Found in src/Collectors/EventDataCollector.php by phpmd

          CamelCaseVariableName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name variables.

          Example

          class ClassName {
              public function doSomething() {
                  $data_module = new DataModule();
              }
          }

          Source

          There are no issues that match your filters.

          Category
          Status